C/C++培训
达内IT学院
400-996-5531
//用VC6.0或者VS的学员,请选择WIN32 APPLICATION
#include <stdio.h>
#include <windows.h>
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;
}
版权声明:转载文章来自公开网络,版权归作者本人所有,推送文章除非无法确认,我们都会注明作者和来源。如果出处有误或侵犯到原作者权益,请与我们联系删除或授权事宜。
填写下面表单即可预约申请免费试听!怕钱不够?可就业挣钱后再付学费! 怕学不会?助教全程陪读,随时解惑!担心就业?一地学习,可全国推荐就业!
Copyright © 京ICP备08000853号-56 京公网安备 11010802029508号 达内时代科技集团有限公司 版权所有
Tedu.cn All Rights Reserved