金鳞
目标->软件测试架构师
IT博客
管理
公告
该博客已经停止更新了 {QQ群:44758540 (Enjoy Test 1)} {QQ群:82480755 (Enjoy Test 2)} {QQ群:82480523 (渗透测试-非专业群)}
留言簿
(4)
给我留言
查看公开留言
查看私人留言
随笔分类
*nix(10)
AWK(1)
c(1)
Mysql(1)
Oracle(1)
perl(1)
心情(22)
测试随聊(5)
文章分类
C(10)
information(1)
java(4)
Linux(7)
Loadrunner(3)
mysql(4)
net security(10)
Oracle(5)
perl(6)
perl-File::Find(1)
perl-Getopt::Long(1)
perl-LWP
perl-yaml(1)
QTP(4)
Selenium (1)
SQL Server(1)
产品改进(1)
养生(1)
好玩的(4)
正则表达式(1)
算法(1)
跟吃有关的美文(1)
过程改进
最新随笔
1. 找出低效SQL
2. 现在的领导都是屁股决定脑袋
3. 往数据库里导文件
4. 在中国联通办理宽带业务,看你晕不晕
5. linux文件系统分区
6. weblily和F谈安全总监都干点啥--名字都加密了,防社工的,^_^
7. 安装centos提示未找到任何驱动器--感谢景泰蓝同学
8. VM中设置linux上网--感谢醉生梦死 小梦小朋友
9. 感谢joe的分享,看到有位大牛做个针对进程统计IO情况的小工具
10. AWK(更新)
积分与排名
积分 - 52566
排名 - 115
最新评论
1. re: AWK(更新)
评论内容较长,点击标题查看
--egi
2. re: 用perl分析apache日志
cat /usr/local/apache/logs/access.log |grep -v "aaServlet\|bbServlet"|wc -l
这个更快
--d
3. re: Perl自动化测试脚本笔记--testage第三十四次(北京)软件测试交流会
评论内容较长,点击标题查看
--金鳞
4. re: Perl自动化测试脚本笔记--testage第三十四次(北京)软件测试交流会
希望学习perl软件测试
--彭晶
5. re: 转载 竹笋炒肉 的正则表达
其实竹笋炒鸡蛋也好吃,(*^__^*) 嘻嘻……
--金鳞
突然找到一个注释的很全面的程序
1
//
win32.cpp : Defines the entry point for the application.
2
//
3
4
#include
"
stdafx.h
"
//
包含有windows.h头文件
5
#include
"
resource.h
"
//
资源头文件,包含有各个资源的ID号。
6
7
#define
MAX_LOADSTRING 100
8
9
//
Global Variables:
10
HINSTANCE hInst;
//
current instance
11
TCHAR szTitle[MAX_LOADSTRING];
//
The title bar text
12
TCHAR szWindowClass[MAX_LOADSTRING];
//
The title bar text
13
14
//
Foward declarations of functions included in this code module:
15
16
BOOL MyRegisterClass(HINSTANCE hInstance);
//
注册窗口类
17
BOOL InitInstance(HINSTANCE,
int
);
//
初始化程序
18
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//
主窗口函数
19
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
//
两个都是CALLBACK(回调)函数
20
21
//
----------------------------------------------------------------------
22
//
程序的入口点WinMain函数
23
//
----------------------------------------------------------------------
24
int
CALLBACK WinMain(HINSTANCE hInstance,
25
HINSTANCE hPrevInstance,
26
LPSTR lpCmdLine,
27
int
nCmdShow)
28
{
29
//
TODO: Place code here.
30
MSG msg;
//
Windows的消息结构
31
HACCEL hAccelTable;
//
加速键表句柄(handle);
32
33
//
Initialize global strings
34
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
35
LoadString(hInstance, IDC_WIN32, szWindowClass, MAX_LOADSTRING);
36
MyRegisterClass(hInstance);
//
注册窗口类
37
38
//
Perform application initialization:
39
if
(
!
InitInstance (hInstance, nCmdShow))
//
实例的初始化
40
{
41
return
FALSE;
42
}
43
44
//
装入加速键表。
45
hAccelTable
=
LoadAccelerators(hInstance, (LPCTSTR)IDC_WIN32);
46
47
//
Main message loop:
48
while
(GetMessage(
&
msg, NULL,
0
,
0
))
//
从消息队列中获取消息
49
{
50
//
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
//
解释快捷键
51
{
52
TranslateMessage(
&
msg);
//
解释消息
53
DispatchMessage(
&
msg);
//
分派消息(到窗口函数中);
54
}
55
}
56
57
return
msg.wParam;
58
}
59
60
61
62
//
63
//
FUNCTION: MyRegisterClass()
64
//
65
//
PURPOSE: Registers the window class.
66
//
67
//
COMMENTS:
68
//
69
//
This function and its usage is only necessary if you want this code
70
//
to be compatible with Win32 systems prior to the 'RegisterClassEx'
71
//
function that was added to Windows 95. It is important to call this function
72
//
so that the application will get 'well formed' small icons associated
73
//
with it.
74
//
75
76
//
----------------------------------------------------------------------
77
//
注册窗口类,在产生窗口之前必须注册窗口类。
78
//
如同开一个公司之前,先要登记注册一样。
79
//
----------------------------------------------------------------------
80
BOOL MyRegisterClass(HINSTANCE hInstance)
81
{
82
WNDCLASSEX wcex;
83
84
wcex.cbSize
=
sizeof
(WNDCLASSEX);
85
86
wcex.style
=
CS_HREDRAW
|
CS_VREDRAW;
//
注册窗口的风格。
87
wcex.lpfnWndProc
=
(WNDPROC)WndProc;
//
注册窗口函数
88
wcex.cbClsExtra
=
0
;
//
为窗口类额外分配的字节(一般为0)
89
wcex.cbWndExtra
=
0
;
//
为窗口实例额外分配的字节(一般为0)
90
wcex.hInstance
=
hInstance;
//
实例句柄
91
wcex.hIcon
=
LoadIcon(hInstance, (LPCTSTR)IDI_WIN32);
//
大图标
92
wcex.hCursor
=
LoadCursor(NULL, IDC_ARROW);
//
光标
93
wcex.hbrBackground
=
(HBRUSH)(COLOR_WINDOW
+
1
);
//
窗口背景颜色
94
wcex.lpszMenuName
=
(LPCSTR)IDC_WIN32;
//
窗口的菜单名称(与类名一致)
95
wcex.lpszClassName
=
szWindowClass;
//
窗口类名称。
96
wcex.hIconSm
=
LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
//
小图标
97
98
return
RegisterClassEx(
&
wcex);
99
}
100
101
//
102
//
FUNCTION: InitInstance(HANDLE, int)
103
//
104
//
PURPOSE: Saves instance handle and creates main window
105
//
106
//
COMMENTS:
107
//
108
//
In this function, we save the instance handle in a global variable and
109
//
create and display the main program window.
110
//
111
//
----------------------------------------------------------------------------
112
//
此函数用来产生窗口。
113
//
----------------------------------------------------------------------
114
BOOL InitInstance(HINSTANCE hInstance,
int
nCmdShow)
115
{
116
HWND hWnd;
117
118
hInst
=
hInstance;
//
Store instance handle in our global variable
119
120
hWnd
=
CreateWindow( szWindowClass,
//
窗口类名称
121
szTitle,
//
窗口标题
122
WS_OVERLAPPEDWINDOW,
//
窗口风格
123
CW_USEDEFAULT,
//
窗口位置x,用此参数会??
124
0
,
//
窗口位置y。为什么为0??
125
CW_USEDEFAULT,
//
窗口宽度
126
0
,
//
窗口高度。为什么为0??
127
NULL,
//
窗口的父窗口指针
128
NULL,
//
菜单指针
129
hInstance,
//
实例指针
130
NULL);
//
窗口创建参数
131
132
if
(
!
hWnd)
133
{
134
return
FALSE;
135
}
136
137
ShowWindow(hWnd, nCmdShow);
//
显示窗口
138
UpdateWindow(hWnd);
//
更新窗口,即通过发送WM_PAINT消息实现。
139
140
return
TRUE;
141
}
142
143
//
144
//
FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
145
//
146
//
PURPOSE: Processes messages for the main window.
147
//
148
//
WM_COMMAND - process the application menu
149
//
WM_PAINT - Paint the main window
150
//
WM_DESTROY - post a quit message and return
151
//
152
//
153
//
----------------------------------------------------------------------
154
//
主窗口函数(用来处理消息)
155
//
----------------------------------------------------------------------
156
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
157
{
158
int
wmId, wmEvent;
159
PAINTSTRUCT ps;
160
HDC hdc;
161
TCHAR szHello[MAX_LOADSTRING];
162
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
163
164
switch
(message)
165
{
166
case
WM_COMMAND:
167
wmId
=
LOWORD(wParam);
168
wmEvent
=
HIWORD(wParam);
169
//
Parse the menu selections:
170
switch
(wmId)
171
{
172
case
IDM_ABOUT:
173
DialogBox(hInst,
//
所属实例
174
(LPCTSTR)IDD_ABOUTBOX,
//
对话框资源名称。
175
hWnd,
//
父窗口
176
(DLGPROC)About);
//
对话框的窗口函数名称。
177
break
;
178
case
IDM_EXIT:
179
DestroyWindow(hWnd);
//
销毁窗口。
180
break
;
181
default
:
182
//
注意:不论什么消息,都必须被处理。
183
//
未被处理的消息由Windows系统缺省的窗口函数调用。
184
return
DefWindowProc(hWnd, message, wParam, lParam);
185
}
186
break
;
187
case
WM_PAINT:
//
重画
188
hdc
=
BeginPaint(hWnd,
&
ps);
189
//
TODO: Add any drawing code here
190
RECT rt;
191
GetClientRect(hWnd,
&
rt);
192
DrawText(hdc, szHello, strlen(szHello),
&
rt, DT_CENTER);
193
EndPaint(hWnd,
&
ps);
194
break
;
195
case
WM_DESTROY:
//
窗口已经被销毁,程序即将结束。
196
PostQuitMessage(
0
);
197
break
;
198
default
:
199
//
未被处理的消息由Windows系统缺省的窗口函数调用。
200
return
DefWindowProc(hWnd, message, wParam, lParam);
201
}
202
return
0
;
203
}
204
205
//
Mesage handler for about box.
206
//
----------------------------------------------------------------------
207
//
处理对话框消息的窗口函数。
208
//
----------------------------------------------------------------------
209
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
210
{
211
switch
(message)
212
{
213
case
WM_INITDIALOG:
214
return
TRUE;
215
216
case
WM_COMMAND:
217
if
(LOWORD(wParam)
==
IDOK
||
LOWORD(wParam)
==
IDCANCEL)
218
{
219
EndDialog(hDlg, LOWORD(wParam));
220
return
TRUE;
221
}
222
break
;
223
}
224
return
FALSE;
//
FALSE表示没有处理这个消息。
225
}
原文:
http://read.pudn.com/downloads95/sourcecode/windows/388297/02%E7%AB%A0/win32/win32.cpp__.htm
posted on 2009-03-12 10:16
金鳞
阅读(333)
评论(0)
编辑
收藏
引用
所属分类:
C
只有注册用户
登录
后才能发表评论。
Powered by:
IT博客
Copyright © 金鳞