|
各位请教一下,做一个基本的DDraw程序,main函数如下(省略了消息处理和ddraw初始化函数)
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("Game");
HWND hwnd; //窗口句柄
MSG msg;
WNDCLASS wndclass;
wndclass.style = NULL;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = NULL;
wndclass.hCursor = NULL;
wndclass.hbrBackground = NULL;
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
if(!RegisterClass(&wndclass))
{
MessageBox ( NULL, "Failed registing window.",
szAppName, MB_ICONERROR);
return 0;
}
hwnd = CreateWindow(szAppName, // window class name
TEXT("The Hello Program"), // window caption
WS_POPUP|WS_MAXIMIZE, // window style
CW_USEDEFAULT,// initial x position
CW_USEDEFAULT,// initial y position
GetSystemMetrics( SM_CXSCREEN ),// initial x size
GetSystemMetrics( SM_CYSCREEN ),// initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(1)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
程序编译一执行就出错,F10的结果是在createwindow函数结尾处出错:Unhandled exception in Game.exe:0xC0000005:Access Violation
请问是为什么呢??
如果我去掉这个paint函数,就不会出现这个情况.但是这个paint函数是贴图和换页的函数,不能省略的
|
|