对话框,光标,字符串,位图——Windows编程上机作业之三
1. 光标
通过菜单选择使用ARROW、WAIT和一个自定义光标。
2.位图
设计五个位图。
3.对话框
设计一个模式对话框,复选五个位图的显示。
设计一个无模式对话框,单选五个位图中的一个进行显示。
设计一个打开文件通用对话框,通过消息框显示获取的文件名。
4.字符串
在客户区和标题栏显示的文字采用字符串资源定义的方法。所显示的文字信息不在程序中出现。
5.中英文菜单切换
将菜单项的显示文字定义为字符串资源或通过菜单整体切换
resource.h
1
//
{{NO_DEPENDENCIES}}
2 // Microsoft Visual C++ generated include file.
3 // Used by WinZJ.rc
4 //
5 #define IDI_WINZJ 101
6 #define IDC_WINZJ 102
7 #define IDA_WINZJ 103
8 #define IDM_WINZJ_CH 104
9 #define IDM_WINZJ_EN 105
10 #define IDS_APPNAME_CH 106
11 #define IDS_APPNAME_EN 107
12 #define IDS_WNDCLASSNAME 108
13 #define IDS_CURSOR_PREFIX_CH 109
14 #define IDS_CURSOR_PREFIX_EN 110
15 #define IDS_CURSOR_ARROW 111
16 #define IDS_CURSOR_WAIT 112
17 #define IDS_CURSOR_USER_CH 113
18 #define IDS_CURSOR_USER_EN 114
19 #define IDD_CHECK 115
20 #define IDB_A 116
21 #define IDB_B 117
22 #define IDB_C 118
23 #define IDB_D 119
24 #define IDB_E 120
25 #define IDD_RADIO 121
26 #define IDC_CHECK1 1001
27 #define IDC_CHECK2 1002
28 #define IDC_CHECK3 1003
29 #define IDC_CHECK4 1004
30 #define IDC_CHECK5 1005
31 #define IDC_RADIO1 1006
32 #define IDC_RADIO2 1007
33 #define IDC_RADIO3 1008
34 #define IDC_RADIO4 1009
35 #define IDC_RADIO5 1010
36 #define IDM_EXIT 40001
37 #define IDM_MODAL 40002
38 #define IDM_MODALLESS 40003
39 #define IDM_FILE 40004
40 #define IDM_ARROW 40005
41 #define IDM_WAIT 40006
42 #define IDM_USER 40007
43 #define IDM_CHINESE 40008
44 #define IDM_ENGLISH 40009
45 #define IDM_INFO 40010
46
47 // Next default values for new objects
48 //
49 #ifdef APSTUDIO_INVOKED
50 #ifndef APSTUDIO_READONLY_SYMBOLS
51 #define _APS_NEXT_RESOURCE_VALUE 122
52 #define _APS_NEXT_COMMAND_VALUE 40011
53 #define _APS_NEXT_CONTROL_VALUE 1011
54 #define _APS_NEXT_SYMED_VALUE 101
55 #endif
56 #endif
57
2 // Microsoft Visual C++ generated include file.
3 // Used by WinZJ.rc
4 //
5 #define IDI_WINZJ 101
6 #define IDC_WINZJ 102
7 #define IDA_WINZJ 103
8 #define IDM_WINZJ_CH 104
9 #define IDM_WINZJ_EN 105
10 #define IDS_APPNAME_CH 106
11 #define IDS_APPNAME_EN 107
12 #define IDS_WNDCLASSNAME 108
13 #define IDS_CURSOR_PREFIX_CH 109
14 #define IDS_CURSOR_PREFIX_EN 110
15 #define IDS_CURSOR_ARROW 111
16 #define IDS_CURSOR_WAIT 112
17 #define IDS_CURSOR_USER_CH 113
18 #define IDS_CURSOR_USER_EN 114
19 #define IDD_CHECK 115
20 #define IDB_A 116
21 #define IDB_B 117
22 #define IDB_C 118
23 #define IDB_D 119
24 #define IDB_E 120
25 #define IDD_RADIO 121
26 #define IDC_CHECK1 1001
27 #define IDC_CHECK2 1002
28 #define IDC_CHECK3 1003
29 #define IDC_CHECK4 1004
30 #define IDC_CHECK5 1005
31 #define IDC_RADIO1 1006
32 #define IDC_RADIO2 1007
33 #define IDC_RADIO3 1008
34 #define IDC_RADIO4 1009
35 #define IDC_RADIO5 1010
36 #define IDM_EXIT 40001
37 #define IDM_MODAL 40002
38 #define IDM_MODALLESS 40003
39 #define IDM_FILE 40004
40 #define IDM_ARROW 40005
41 #define IDM_WAIT 40006
42 #define IDM_USER 40007
43 #define IDM_CHINESE 40008
44 #define IDM_ENGLISH 40009
45 #define IDM_INFO 40010
46
47 // Next default values for new objects
48 //
49 #ifdef APSTUDIO_INVOKED
50 #ifndef APSTUDIO_READONLY_SYMBOLS
51 #define _APS_NEXT_RESOURCE_VALUE 122
52 #define _APS_NEXT_COMMAND_VALUE 40011
53 #define _APS_NEXT_CONTROL_VALUE 1011
54 #define _APS_NEXT_SYMED_VALUE 101
55 #endif
56 #endif
57
WinZJ.rc
1
//
Microsoft Visual C++ generated resource script.
2 //
3 #include " resource.h "
4
5 #define APSTUDIO_READONLY_SYMBOLS
6 /**/ /////////////////////////////////////////////////////////////////////////////
7 //
8 // Generated from the TEXTINCLUDE 2 resource.
9 //
10 #include " afxres.h "
11
12 /**/ /////////////////////////////////////////////////////////////////////////////
13 #undef APSTUDIO_READONLY_SYMBOLS
14
15 /**/ /////////////////////////////////////////////////////////////////////////////
16 // Chinese (Simplified, PRC) resources
17
18 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
19 LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
20
21 #ifdef APSTUDIO_INVOKED
22 /**/ /////////////////////////////////////////////////////////////////////////////
23 //
24 // TEXTINCLUDE
25 //
26
27 1 TEXTINCLUDE
28 BEGIN
29 " resource.h\0 "
30 END
31
32 2 TEXTINCLUDE
33 BEGIN
34 " #include "" afxres.h "" \r\n "
35 " \0 "
36 END
37
38 3 TEXTINCLUDE
39 BEGIN
40 " \r\n "
41 " \0 "
42 END
43
44 #endif // APSTUDIO_INVOKED
45
46
47 /**/ /////////////////////////////////////////////////////////////////////////////
48 //
49 // Icon
50 //
51
52 // Icon with lowest ID value placed first to ensure application icon
53 // remains consistent on all systems.
54 IDI_WINZJ ICON " WinZJ.ico "
55
56 /**/ /////////////////////////////////////////////////////////////////////////////
57 //
58 // Menu
59 //
60
61 IDM_WINZJ_CH MENU
62 BEGIN
63 POPUP " 文件(&F) "
64 BEGIN
65 MENUITEM " 退出(&X) " , IDM_EXIT
66 END
67 POPUP " 对话框(&O) "
68 BEGIN
69 MENUITEM " 打开模式对话框(&M)\tCtrl+A " , IDM_MODAL
70 MENUITEM " 打开无模式对话框(&L)\tCtrl+B " , IDM_MODALLESS
71 MENUITEM " 打开文件对话框(&F)\tCtrl+C " , IDM_FILE
72 END
73 POPUP " 光标类型(&C) "
74 BEGIN
75 MENUITEM " 光标&1(ARROW)\tCtrl+1 " , IDM_ARROW
76 MENUITEM " 光标&2(WAIT)\tCtrl+2 " , IDM_WAIT
77 MENUITEM " 光标&3(User)\tCtrl+3 " , IDM_USER
78 END
79 POPUP " 语言(&L) "
80 BEGIN
81 MENUITEM " 中文(&C)\tCtrl+Shift+C " , IDM_CHINESE
82 MENUITEM " &English\tCtrl+Shift+D " , IDM_ENGLISH
83 END
84 POPUP " 关于(&A) "
85 BEGIN
86 MENUITEM " 程序信息(&I)\tF1 " , IDM_INFO
87 END
88 END
89
90
91 /**/ /////////////////////////////////////////////////////////////////////////////
92 //
93 // Cursor
94 //
95
96 IDC_WINZJ CURSOR " WinZJ.cur "
97
98 /**/ /////////////////////////////////////////////////////////////////////////////
99 //
100 // Accelerator
101 //
102
103 IDA_WINZJ ACCELERATORS
104 BEGIN
105 VK_F1, IDM_INFO, VIRTKEY, NOINVERT
106 " A " , IDM_MODAL, VIRTKEY, CONTROL, NOINVERT
107 " B " , IDM_MODALLESS, VIRTKEY, CONTROL, NOINVERT
108 " C " , IDM_FILE, VIRTKEY, CONTROL, NOINVERT
109 " 1 " , IDM_ARROW, VIRTKEY, CONTROL, NOINVERT
110 " 2 " , IDM_WAIT, VIRTKEY, CONTROL, NOINVERT
111 " 3 " , IDM_USER, VIRTKEY, CONTROL, NOINVERT
112 " C " , IDM_CHINESE, VIRTKEY, SHIFT, CONTROL, NOINVERT
113 " D " , IDM_ENGLISH, VIRTKEY, SHIFT, CONTROL, NOINVERT
114 END
115
116
117 /**/ /////////////////////////////////////////////////////////////////////////////
118 //
119 // Dialog
120 //
121
122 IDD_CHECK DIALOGEX 50 , 50 , 185 , 142
123 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
124 CAPTION " 复选显示位图选择 "
125 FONT 8 , " MS Shell Dlg " , 400 , 0 , 0x1
126 BEGIN
127 DEFPUSHBUTTON " 确定 " ,IDOK, 128 , 15 , 50 , 14
128 PUSHBUTTON " 取消 " ,IDCANCEL, 128 , 44 , 50 , 14
129 CONTROL " 复选位图 1 " ,IDC_CHECK1, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 26 , 54 , 10
130 CONTROL " 复选位图 2 " ,IDC_CHECK2, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 46 , 54 , 10
131 CONTROL " 复选位图 3 " ,IDC_CHECK3, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 66 , 54 , 10
132 CONTROL " 复选位图 4 " ,IDC_CHECK4, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 86 , 54 , 10
133 CONTROL " 复选位图 5 " ,IDC_CHECK5, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 106 , 54 , 10
134 END
135
136 IDD_RADIO DIALOGEX 50 , 50 , 185 , 142
137 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
138 CAPTION " 单选显示位图选择 "
139 FONT 8 , " MS Shell Dlg " , 400 , 0 , 0x1
140 BEGIN
141 DEFPUSHBUTTON " 确定 " ,IDOK, 128 , 15 , 50 , 14
142 PUSHBUTTON " 取消 " ,IDCANCEL, 128 , 44 , 50 , 14
143 CONTROL " 单选位图 1 " ,IDC_RADIO1, " Button " ,BS_AUTORADIOBUTTON, 31 , 26 , 54 , 10
144 CONTROL " 单选位图 2 " ,IDC_RADIO2, " Button " ,BS_AUTORADIOBUTTON, 31 , 46 , 54 , 10
145 CONTROL " 单选位图 3 " ,IDC_RADIO3, " Button " ,BS_AUTORADIOBUTTON, 31 , 66 , 54 , 10
146 CONTROL " 单选位图 4 " ,IDC_RADIO4, " Button " ,BS_AUTORADIOBUTTON, 31 , 86 , 54 , 10
147 CONTROL " 单选位图 5 " ,IDC_RADIO5, " Button " ,BS_AUTORADIOBUTTON, 31 , 106 , 54 , 10
148 END
149
150
151 /**/ /////////////////////////////////////////////////////////////////////////////
152 //
153 // DESIGNINFO
154 //
155
156 #ifdef APSTUDIO_INVOKED
157 GUIDELINES DESIGNINFO
158 BEGIN
159 IDD_CHECK, DIALOG
160 BEGIN
161 LEFTMARGIN, 7
162 RIGHTMARGIN, 178
163 TOPMARGIN, 7
164 BOTTOMMARGIN, 135
165 END
166
167 IDD_RADIO, DIALOG
168 BEGIN
169 LEFTMARGIN, 7
170 RIGHTMARGIN, 178
171 TOPMARGIN, 7
172 BOTTOMMARGIN, 135
173 END
174 END
175 #endif // APSTUDIO_INVOKED
176
177
178 /**/ /////////////////////////////////////////////////////////////////////////////
179 //
180 // Bitmap
181 //
182
183 IDB_A BITMAP " bmpA.bmp "
184 IDB_B BITMAP " bmpB.bmp "
185 IDB_C BITMAP " bmpC.bmp "
186 IDB_D BITMAP " bmpD.bmp "
187 IDB_E BITMAP " bmpE.bmp "
188
189 /**/ /////////////////////////////////////////////////////////////////////////////
190 //
191 // String Table
192 //
193
194 STRINGTABLE
195 BEGIN
196 IDS_APPNAME_CH " 第三次作业 "
197 IDS_APPNAME_EN " My Work 3 "
198 IDS_WNDCLASSNAME " WinZJ "
199 IDS_CURSOR_PREFIX_CH " 当前使用的光标是: "
200 IDS_CURSOR_PREFIX_EN " The current cursor is : "
201 IDS_CURSOR_ARROW " IDC_ARROW "
202 END
203
204 STRINGTABLE
205 BEGIN
206 IDS_CURSOR_WAIT " IDC_WAIT "
207 IDS_CURSOR_USER_CH " 我画的光标 "
208 IDS_CURSOR_USER_EN " MY CURSOR "
209 END
210
211 #endif // Chinese (Simplified, PRC) resources
212 /**/ /////////////////////////////////////////////////////////////////////////////
213
214
215/////////////////////////////////////////////////////////////////////////////
216 // English resources
217
218 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
219 LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
220
221 /**/ /////////////////////////////////////////////////////////////////////////////
222 //
223 // Menu
224 //
225
226 IDM_WINZJ_EN MENU
227 BEGIN
228 POPUP " &File "
229 BEGIN
230 MENUITEM " E&xit " , IDM_EXIT
231 END
232 POPUP " &OpenDialog "
233 BEGIN
234 MENUITEM " Open &Modal Dialog\tCtrl+A " , IDM_MODAL
235 MENUITEM " Open Modal&Less Dialog\tCtrl+B " , IDM_MODALLESS
236 MENUITEM " Open &File Dialog\tCtrl+C " , IDM_FILE
237 END
238 POPUP " &Cursor "
239 BEGIN
240 MENUITEM " Cursor&1(ARROW)\tCtrl+1 " , IDM_ARROW
241 MENUITEM " Cursor&2(WAIT)\tCtrl+2 " , IDM_WAIT
242 MENUITEM " Cursor&3(User)\tCtrl+3 " , IDM_USER
243 END
244 POPUP " &Language "
245 BEGIN
246 MENUITEM " 中文(&C)\tCtrl+Shift+C " , IDM_CHINESE
247 MENUITEM " &English\tCtrl+Shift+D " , IDM_ENGLISH
248 END
249 POPUP " &About "
250 BEGIN
251 MENUITEM " Program &Information\tF1 " , IDM_INFO
252 END
253 END
254
255 #endif // English resources
256 /**/ /////////////////////////////////////////////////////////////////////////////
257
258
259
260 #ifndef APSTUDIO_INVOKED
261 /**/ /////////////////////////////////////////////////////////////////////////////
262 //
263 // Generated from the TEXTINCLUDE 3 resource.
264 //
265
266
267 /**/ /////////////////////////////////////////////////////////////////////////////
268 #endif // not APSTUDIO_INVOKED
269
270
2 //
3 #include " resource.h "
4
5 #define APSTUDIO_READONLY_SYMBOLS
6 /**/ /////////////////////////////////////////////////////////////////////////////
7 //
8 // Generated from the TEXTINCLUDE 2 resource.
9 //
10 #include " afxres.h "
11
12 /**/ /////////////////////////////////////////////////////////////////////////////
13 #undef APSTUDIO_READONLY_SYMBOLS
14
15 /**/ /////////////////////////////////////////////////////////////////////////////
16 // Chinese (Simplified, PRC) resources
17
18 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
19 LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
20
21 #ifdef APSTUDIO_INVOKED
22 /**/ /////////////////////////////////////////////////////////////////////////////
23 //
24 // TEXTINCLUDE
25 //
26
27 1 TEXTINCLUDE
28 BEGIN
29 " resource.h\0 "
30 END
31
32 2 TEXTINCLUDE
33 BEGIN
34 " #include "" afxres.h "" \r\n "
35 " \0 "
36 END
37
38 3 TEXTINCLUDE
39 BEGIN
40 " \r\n "
41 " \0 "
42 END
43
44 #endif // APSTUDIO_INVOKED
45
46
47 /**/ /////////////////////////////////////////////////////////////////////////////
48 //
49 // Icon
50 //
51
52 // Icon with lowest ID value placed first to ensure application icon
53 // remains consistent on all systems.
54 IDI_WINZJ ICON " WinZJ.ico "
55
56 /**/ /////////////////////////////////////////////////////////////////////////////
57 //
58 // Menu
59 //
60
61 IDM_WINZJ_CH MENU
62 BEGIN
63 POPUP " 文件(&F) "
64 BEGIN
65 MENUITEM " 退出(&X) " , IDM_EXIT
66 END
67 POPUP " 对话框(&O) "
68 BEGIN
69 MENUITEM " 打开模式对话框(&M)\tCtrl+A " , IDM_MODAL
70 MENUITEM " 打开无模式对话框(&L)\tCtrl+B " , IDM_MODALLESS
71 MENUITEM " 打开文件对话框(&F)\tCtrl+C " , IDM_FILE
72 END
73 POPUP " 光标类型(&C) "
74 BEGIN
75 MENUITEM " 光标&1(ARROW)\tCtrl+1 " , IDM_ARROW
76 MENUITEM " 光标&2(WAIT)\tCtrl+2 " , IDM_WAIT
77 MENUITEM " 光标&3(User)\tCtrl+3 " , IDM_USER
78 END
79 POPUP " 语言(&L) "
80 BEGIN
81 MENUITEM " 中文(&C)\tCtrl+Shift+C " , IDM_CHINESE
82 MENUITEM " &English\tCtrl+Shift+D " , IDM_ENGLISH
83 END
84 POPUP " 关于(&A) "
85 BEGIN
86 MENUITEM " 程序信息(&I)\tF1 " , IDM_INFO
87 END
88 END
89
90
91 /**/ /////////////////////////////////////////////////////////////////////////////
92 //
93 // Cursor
94 //
95
96 IDC_WINZJ CURSOR " WinZJ.cur "
97
98 /**/ /////////////////////////////////////////////////////////////////////////////
99 //
100 // Accelerator
101 //
102
103 IDA_WINZJ ACCELERATORS
104 BEGIN
105 VK_F1, IDM_INFO, VIRTKEY, NOINVERT
106 " A " , IDM_MODAL, VIRTKEY, CONTROL, NOINVERT
107 " B " , IDM_MODALLESS, VIRTKEY, CONTROL, NOINVERT
108 " C " , IDM_FILE, VIRTKEY, CONTROL, NOINVERT
109 " 1 " , IDM_ARROW, VIRTKEY, CONTROL, NOINVERT
110 " 2 " , IDM_WAIT, VIRTKEY, CONTROL, NOINVERT
111 " 3 " , IDM_USER, VIRTKEY, CONTROL, NOINVERT
112 " C " , IDM_CHINESE, VIRTKEY, SHIFT, CONTROL, NOINVERT
113 " D " , IDM_ENGLISH, VIRTKEY, SHIFT, CONTROL, NOINVERT
114 END
115
116
117 /**/ /////////////////////////////////////////////////////////////////////////////
118 //
119 // Dialog
120 //
121
122 IDD_CHECK DIALOGEX 50 , 50 , 185 , 142
123 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
124 CAPTION " 复选显示位图选择 "
125 FONT 8 , " MS Shell Dlg " , 400 , 0 , 0x1
126 BEGIN
127 DEFPUSHBUTTON " 确定 " ,IDOK, 128 , 15 , 50 , 14
128 PUSHBUTTON " 取消 " ,IDCANCEL, 128 , 44 , 50 , 14
129 CONTROL " 复选位图 1 " ,IDC_CHECK1, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 26 , 54 , 10
130 CONTROL " 复选位图 2 " ,IDC_CHECK2, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 46 , 54 , 10
131 CONTROL " 复选位图 3 " ,IDC_CHECK3, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 66 , 54 , 10
132 CONTROL " 复选位图 4 " ,IDC_CHECK4, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 86 , 54 , 10
133 CONTROL " 复选位图 5 " ,IDC_CHECK5, " Button " ,BS_AUTOCHECKBOX | WS_TABSTOP, 31 , 106 , 54 , 10
134 END
135
136 IDD_RADIO DIALOGEX 50 , 50 , 185 , 142
137 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
138 CAPTION " 单选显示位图选择 "
139 FONT 8 , " MS Shell Dlg " , 400 , 0 , 0x1
140 BEGIN
141 DEFPUSHBUTTON " 确定 " ,IDOK, 128 , 15 , 50 , 14
142 PUSHBUTTON " 取消 " ,IDCANCEL, 128 , 44 , 50 , 14
143 CONTROL " 单选位图 1 " ,IDC_RADIO1, " Button " ,BS_AUTORADIOBUTTON, 31 , 26 , 54 , 10
144 CONTROL " 单选位图 2 " ,IDC_RADIO2, " Button " ,BS_AUTORADIOBUTTON, 31 , 46 , 54 , 10
145 CONTROL " 单选位图 3 " ,IDC_RADIO3, " Button " ,BS_AUTORADIOBUTTON, 31 , 66 , 54 , 10
146 CONTROL " 单选位图 4 " ,IDC_RADIO4, " Button " ,BS_AUTORADIOBUTTON, 31 , 86 , 54 , 10
147 CONTROL " 单选位图 5 " ,IDC_RADIO5, " Button " ,BS_AUTORADIOBUTTON, 31 , 106 , 54 , 10
148 END
149
150
151 /**/ /////////////////////////////////////////////////////////////////////////////
152 //
153 // DESIGNINFO
154 //
155
156 #ifdef APSTUDIO_INVOKED
157 GUIDELINES DESIGNINFO
158 BEGIN
159 IDD_CHECK, DIALOG
160 BEGIN
161 LEFTMARGIN, 7
162 RIGHTMARGIN, 178
163 TOPMARGIN, 7
164 BOTTOMMARGIN, 135
165 END
166
167 IDD_RADIO, DIALOG
168 BEGIN
169 LEFTMARGIN, 7
170 RIGHTMARGIN, 178
171 TOPMARGIN, 7
172 BOTTOMMARGIN, 135
173 END
174 END
175 #endif // APSTUDIO_INVOKED
176
177
178 /**/ /////////////////////////////////////////////////////////////////////////////
179 //
180 // Bitmap
181 //
182
183 IDB_A BITMAP " bmpA.bmp "
184 IDB_B BITMAP " bmpB.bmp "
185 IDB_C BITMAP " bmpC.bmp "
186 IDB_D BITMAP " bmpD.bmp "
187 IDB_E BITMAP " bmpE.bmp "
188
189 /**/ /////////////////////////////////////////////////////////////////////////////
190 //
191 // String Table
192 //
193
194 STRINGTABLE
195 BEGIN
196 IDS_APPNAME_CH " 第三次作业 "
197 IDS_APPNAME_EN " My Work 3 "
198 IDS_WNDCLASSNAME " WinZJ "
199 IDS_CURSOR_PREFIX_CH " 当前使用的光标是: "
200 IDS_CURSOR_PREFIX_EN " The current cursor is : "
201 IDS_CURSOR_ARROW " IDC_ARROW "
202 END
203
204 STRINGTABLE
205 BEGIN
206 IDS_CURSOR_WAIT " IDC_WAIT "
207 IDS_CURSOR_USER_CH " 我画的光标 "
208 IDS_CURSOR_USER_EN " MY CURSOR "
209 END
210
211 #endif // Chinese (Simplified, PRC) resources
212 /**/ /////////////////////////////////////////////////////////////////////////////
213
214
215/////////////////////////////////////////////////////////////////////////////
216 // English resources
217
218 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
219 LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
220
221 /**/ /////////////////////////////////////////////////////////////////////////////
222 //
223 // Menu
224 //
225
226 IDM_WINZJ_EN MENU
227 BEGIN
228 POPUP " &File "
229 BEGIN
230 MENUITEM " E&xit " , IDM_EXIT
231 END
232 POPUP " &OpenDialog "
233 BEGIN
234 MENUITEM " Open &Modal Dialog\tCtrl+A " , IDM_MODAL
235 MENUITEM " Open Modal&Less Dialog\tCtrl+B " , IDM_MODALLESS
236 MENUITEM " Open &File Dialog\tCtrl+C " , IDM_FILE
237 END
238 POPUP " &Cursor "
239 BEGIN
240 MENUITEM " Cursor&1(ARROW)\tCtrl+1 " , IDM_ARROW
241 MENUITEM " Cursor&2(WAIT)\tCtrl+2 " , IDM_WAIT
242 MENUITEM " Cursor&3(User)\tCtrl+3 " , IDM_USER
243 END
244 POPUP " &Language "
245 BEGIN
246 MENUITEM " 中文(&C)\tCtrl+Shift+C " , IDM_CHINESE
247 MENUITEM " &English\tCtrl+Shift+D " , IDM_ENGLISH
248 END
249 POPUP " &About "
250 BEGIN
251 MENUITEM " Program &Information\tF1 " , IDM_INFO
252 END
253 END
254
255 #endif // English resources
256 /**/ /////////////////////////////////////////////////////////////////////////////
257
258
259
260 #ifndef APSTUDIO_INVOKED
261 /**/ /////////////////////////////////////////////////////////////////////////////
262 //
263 // Generated from the TEXTINCLUDE 3 resource.
264 //
265
266
267 /**/ /////////////////////////////////////////////////////////////////////////////
268 #endif // not APSTUDIO_INVOKED
269
270
WinZJ.cpp
1
//
资源就不释放了,系统自己回收。
2
3 #include < Windows.h >
4 #include < string .h >
5 #include " resource.h "
6
7
8 #define STR_BUF_MAX 1024
9
10
11 BOOL bCheck[ 5 ] = { 0 } ;
12 TCHAR szWndClassName[ STR_BUF_MAX ];
13 HWND hDlgLess = NULL;
14 INT iRadioSelector = 0 ;
15
16
17 LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
18 INT_PTR CALLBACK DlgProc( HWND, UINT, WPARAM, LPARAM );
19 BOOL CALLBACK DlgLessProc( HWND, UINT, WPARAM, LPARAM );
20
21
22 int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) {
23 LoadString( hInst, IDS_WNDCLASSNAME, szWndClassName, STR_BUF_MAX );
24
25 WNDCLASSEX wc;
26 wc.cbClsExtra = 0;
27 wc.cbSize = sizeof(wc);
28 wc.cbWndExtra = 0;
29 wc.hbrBackground = (HBRUSH)::GetStockObject( WHITE_BRUSH );
30 wc.hCursor = NULL;
31 wc.hIcon = ::LoadIcon( hInst, MAKEINTRESOURCE(IDI_WINZJ) );
32 wc.hIconSm = ::LoadIcon( hInst, MAKEINTRESOURCE(IDI_WINZJ) );
33 wc.hInstance = hInst;
34 wc.lpfnWndProc = WndProc;
35 wc.lpszClassName = szWndClassName;
36 wc.lpszMenuName = NULL;
37 wc.style = CS_HREDRAW | CS_VREDRAW;
38
39 ::RegisterClassEx( &wc );
40
41 HWND hWnd = ::CreateWindowEx( 0, szWndClassName, TEXT(""),
42 WS_OVERLAPPEDWINDOW,
43 100, 100, 800, 600,
44 NULL, NULL, wc.hInstance, NULL );
45
46 ::ShowWindow( hWnd,nCmdShow );
47 ::UpdateWindow( hWnd );
48
49 HACCEL hAccel = ::LoadAccelerators( hInst, MAKEINTRESOURCE(IDA_WINZJ) );
50 MSG msg;
51 while ( ::GetMessage( &msg, NULL, 0, 0 ) ) {
52 if ( (::IsWindow(hDlgLess)) && (::IsDialogMessage(hDlgLess,&msg)) ) {
53 continue;
54 }
55 if ( ! ::TranslateAccelerator( hWnd, hAccel, &msg ) ) {
56 ::TranslateMessage( &msg );
57 ::DispatchMessage( &msg );
58 }
59 }
60 return msg.wParam;
61}
62
63
64 LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
65 HDC hdc, hdcMem;
66 PAINTSTRUCT ps;
67 HMENU hMenu;
68 RECT rt;
69 POINT pt;
70 int i;
71
72 OPENFILENAME ofn;
73 TCHAR szPath[ STR_BUF_MAX ], szFile[ STR_BUF_MAX ];
74
75 HBITMAP hbmpOld;
76
77 static HINSTANCE hInst;
78 static INT iLangSelector; // Base--Chinese, 0--Chinese, 1--English
79 static HCURSOR hCursor[ 3 ];
80 static INT iCursorSelector; // Base--Arrow, 0--Arrow, 1-Wait, 2--User
81 static TCHAR szText[ STR_BUF_MAX ];
82 static TCHAR szCursor[3][ STR_BUF_MAX ];
83 static HBITMAP hBmp[ 5 ];
84
85 switch ( uMsg ) {
86 case WM_CREATE :
87 hInst = ((LPCREATESTRUCT)lParam)->hInstance;
88
89 hCursor[ 0 ] = ::LoadCursor( NULL, IDC_ARROW );
90 hCursor[ 1 ] = ::LoadCursor( NULL, IDC_WAIT );
91 hCursor[ 2 ] = ::LoadCursor( hInst, MAKEINTRESOURCE(IDC_WINZJ) );
92
93 for ( i = IDB_A; i <= IDB_E; ++i ) {
94 hBmp[ i-IDB_A ] = ::LoadBitmap( hInst, MAKEINTRESOURCE(i) );
95 }
96
97 ::LoadString( hInst, IDS_CURSOR_ARROW, szCursor[ 0 ], STR_BUF_MAX );
98 ::LoadString( hInst, IDS_CURSOR_WAIT, szCursor[ 1 ], STR_BUF_MAX );
99
100 iCursorSelector = 0; // arrow
101 ::SendMessage( hWnd, WM_COMMAND, IDM_CHINESE, 0 );
102 return 0;
103
104 case WM_PAINT :
105 hdc = ::BeginPaint( hWnd, &ps );
106
107 ::LoadString( hInst, IDS_CURSOR_PREFIX_CH+iLangSelector, szText, STR_BUF_MAX );
108 lstrcat( szText, szCursor[iCursorSelector] );
109 ::TextOut( hdc, 50, 10, szText, lstrlen(szText) );
110
111 hdcMem = ::CreateCompatibleDC( hdc );
112
113 for ( i = 0; i < 5; ++i ) {
114 if ( bCheck[ i ] ) {
115 hbmpOld = (HBITMAP)::SelectObject( hdcMem, hBmp[ i ] );
116 ::BitBlt( hdc, 50, i*110+50, 130, 110,
117 hdcMem, 0, 0, SRCCOPY );
118 ::SelectObject( hdcMem, hbmpOld );
119 }
120 }
121 hbmpOld = (HBITMAP)::SelectObject( hdcMem, hBmp[ iRadioSelector ] );
122 ::BitBlt( hdc, 200, 100, 130, 110,
123 hdcMem, 0, 0, SRCCOPY );
124 ::SelectObject( hdcMem, hbmpOld );
125
126 ::DeleteDC( hdcMem );
127
128 ::EndPaint( hWnd, &ps );
129 return 0;
130
131 case WM_DESTROY :
132 ::PostQuitMessage( 0 );
133 return 0;
134
135 case WM_SETCURSOR :
136 ::GetClientRect( hWnd, &rt );
137 ::GetCursorPos( &pt );
138 ::ScreenToClient( hWnd, &pt );
139 if ( (rt.left<=pt.x) && (pt.x<rt.right) && (rt.top<=pt.y) && (pt.y<rt.bottom) ) {
140 ::SetCursor( hCursor[ iCursorSelector ] );
141 return 0;
142 }
143 break;
144
145 case WM_COMMAND :
146 hMenu = ::GetMenu( hWnd );
147 switch ( LOWORD(wParam) ) {
148 case IDM_EXIT :
149 ::DestroyWindow( hWnd );
150 return 0;
151
152 case IDM_MODAL :
153 if ( IDOK == ::DialogBox( hInst, MAKEINTRESOURCE(IDD_CHECK), hWnd, DlgProc ) ) {
154 ::InvalidateRect( hWnd, NULL, TRUE );
155 }
156 return 0;
157 case IDM_MODALLESS :
158 if ( ! ::IsWindow( hDlgLess ) ) {
159 hDlgLess = ::CreateDialog( hInst, MAKEINTRESOURCE(IDD_RADIO), hWnd, DlgLessProc );
160 ::ShowWindow( hDlgLess, SW_SHOW );
161 }
162 return 0;
163 case IDM_FILE :
164 memset( &ofn, 0, sizeof(ofn) );
165 ofn.lStructSize = sizeof(ofn);
166 ofn.hInstance = hInst;
167 ofn.hwndOwner = hWnd;
168 ofn.lpstrFilter = TEXT("All Files(*.*)\0*.*\0Text Files(*.txt)\0*.txt\0C++ Files(*.cpp)\0*.cpp\0\0");
169 ofn.lpstrTitle = TEXT("打开");
170 lstrcpy( szFile, TEXT("") );
171 ofn.lpstrFile = szFile;
172 ofn.nMaxFile = sizeof(szFile) / sizeof(TCHAR);
173 ::GetCurrentDirectory( STR_BUF_MAX, szPath );
174 ofn.lpstrInitialDir = szPath;
175 ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST;
176 if ( ::GetOpenFileName( &ofn ) ) {
177 ::MessageBox( hWnd, szFile, TEXT("文件名"), MB_OK );
178 }
179 return 0;
180
181 case IDM_ARROW :
182 case IDM_WAIT :
183 case IDM_USER :
184 iCursorSelector = (int)(LOWORD(wParam)) - (int)(IDM_ARROW);
185 ::SetCursor( hCursor[ iCursorSelector ] );
186 ::CheckMenuRadioItem( hMenu, IDM_ARROW, IDM_USER, IDM_ARROW+iCursorSelector, MF_BYCOMMAND );
187 ::InvalidateRect( hWnd, NULL, TRUE );
188 return 0;
189
190 case IDM_CHINESE :
191 case IDM_ENGLISH :
192 iLangSelector = (int)(LOWORD(wParam)) - (int)(IDM_CHINESE);
193 hMenu = ::LoadMenu( hInst, MAKEINTRESOURCE(IDM_WINZJ_CH+iLangSelector) );
194 ::SetMenu( hWnd, hMenu );
195 ::CheckMenuRadioItem( hMenu, IDM_CHINESE, IDM_ENGLISH, IDM_CHINESE+iLangSelector, MF_BYCOMMAND );
196 ::LoadString( hInst, IDS_CURSOR_USER_CH+iLangSelector, szCursor[ 2 ], STR_BUF_MAX );
197 ::LoadString( hInst, IDS_APPNAME_CH+iLangSelector, szText, STR_BUF_MAX );
198 ::SetWindowText( hWnd, szText );
199 ::SendMessage( hWnd, WM_COMMAND, IDM_ARROW+iCursorSelector, 0 );
200 ::InvalidateRect( hWnd, NULL, TRUE );
201 return 0;
202
203 case IDM_INFO :
204 ::MessageBox( hWnd, TEXT("第三次上机练习\n对话框,光标,字符串,位图\n\n学号:***********\n姓名:****\n"), TEXT("Lab3 ZJ"), MB_OK|MB_ICONINFORMATION );
205 return 0;
206 }
207 break;
208 }
209 return ::DefWindowProc( hWnd, uMsg, wParam, lParam );
210}
211
212
213 INT_PTR CALLBACK DlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
214 int i;
215 switch ( uMsg ) {
216 case WM_INITDIALOG :
217 for ( i = IDC_CHECK1; i <= IDC_CHECK5; ++i ) {
218 ::CheckDlgButton( hDlg, i, bCheck[ i-IDC_CHECK1 ] );
219 }
220 return TRUE;
221 case WM_COMMAND :
222 switch ( LOWORD(wParam) ) {
223 case IDOK :
224 for ( i = IDC_CHECK1; i <= IDC_CHECK5; ++i ) {
225 bCheck[ i-IDC_CHECK1 ] = ::IsDlgButtonChecked( hDlg, i );
226 }
227 case IDCANCEL :
228 ::EndDialog( hDlg, LOWORD(wParam) );
229 return TRUE;
230 }
231 break;
232 }
233 return FALSE;
234}
235
236
237 BOOL CALLBACK DlgLessProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
238 switch ( uMsg ) {
239 case WM_INITDIALOG :
240 ::CheckRadioButton( hDlg, IDC_RADIO1, IDC_RADIO5, IDC_RADIO1+iRadioSelector );
241 return TRUE;
242 case WM_COMMAND :
243 switch ( LOWORD(wParam) ) {
244 case IDOK :
245 iRadioSelector = 0;
246 while ( ! ::IsDlgButtonChecked( hDlg, IDC_RADIO1+iRadioSelector ) ) {
247 ++iRadioSelector;
248 }
249 ::InvalidateRect( ::GetParent(hDlg), NULL, TRUE );
250 return TRUE;
251 case IDCANCEL :
252 ::DestroyWindow( hDlgLess );
253 hDlgLess = NULL;
254 return TRUE;
255 }
256 break;
257 }
258 return FALSE;
259}
260
2
3 #include < Windows.h >
4 #include < string .h >
5 #include " resource.h "
6
7
8 #define STR_BUF_MAX 1024
9
10
11 BOOL bCheck[ 5 ] = { 0 } ;
12 TCHAR szWndClassName[ STR_BUF_MAX ];
13 HWND hDlgLess = NULL;
14 INT iRadioSelector = 0 ;
15
16
17 LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
18 INT_PTR CALLBACK DlgProc( HWND, UINT, WPARAM, LPARAM );
19 BOOL CALLBACK DlgLessProc( HWND, UINT, WPARAM, LPARAM );
20
21
22 int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) {
23 LoadString( hInst, IDS_WNDCLASSNAME, szWndClassName, STR_BUF_MAX );
24
25 WNDCLASSEX wc;
26 wc.cbClsExtra = 0;
27 wc.cbSize = sizeof(wc);
28 wc.cbWndExtra = 0;
29 wc.hbrBackground = (HBRUSH)::GetStockObject( WHITE_BRUSH );
30 wc.hCursor = NULL;
31 wc.hIcon = ::LoadIcon( hInst, MAKEINTRESOURCE(IDI_WINZJ) );
32 wc.hIconSm = ::LoadIcon( hInst, MAKEINTRESOURCE(IDI_WINZJ) );
33 wc.hInstance = hInst;
34 wc.lpfnWndProc = WndProc;
35 wc.lpszClassName = szWndClassName;
36 wc.lpszMenuName = NULL;
37 wc.style = CS_HREDRAW | CS_VREDRAW;
38
39 ::RegisterClassEx( &wc );
40
41 HWND hWnd = ::CreateWindowEx( 0, szWndClassName, TEXT(""),
42 WS_OVERLAPPEDWINDOW,
43 100, 100, 800, 600,
44 NULL, NULL, wc.hInstance, NULL );
45
46 ::ShowWindow( hWnd,nCmdShow );
47 ::UpdateWindow( hWnd );
48
49 HACCEL hAccel = ::LoadAccelerators( hInst, MAKEINTRESOURCE(IDA_WINZJ) );
50 MSG msg;
51 while ( ::GetMessage( &msg, NULL, 0, 0 ) ) {
52 if ( (::IsWindow(hDlgLess)) && (::IsDialogMessage(hDlgLess,&msg)) ) {
53 continue;
54 }
55 if ( ! ::TranslateAccelerator( hWnd, hAccel, &msg ) ) {
56 ::TranslateMessage( &msg );
57 ::DispatchMessage( &msg );
58 }
59 }
60 return msg.wParam;
61}
62
63
64 LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
65 HDC hdc, hdcMem;
66 PAINTSTRUCT ps;
67 HMENU hMenu;
68 RECT rt;
69 POINT pt;
70 int i;
71
72 OPENFILENAME ofn;
73 TCHAR szPath[ STR_BUF_MAX ], szFile[ STR_BUF_MAX ];
74
75 HBITMAP hbmpOld;
76
77 static HINSTANCE hInst;
78 static INT iLangSelector; // Base--Chinese, 0--Chinese, 1--English
79 static HCURSOR hCursor[ 3 ];
80 static INT iCursorSelector; // Base--Arrow, 0--Arrow, 1-Wait, 2--User
81 static TCHAR szText[ STR_BUF_MAX ];
82 static TCHAR szCursor[3][ STR_BUF_MAX ];
83 static HBITMAP hBmp[ 5 ];
84
85 switch ( uMsg ) {
86 case WM_CREATE :
87 hInst = ((LPCREATESTRUCT)lParam)->hInstance;
88
89 hCursor[ 0 ] = ::LoadCursor( NULL, IDC_ARROW );
90 hCursor[ 1 ] = ::LoadCursor( NULL, IDC_WAIT );
91 hCursor[ 2 ] = ::LoadCursor( hInst, MAKEINTRESOURCE(IDC_WINZJ) );
92
93 for ( i = IDB_A; i <= IDB_E; ++i ) {
94 hBmp[ i-IDB_A ] = ::LoadBitmap( hInst, MAKEINTRESOURCE(i) );
95 }
96
97 ::LoadString( hInst, IDS_CURSOR_ARROW, szCursor[ 0 ], STR_BUF_MAX );
98 ::LoadString( hInst, IDS_CURSOR_WAIT, szCursor[ 1 ], STR_BUF_MAX );
99
100 iCursorSelector = 0; // arrow
101 ::SendMessage( hWnd, WM_COMMAND, IDM_CHINESE, 0 );
102 return 0;
103
104 case WM_PAINT :
105 hdc = ::BeginPaint( hWnd, &ps );
106
107 ::LoadString( hInst, IDS_CURSOR_PREFIX_CH+iLangSelector, szText, STR_BUF_MAX );
108 lstrcat( szText, szCursor[iCursorSelector] );
109 ::TextOut( hdc, 50, 10, szText, lstrlen(szText) );
110
111 hdcMem = ::CreateCompatibleDC( hdc );
112
113 for ( i = 0; i < 5; ++i ) {
114 if ( bCheck[ i ] ) {
115 hbmpOld = (HBITMAP)::SelectObject( hdcMem, hBmp[ i ] );
116 ::BitBlt( hdc, 50, i*110+50, 130, 110,
117 hdcMem, 0, 0, SRCCOPY );
118 ::SelectObject( hdcMem, hbmpOld );
119 }
120 }
121 hbmpOld = (HBITMAP)::SelectObject( hdcMem, hBmp[ iRadioSelector ] );
122 ::BitBlt( hdc, 200, 100, 130, 110,
123 hdcMem, 0, 0, SRCCOPY );
124 ::SelectObject( hdcMem, hbmpOld );
125
126 ::DeleteDC( hdcMem );
127
128 ::EndPaint( hWnd, &ps );
129 return 0;
130
131 case WM_DESTROY :
132 ::PostQuitMessage( 0 );
133 return 0;
134
135 case WM_SETCURSOR :
136 ::GetClientRect( hWnd, &rt );
137 ::GetCursorPos( &pt );
138 ::ScreenToClient( hWnd, &pt );
139 if ( (rt.left<=pt.x) && (pt.x<rt.right) && (rt.top<=pt.y) && (pt.y<rt.bottom) ) {
140 ::SetCursor( hCursor[ iCursorSelector ] );
141 return 0;
142 }
143 break;
144
145 case WM_COMMAND :
146 hMenu = ::GetMenu( hWnd );
147 switch ( LOWORD(wParam) ) {
148 case IDM_EXIT :
149 ::DestroyWindow( hWnd );
150 return 0;
151
152 case IDM_MODAL :
153 if ( IDOK == ::DialogBox( hInst, MAKEINTRESOURCE(IDD_CHECK), hWnd, DlgProc ) ) {
154 ::InvalidateRect( hWnd, NULL, TRUE );
155 }
156 return 0;
157 case IDM_MODALLESS :
158 if ( ! ::IsWindow( hDlgLess ) ) {
159 hDlgLess = ::CreateDialog( hInst, MAKEINTRESOURCE(IDD_RADIO), hWnd, DlgLessProc );
160 ::ShowWindow( hDlgLess, SW_SHOW );
161 }
162 return 0;
163 case IDM_FILE :
164 memset( &ofn, 0, sizeof(ofn) );
165 ofn.lStructSize = sizeof(ofn);
166 ofn.hInstance = hInst;
167 ofn.hwndOwner = hWnd;
168 ofn.lpstrFilter = TEXT("All Files(*.*)\0*.*\0Text Files(*.txt)\0*.txt\0C++ Files(*.cpp)\0*.cpp\0\0");
169 ofn.lpstrTitle = TEXT("打开");
170 lstrcpy( szFile, TEXT("") );
171 ofn.lpstrFile = szFile;
172 ofn.nMaxFile = sizeof(szFile) / sizeof(TCHAR);
173 ::GetCurrentDirectory( STR_BUF_MAX, szPath );
174 ofn.lpstrInitialDir = szPath;
175 ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST;
176 if ( ::GetOpenFileName( &ofn ) ) {
177 ::MessageBox( hWnd, szFile, TEXT("文件名"), MB_OK );
178 }
179 return 0;
180
181 case IDM_ARROW :
182 case IDM_WAIT :
183 case IDM_USER :
184 iCursorSelector = (int)(LOWORD(wParam)) - (int)(IDM_ARROW);
185 ::SetCursor( hCursor[ iCursorSelector ] );
186 ::CheckMenuRadioItem( hMenu, IDM_ARROW, IDM_USER, IDM_ARROW+iCursorSelector, MF_BYCOMMAND );
187 ::InvalidateRect( hWnd, NULL, TRUE );
188 return 0;
189
190 case IDM_CHINESE :
191 case IDM_ENGLISH :
192 iLangSelector = (int)(LOWORD(wParam)) - (int)(IDM_CHINESE);
193 hMenu = ::LoadMenu( hInst, MAKEINTRESOURCE(IDM_WINZJ_CH+iLangSelector) );
194 ::SetMenu( hWnd, hMenu );
195 ::CheckMenuRadioItem( hMenu, IDM_CHINESE, IDM_ENGLISH, IDM_CHINESE+iLangSelector, MF_BYCOMMAND );
196 ::LoadString( hInst, IDS_CURSOR_USER_CH+iLangSelector, szCursor[ 2 ], STR_BUF_MAX );
197 ::LoadString( hInst, IDS_APPNAME_CH+iLangSelector, szText, STR_BUF_MAX );
198 ::SetWindowText( hWnd, szText );
199 ::SendMessage( hWnd, WM_COMMAND, IDM_ARROW+iCursorSelector, 0 );
200 ::InvalidateRect( hWnd, NULL, TRUE );
201 return 0;
202
203 case IDM_INFO :
204 ::MessageBox( hWnd, TEXT("第三次上机练习\n对话框,光标,字符串,位图\n\n学号:***********\n姓名:****\n"), TEXT("Lab3 ZJ"), MB_OK|MB_ICONINFORMATION );
205 return 0;
206 }
207 break;
208 }
209 return ::DefWindowProc( hWnd, uMsg, wParam, lParam );
210}
211
212
213 INT_PTR CALLBACK DlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
214 int i;
215 switch ( uMsg ) {
216 case WM_INITDIALOG :
217 for ( i = IDC_CHECK1; i <= IDC_CHECK5; ++i ) {
218 ::CheckDlgButton( hDlg, i, bCheck[ i-IDC_CHECK1 ] );
219 }
220 return TRUE;
221 case WM_COMMAND :
222 switch ( LOWORD(wParam) ) {
223 case IDOK :
224 for ( i = IDC_CHECK1; i <= IDC_CHECK5; ++i ) {
225 bCheck[ i-IDC_CHECK1 ] = ::IsDlgButtonChecked( hDlg, i );
226 }
227 case IDCANCEL :
228 ::EndDialog( hDlg, LOWORD(wParam) );
229 return TRUE;
230 }
231 break;
232 }
233 return FALSE;
234}
235
236
237 BOOL CALLBACK DlgLessProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
238 switch ( uMsg ) {
239 case WM_INITDIALOG :
240 ::CheckRadioButton( hDlg, IDC_RADIO1, IDC_RADIO5, IDC_RADIO1+iRadioSelector );
241 return TRUE;
242 case WM_COMMAND :
243 switch ( LOWORD(wParam) ) {
244 case IDOK :
245 iRadioSelector = 0;
246 while ( ! ::IsDlgButtonChecked( hDlg, IDC_RADIO1+iRadioSelector ) ) {
247 ++iRadioSelector;
248 }
249 ::InvalidateRect( ::GetParent(hDlg), NULL, TRUE );
250 return TRUE;
251 case IDCANCEL :
252 ::DestroyWindow( hDlgLess );
253 hDlgLess = NULL;
254 return TRUE;
255 }
256 break;
257 }
258 return FALSE;
259}
260