运行VC程序,但是主程序界面不显示,而程序却占很大的内存。经调试在
HWND hWnd = ::CreateWindowEx(cs.dwExStyle, cs.lpszClass,
cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy,
cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);
这条语句上有问题
说是lpszName 没有被付值。谁能告诉我问题在哪里。

解决方案 »

  1.   

    Creating a Main Window
    The first window an application creates is typically the main window. You create the main window by using the CreateWindowEx function, specifying the window class, window name, window styles, size, position, menu handle, instance handle, and creation data. A main window belongs to an application-defined window class, so you must register the window class and provide a window procedure for the class before creating the main window. Most applications typically use the WS_OVERLAPPEDWINDOW style to create the main window. This style gives the window a title bar, a window menu, a sizing border, and minimize and maximize buttons. The CreateWindowEx function returns a handle that uniquely identifies the window. The following example creates a main window belonging to an application-defined window class. The window name, Main Window, will appear in the window's title bar. By combining the WS_VSCROLL and WS_HSCROLL styles with the WS_OVERLAPPEDWINDOW style, the application creates a main window with horizontal and vertical scroll bars in addition to the components provided by the WS_OVERLAPPEDWINDOW style. The four occurrences of the CW_USEDEFAULT constant set the initial size and position of the window to the system-defined default values. By specifying NULL instead of a menu handle, the window will have the menu defined for the window class. HINSTANCE hinst; 
    HWND hwndMain; 
     
    // Create the main window. 
     
    hwndMain = CreateWindowEx( 
        0,                      // no extended styles           
        "MainWClass",           // class name                   
        "Main Window",          // window name                  
        WS_OVERLAPPEDWINDOW |   // overlapped window            
            WS_HSCROLL |        // horizontal scroll bar        
            WS_VSCROLL,         // vertical scroll bar          
        CW_USEDEFAULT,          // default horizontal position  
        CW_USEDEFAULT,          // default vertical position    
        CW_USEDEFAULT,          // default width                
        CW_USEDEFAULT,          // default height               
        (HWND) NULL,            // no parent or owner window    
        (HMENU) NULL,           // class menu used              
        hinstance,              // instance handle              
        NULL);                  // no window creation data      
     
    if (!hwndMain) 
        return FALSE; 
     
    // Show the window using the flag specified by the program 
    // that started the application, and send the application 
    // a WM_PAINT message. 
     
    ShowWindow(hwndMain, SW_SHOWDEFAULT); 
    UpdateWindow(hwndMain); 
    Notice that the preceding example calls the ShowWindow function after creating the main window. This is done because the system does not automatically display the main window after creating it. By passing the SW_SHOWDEFAULT flag to ShowWindow, the application allows the program that started the application to set the initial show state of the main window. The UpdateWindow function sends the window its first WM_PAINT message. 
      

  2.   

    我是在App类中开始调试的,在它的InitInstance()函数中的
    if (!ProcessShellCommand(cmdInfo))//在折射的断点
    return FALSE;
    但是调试时候,不继续往下走,就停在那,所以我就按F11进去继续调试,到
    HWND hWnd = ::CreateWindowEx(cs.dwExStyle, cs.lpszClass,
    cs.lpszName, cs.style, cs.x, cs.y, cs.cx, cs.cy,
    cs.hwndParent, cs.hMenu, cs.hInstance, cs.lpCreateParams);
    这里程序不能向下走了,但是在任务管理器中,可以看到程序在运行,占用CPU还很大,但是就是不显示主程序的界面。