//用VC6.0或者VS的学员,请选择WIN32 APPLICATION
#include
#include
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch(msg)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, 0, 50, "欢迎来到邢帅公开课堂!",
strlen("欢迎来到邢帅公开课堂!"));
EndPaint(hwnd, &ps);
break;
case WM_CLOSE:
if(MessageBox(hwnd, "是否真的退出?", "询问", MB_YESNO) == IDYES)
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
break;
}
return 0;
}
//入口函数
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS wc;
HWND hwnd;
MSG msg;
//1.设计窗口类
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = CreateSolidBrush(RGB(255, 255, 255));
wc.lpszMenuName = NULL;
wc.lpszClassName = "xingshuai";
//2.注册窗口类
RegisterClass(&wc);
//3.创建窗口
hwnd = CreateWindow("xingshuai", "我的窗口", WS_OVERLAPPEDWINDOW,
200, 200, 800, 600, NULL, NULL, hInstance, NULL);
//4.显示并更新窗口
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
//5.消息循环
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
全部0条评论
快来发表一下你的评论吧 !