debug编译能通过,就是打开执行文件后,什么也没发生,窗口也没有
不过release版能正常运行出来编译器使用vc8.0,设置上就是把默认的unicode改成了多字节字符支持主要代码如下
事件处理函数只是负责一些基本的消息处理,所以就不列出来了
#define WIN32_LEAN_AND_MEAN
#include <windows.h>  
#include <windowsx.h>
int WINAPI WinMain(HINSTANCE hinstance,                      HINSTANCE hprevinstance                   LPSTR lpcmdline,                           int ncmdshow)          
{
MSG  msg;     
    
WNDCLASSEX winclass;
    
winclass.cbSize         = sizeof(WNDCLASSEX); 
winclass.style          = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc       = WndProc;   
winclass.cbClsExtra       = 0;
winclass.cbWndExtra       = 0;
winclass.hInstance       = hinstance;
winclass.hIcon       = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName   = NULL; 
winclass.lpszClassName  = "BasicWinFrame"; 
// register the window classif (!RegisterClassEx(&winclass))
    return(0);    
if(!(MainWndH=CreateWindowEx (NULL,
                           "BasicWinFrame",
                           "BasicWindow",  
                           (WINDOWED ? (WS_OVERLAPPED | WS_SYSMENU |WS_CAPTION) : (WS_POPUP |WS_VISIBLE)),
                           0,0,
                           WINDOW_WIDTH,WINDOW_HEIGHT,
                           NULL,
                           NULL,
                           hinstance,
                           NULL)))
             return(0);
      MainInstance  = hinstance;       // resize the window so that client is really width x height
  
    if (WINDOWED)
    {
        // now resize the window, so the client area is the actual size requested
        // since there may be borders and controls if this is going to be a windowed app
        // if the app is not windowed then it won't matter
        RECT window_rect = {0,0,WINDOW_WIDTH-1,WINDOW_HEIGHT-1};
        
        // make the call to adjust window_rect
        AdjustWindowRectEx(&window_rect,
            GetWindowStyle(MainWndH),
            GetMenu(MainWndH) != NULL,
            GetWindowExStyle(MainWndH));
        
        
        // now resize the window with a call to MoveWindow()
        MoveWindow(MainWndH,
            0, // x position
            0, // y position
            window_rect.right - window_rect.left, // width
            window_rect.bottom - window_rect.top, // height
            FALSE);
        
        ShowWindow(MainWndH, SW_SHOW);
    } // end if windowed
           // enter main event loop
        while(true)
    {
        
        if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
        { 
            // test if this is a quit
            if (msg.message == WM_QUIT)
                break;
    
            // translate any accelerator keys
            TranslateMessage(&msg);            // send the message to the window proc
            DispatchMessage(&msg);
        } // end if
    
       } // end while
}

解决方案 »

  1.   

    那还问什么啊??可以用就行了,发行版本也就是用release了
      

  2.   

    debug应该没问题啊
    不过重新建了项目,一样的代码,设置,release版也无法运行了
      

  3.   

    if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
    ------------------------------------------------
    应该是 if(GetMessage(&msg,NULL,0,0))
      

  4.   

    PeekMessage() 是为了构建无等待的事件循环
    没什么关系
      

  5.   

    老兄,你把代码贴全了看看,贴出个能编译的,也没有WinProc,那个Windowed也不知道做什么用的,怎么给你看啊
      

  6.   

    和回调函数大概也没什么关系#define WINDOWED true  //标识是否为窗口程序LRESULT CALLBACK WndProc(HWND hwnd,                    UINT msg, 
                             WPARAM wparam,
          LPARAM lparam)
    {

        PAINTSTRUCT ps;    // used in WM_PAINT
      
        switch(msg)
    {
    case WM_CREATE: 
            {
    // do initialization stuff here
    return(0);
    } break;    case WM_PAINT:
             {

             BeginPaint(hwnd,&ps);         // end painting
             EndPaint(hwnd,&ps);
             return(0);
            } break; case WM_DESTROY: 
    {
    // kill the application
    PostQuitMessage(0);
    return(0);
    } break; default:break;    } // end switchreturn (DefWindowProc(hwnd, msg, wparam, lparam));} // end WinProc
      

  7.   

    在初始化winclass时加上一条
    winclass.hIconSm = NULL;
    不然的话这里不定是什么值,系统在加载小图标时就出问题了