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
}
不过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
}
解决方案 »
- opengl初始化失败的问题
- 数组内替换后换行的问题!
- 有谁是伊爱高新公司的,请教协议解析问题
- 用gdi+的Bitmap类读取jpg文件如何添加到CImageList中的问题?
- 各位大侠,绝对具有挑战的问题,参与者有分!
- 菜鸟问题:vs.net+SQL2000,连接数据库的一个傻问题
- 怎样显示TIP
- 请大家来讲讲为什么现在做WebApp用J2EE的多于用MSDCOM和COM+的,是微软的东西真的有缺点还是因为别的?
- 为什么下面回出错?
- 可以使用类似获取串口地址的方式获取并口地址吗?有没有获取并口地址的方法??求大神解救!!!!
- 寻求高手解答关于头文件stdafx.h的问题
- 求助!! 关于 ole 文档的问题, 研究了很久 也没有弄出来
不过重新建了项目,一样的代码,设置,release版也无法运行了
------------------------------------------------
应该是 if(GetMessage(&msg,NULL,0,0))
没什么关系
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
winclass.hIconSm = NULL;
不然的话这里不定是什么值,系统在加载小图标时就出问题了