关于windows api 窗口的建立
#include<windows.h>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[]="windows"; //建造一个通用的类
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;//小写的lp 过程
wndclass.cbClsExtra=0;//小写的ls
wndclass.cbWndExtra=0;
wndclass.hInstance=hIstance;//大写的I hInstance
wndclass.hIcon=LoadIcon (NULL,IDI_APPLICATION);//加载图标资源 大写的I
wndclass.hCursor=LoadCursor (NULL,IDC_ARROW);
wndclass.hbrBackground=(HBTUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuNam=NULL;
wndclass.lpszClassName=szAppName;
if(!RegisterClass(&wndclass)) //判断一个类是否合法
{
MessageBox (NULL,TEXT("This program requires windows xp!"),
szAppName,MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(szAppName, //创建一个类明确它
TEXT("The Hello Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow (hwnd,iCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&msg,NULL,0,0)) //消息循环
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) //系统调用
{
HDC hdc;
PAINSTRUCT ps;
RECT rect;
switch(message)
{
case WM_PAINT;
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("Hello,Windows xp!"),-1,&rect, //内容
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY;
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
error C2065: 'hIstance' : undeclared identifier 未定义的标记符?
大家帮下我表示 已经弄了一上午了