游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1406|回复: 2

帮忙看看,窗口怎么出不来

[复制链接]

9

主题

58

帖子

64

积分

注册会员

Rank: 2

积分
64
发表于 2006-8-25 19:02:00 | 显示全部楼层 |阅读模式
debug编译能通过,就是打开执行文件后,什么也没发生,窗口也没有
不过release版能正常运行出来,不过新建个项目后,一样的代码,设置
release版就不能运行了


编译器使用vc8.0,设置上就是把默认的unicode改成了多字节字符支持

主要代码如下

#define WIN32_LEAN_AND_MEAN
#include <windows.h>  
#include <windowsx.h>

#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 switch

return (DefWindowProc(hwnd, msg, wparam, lparam));

} // end WinProc



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 class

if (!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
}


60

主题

1319

帖子

1319

积分

金牌会员

Rank: 6Rank: 6

积分
1319
发表于 2006-8-25 19:40:00 | 显示全部楼层

Re:帮忙看看,窗口怎么出不来

winclass.hIconSm没赋值。
写上
winclass.hIconSm = 0;
或者
winclass.hIconSm = winclass.hIcon;

9

主题

58

帖子

64

积分

注册会员

Rank: 2

积分
64
 楼主| 发表于 2006-8-25 20:57:00 | 显示全部楼层

Re:帮忙看看,窗口怎么出不来

谢谢
解决了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-25 04:55

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表