BASE_MFC
#include <stdio.h>
#include <windows.h>
LRESULT CALLBACK custWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam){
switch (msg)
{
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
hdc = BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
//HDC hdc,LPCSTR lpchText,int cchText,LPRECT lprc,UINT format
DrawText(hdc,TEXT("Hello WINDOW XP!"),-1,&rect,DT_INTERNAL);
EndPaint(hwnd,&ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInStance,LPTSTR lptCmd,int nCmdShow){
static TCHAR lpClassName[] = TEXT("WinProgram");
HWND hwnd;
MSG msg;
// UINT style;
// WNDPROC lpfnWndProc;
// int cbClsExtra;
// int cbWndExtra;
// HINSTANCE hInstance;
// HICON hIcon;
// HCURSOR hCursor;
// HBRUSH hbrBackground;
// LPCWSTR lpszMenuName;
// LPCWSTR lpszClassName;
WNDCLASS wClass;
wClass.style = CS_DROPSHADOW;
wClass.lpfnWndProc = custWndProc;
wClass.cbClsExtra = 0;
wClass.cbWndExtra = 0;
wClass.hInstance = hInstance;
wClass.hIcon = LoadIcon(hInstance,IDI_APPLICATION);
wClass.hCursor = LoadCursor(hInstance,IDC_ARROW);
wClass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH));
wClass.lpszClassName = lpClassName;
wClass.lpszMenuName = NULL;
if(!RegisterClass(&wClass)){
MessageBox(NULL,TEXT("注册窗口类失败!"),TEXT("WARNING"),MB_OK);
return 0;
}
//DWORD dwExStyle,LPCSTR lpClassName,LPCSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam
hwnd = CreateWindow(
lpClassName,
TEXT("MFC Program"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.lParam;
}