|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hThis, HINSTANCE hPrev, LPSTR szCmdLine, int iCmdShow)
{
// UNREFERENCED_PARAMETER(hPrev);
// UNREFERENCED_PARAMETER(szCmdLine);
WNDCLASS wndex ;
HWND hWnd;
MSG msg;
wndex.cbClsExtra = 0;
wndex.cbWndExtra = 0;
wndex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndex.hCursor = LoadCursor(NULL, IDC_ARROW);
wndex.hIcon = LoadIcon(NULL, IDI_APPLICATION );
wndex.hInstance = hThis;
wndex.lpfnWndProc = WndProc;
wndex.lpszClassName = TEXT("GUIProject");
wndex.lpszMenuName = NULL;
wndex.style = CS_HREDRAW ;
if (!RegisterClass(&wndex))
{
MessageBox(NULL, TEXT("我爱你"), TEXT("I LOVE YOU SO MUCH"), MB_OK);
return -1;
}
hWnd = CreateWindow(wndex.lpszClassName, TEXT("My First Windows Program"),
WS_OVERLAPPEDWINDOW, 100, 100, 640, 480,
NULL, NULL, hThis, NULL);
// hWnd = CreateWindow( TEXT("GUIProject"), TEXT("GUI Project"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
// CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hThis, NULL);
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//DestroyWindow(hWnd);
//UnregisterClass(wndex.lpszClassName,hThis);
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
///case WM_CLOSE:
// {
// PostQuitMessage(0);
// break;
// }
case WM_RBUTTONDOWN:
{
MessageBox(NULL, TEXT("晚安!"), TEXT("你好!"), MB_OK);
}
defult:
{
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
}
return 0;
}
|
|