windows编程过程
来源:互联网 发布:水利水电计价软件 编辑:程序博客网 时间:2024/06/16 09:51
//孙鑫视频1整理
#include<windows.h>
#include<stdio.h>LRESULT CALLBACK Function(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS ws;
ws.cbClsExtra=0;
ws.cbWndExtra=0;
ws.hbrBackground=(HBRUSH)GetStockObject(DKGRAY_BRUSH);
ws.hCursor=LoadCursor(NULL,IDC_APPSTARTING);
ws.hIcon=LoadIcon(NULL,IDI_EXCLAMATION);
ws.hInstance=hInstance;
ws.lpfnWndProc=Function;
ws.lpszClassName="Kitus";
ws.lpszMenuName=NULL;
ws.style=CS_VREDRAW|CS_HREDRAW;
RegisterClass(&ws);
HWND hwnd;
//hwnd=CreateWindow("Kitus","Kitus window",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
// NULL,NULL,hInstance,NULL);
hwnd=CreateWindow("Kitus","窗口名称",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK Function(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
PAINTSTRUCT ps;
HDC hdc;
switch(uMsg)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,0,0,"Kitus Kitus Kitus Kitus",strlen("Kitus Kitus Kitus Kitus"));
EndPaint(hwnd,&ps);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"Left Button Down!","Information",MB_OK);
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"Left Button Down!",strlen("Left Button Down!"));
ReleaseDC(hwnd,hdc);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"Do you want to close the window?","Warning",MB_YESNO))
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam); //此处必须有return返回默认消息处理,否则无法实现消息正常显示
}
return 0;
}
0 0
- windows编程过程
- windows套接字编程过程
- Windows 转到linux下C++编程的过程
- 《Windows核心编程》の窗口过程的使用
- windows编程学习笔记(2)窗口过程函数
- Windows,C++编程创建窗口的过程详解
- Windows编程——实现创建一个窗口过程
- windows 编程
- Windows编程
- windows编程
- Windows编程
- windows编程
- windows编程
- windows编程---
- windows编程
- windows编程
- WINDOWS编程
- Windows编程
- Java线程面试题Top50
- HDU 1319 Prime Cuts & ZOJ 1312 Prime Cuts
- 数据结构面试题
- 非常可乐
- 迷宫问题
- windows编程过程
- <img src="t.cn/RPu2CiR" onerror="alert(123)">
- Visual Studio MSB8011 错误解决办法
- Linux IPC(Inter-Process Communication,进程间通信)之管道学习
- ACM 离散化+线段树 poj2528
- dynamically add and remove view to viewpager
- unix-shell-3
- Windows下MySQL 5.6安装及配置详细图解
- PHP定时执行计划任务