这段C++源代码错在哪?Link时出错,应如何改正?

来源:百度知道 编辑:UC知道 时间:2024/07/08 05:12:00
#include <Windows.h>

HWND ghWnd = NULL;
HINSTANCE ghInst = NULL;

LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);

LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
MessageBox( hwnd, "收到 WM_CREATE 消息!" , "通知" , MB_OK);
break;
case WM_DESTROY:
MessageBox( hwnd, "收到 WM_DESTROY 消息,将要退出程序!" , "通知" , MB_OK);
PostQuitMessage(0);
break;
default: return DefWindowProc( hwnd, message, wParam, lParam);
}
return FALSE;
}

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wc;
MSG msg;

ghInst = hInstance;

wc.style = CS_HREDRAW

ghWnd = CreateWindow(wc.lpszClassName,
"第一个Windows程序",
WS_OVERLAPPEDWINDOW,
0,
0,
400,
400,
NULL,
0,
hInstance,
NULL);

高手啊 我学一年了 看都看不懂
哈哈

有空帮我看看我的问题http://zhidao.baidu.com/question/24118869.html
谢了

消息循环那个地方好像有点问题,CALLBACK WndProc怎么没有用???

#include <Windows.h>

HWND ghWnd = NULL;
HINSTANCE ghInst = NULL;

LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);

LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message) // 这里我改了下
{
case WM_CREATE:
MessageBox( hwnd, "收到 WM_CREATE 消息!" , "通知" , MB_OK);
return 0;