|
|
1.1 root 1: {\rtf1\ansi \deff0\deflang1024{\fonttbl{\f0\froman Times New Roman;}{\f1\froman Symbol;}{\f2\fswiss Arial;}{\f3\fswiss Helvetica;}{\f4\fmodern Courier;}{\f5\fswiss Helv;}{\f6\froman Ariel;}{\f7\fmodern Courier New;}
2: {\f8\fswiss Univers (WN);}{\f9\froman CG Times (WN);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;
3: \red0\green0\blue127;\red0\green127\blue127;\red0\green127\blue0;\red127\green0\blue127;\red127\green0\blue0;\red127\green127\blue0;\red127\green127\blue127;\red192\green192\blue192;}{\stylesheet{\s244\li120\sb80\sl-240 \f3\fs18\up6\lang1033
4: \sbasedon0\snext0 footnote reference;}{\s245\li120\sb80\sl-240 \f3\fs20\lang1033 \sbasedon0\snext0 footnote text;}{\s252\li120\sb120\sa60\sl-240 \f3\fs20\lang1033 \snext0 heading 3;}{\s253\li120\sb120\sa60\sl-240 \b\f3\fs20\lang1033 \snext0 heading 2;}{
5: \s254\li120\sb280\sa120\sl-320 \b\f3\lang1033 \snext10 heading 1;}{\s255\li360\sb80\sl-240 \f3\fs20\lang1033 \snext0 Normal Indent;}{\li120\sb80\sl-240 \f3\fs20\lang1033 \snext0 Normal;}{\s2\fi-240\li600\sb60\sl-240 \f3\fs20\lang1033 \snext2 Jli;}{
6: \s3\li120\sb60\sl-240\keep\tx520\tx920\tx1320\tx1720\tx2120 \f4\fs16\lang1033 \snext3 Ex;}{\s4\li120\sb160\sl-240 \f3\fs20\lang1033 \snext13 Sa1;}{\s5\fi-240\li360\sl-240\tx360 \f3\fs20\lang1033 \snext6 Lb1;}{\s6\fi-240\li360\sb60\sl-240\tx360
7: \f3\fs20\lang1033 \snext6 Lb2;}{\s7\li360\sb60\sl-240 \f3\fs20\lang1033 \snext6 Lp1;}{\s8\fi-1800\li1920\sb120\sa40\sl-240\brdrb\brdrs\brdrw15\brsp20 \brdrbtw\brdrs\brdrw15\brsp20 \tx1920 \b\f3\fs20\lang1033 \snext9 Th;}{
8: \s9\fi-1800\li1920\sb60\sl-240\tx1920 \f3\fs20\lang1033 \snext9 Tp;}{\s10\li120\sl-240 \f3\fs20\lang1033 \snext0 Normal 2;}{\s11\li120\sb120\sa120 \f3\fs20\lang1033 \snext0 bitmap;}{\s12\li120\sb120\sl-240 \f3\fs20\lang1033 \snext13 Sa2;}{
9: \s13\fi-240\li360\sb60\sl-240 \f3\fs20\lang1033 \snext13 Jl;}{\s14\li120\sa60 \f8\fs20\lang1033 \snext14 *body;}{\s15\li120\sa60 \b\f8\fs20\lang1033 \snext15 *heading;}{\s16\li120\sa60\sl-240 \f8\fs20\lang1033 \sbasedon14\snext16 para;}{
10: \s17\fi-280\li400\sa60 \f8\fs20\lang1033 \sbasedon14\snext17 jump;}{\s18\fi-280\li400\sa60\tx400 \f8\fs20\lang1033 \sbasedon14\snext18 list bullet;}{\s19\fi-280\li600\sa60 \f8\fs20\lang1033 \sbasedon14\snext19 jump indent;}{\s20\li120\sa60\sl-40\brdrb
11: \brdrs\brdrw15\brsp20 \brdrbtw\brdrs\brdrw15\brsp20 \f8\fs20\lang1033 \sbasedon14\snext20 table rule;}{\s21\fi-280\li400\sa60\tqr\tx280\tx400 \f8\fs20\lang1033 \sbasedon14\snext21 list number;}{\s22\li120\sb100\sa60 \b\f8\fs20\lang1033
12: \sbasedon15\snext17 see also;}{\s23\li400\sa60 \f8\fs20\lang1033 \sbasedon14\snext23 para indent;}{\s24\fi-1800\li1920\tx1920 \b\f8\fs20\lang1033 \sbasedon15\snext20 table head;}{\s25\fi-1800\li1920\sa60\tx1920 \f8\fs20\lang1033
13: \sbasedon14\snext25 table text;}{\s26\li120\sb120\sa60 \f8\fs20\lang1033 \sbasedon14\snext19 see also 2;}{\s27\li120\sa60\keep\tx520\tx920\tx1320\tx1720\tx2120 \f4\fs20\lang1033 \sbasedon14\snext27 code;}{\s28\sl-120 \f9\fs20\lang1033 \snext16 *spacing;}{
14: \s29\sl-120 \f9\fs20\lang1033 \sbasedon28\snext29 s6;}{\s30\qj\li360 \lang1033 \sbasedon0\snext30 Help Text;}}{\info{\author TRIO}{\creatim\yr1992\mo6\dy24\hr16\min51}{\version1}{\edmins256}{\nofpages14}{\nofwords2490}{\nofchars14208}{\vern16504}}
15: \paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\gutter0 {\*\template C:\\WINAPPS\\WINWORD\\WHAT31.DOT}\sectd \linex0 \pard\plain \keepn \f3\fs20\lang1033 {\fs16\up6 ${\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {
16: \fs16\up6 $} Contents}} {\fs16\up6 #{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs16\up6 #} Contents}} {\fs16\up6 K{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs16\up6 K} Contents}} \{bmc generic.bmp\} {
17: \b\f2\fs32 Contents for Generic Application Help}{\plain \b\f2\lang1033
18: \par }\pard \li120 {\f2
19: \par }{\f2
20: The Windows SDK Generic Application Example is a sample application that you can use to get an idea of how to perform some of the simple functionality that all Applications written for Microsoft Windows should implement. You can use this application as ei
21: }{\f2 ther a starting point from which to build your own applications, or for quickly testing out functionality of an interesting Windows API.}{\f2
22: \par }{\f2
23: \par }{\f2 This application is source compatible for with Windows 3.1 and Windows NT.}{\f2
24: \par }{\f2
25: \par }{\f2 Code Fragments with explainations:}{\f2
26: \par }{\f2
27: \par }\pard \fi-1440\li2160\tx2160 {\f2\uldb Global Declarations}{\v\f2 Globals}{\f2
28: \par }{\f2\uldb WinMain}{\v\f2 WinMain}{\f2 \tab }{\f2 : Calls initialization function, processes message loop}{\f2
29: \par }{\f2\uldb InitApplication}{\v\f2 InitApplication}{\f2 \tab }{\f2 : Initializes window data and registers window}{\f2
30: \par }{\f2\uldb InitInstance}{\v\f2 InitInstance}{\f2 \tab }{\f2 : Saves instance handle and creates main window}{\f2
31: \par }{\f2\uldb WndProc}{\v\f2 WndProc}{\f2 \tab }{\f2 : Processes messages}{\f2
32: \par }{\f2\uldb CenterWindow}{\v\f2 CenterWindow}{\f2 \tab }{\f2 : Used to center the "About" box over application window}{\f2\uldb
33: \par }{\f2\uldb About}{\v\f2 About}{\f2 \tab }{\f2 : Processes messages for "About" dialog box}{\f2
34: \par }\pard \li115 {\f2
35: \par }{\f2
36: \par }\pard \li115\keepn {\f2 \page }{\fs18\up6 ${\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 $} Globals}}{\f2 }{\fs18\up6 #{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 #} Globals}}{\f2 }{
37: \fs18\up6 +{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 +} Globals}}{\f2 }{\fs18\up6 K{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 K} Globals}}{\f2 }{\plain \b\f2\lang1033 Global Declarations
38: }{\f2
39: \par }\pard \li120\sb80\sl-240 {\f7\fs18 #include <windows.h>}\tab {\i\cf2 // required for all Windows applications}
40: \par {\f7\fs18 #include "generic.h"}{\f7\fs18 \tab }{\i\fs18\cf2 // specific to this program}{\i\fs18\cf2
41: \par }{\f7\fs18
42: \par }{\f7\fs18 #if !defined (APIENTRY)}{\i\fs18\cf2 \tab }{\i\fs18\cf2 // Windows NT defines APIENTRY, but 3.x doesn't}{\f7\fs18
43: \par }{\f7\fs18 #define APIENTRY far pascal}{\f7\fs18
44: \par }{\f7\fs18 #endif}{\f7\fs18
45: \par }{\f7\fs18
46: \par }{\f7\fs18 #if defined(WIN32)}{\f7\fs18 \tab }{\i\fs18\cf2 // Windows NT uses a WNDPROC for dialogs, 3.x a FARPROC}{\f7\fs18
47: \par }{\f7\fs18 #define DLGPROC WNDPROC}{\f7\fs18
48: \par }{\f7\fs18 #else}{\f7\fs18
49: \par }{\f7\fs18 #define DLGPROC FARPROC}{\f7\fs18
50: \par }{\f7\fs18 #endif}{\f7\fs18
51: \par }{\f7\fs18
52: \par }{\f7\fs18 HANDLE hInst;}{\f7\fs18 \tab }{\i\fs18\cf2 // current instance}{\f7\fs18
53: \par }{\f7\fs18
54: \par }{\f7\fs18 char szAppName[] = "Generic";}{\f7\fs18 \tab }{\i\fs18\cf2 // The name of this application}{\f7\fs18
55: \par }{\f7\fs18 char szTitle[] = "Generic Sample Application";}{\f7\fs18 \tab }{\i\fs18\cf2 // The title bar text}{\i\fs18\cf2
56: \par }{\f7\fs18
57: \par }\pard \li115\keepn {\f7\fs18 \page }{\fs18\up6 ${\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 $} WinMain}}{\f7\fs18 }{\fs18\up6 #{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 #} WinMain}}{
58: \f7\fs18 }{\fs18\up6 +{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 +} WinMain}}{\f7\fs18 }{\fs18\up6 K{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 K} WinMain}}{\plain \b\f2\lang1033 }
59: {\plain \b\f2\lang1033 WinMain Function}{\plain \b\f2\lang1033
60: \par }\pard \fi-1320\li1440\sb80\sl-240\tx1440 {\b\f2 FUNCTION}{\f2 :}{\f2 \tab }{\f2 WinMain(HANDLE, HANDLE, LPSTR, int)}{\f2
61: \par }{\b\f2 PURPOSE}{\f2 :}{\f2 \tab }{\f2 Calls initialization function, processes message loop}{\f2
62: \par }{\b\f2 COMMENTS}{\f2 :}{\f2 \tab }{\f2
63: Windows recognizes this function by name as the initial entry point for the program. This function calls the application initialization routine, if no other instance of the program is running, and always calls the instance initialization routine. It the
64: }{\f2
65: n executes a message retrieval and dispatch loop that is the top-level control structure for the remainder of execution. The loop is terminated when a WM_QUIT message is received, at which time this function exits the application instance by returning th
66: }{\f2 e }{\f2 value passed by PostQuitMessage().}{\f2
67: \par }\pard \fi-1320\li1440\sb80\sl-240 {\f2
68: \par }\pard \li1440\sb80\sl-240 {\f2 If this function must abort before entering the message loop, it returns the conventional value NULL.}{\f2
69: \par }\pard \li120\sb80\sl-240 {\f2
70: \par }{\f7\fs18 int APIENTRY WinMain(}{\f7\fs18
71: \par }{\f7\fs18 HANDLE hInstance,}{\f7\fs18
72: \par }{\f7\fs18 HANDLE hPrevInstance,}{\f7\fs18
73: \par }{\f7\fs18 LPSTR lpCmdLine,}{\f7\fs18
74: \par }{\f7\fs18 int nCmdShow)}{\f7\fs18
75: \par }{\f7\fs18 \{}{\f7\fs18
76: \par }{\f7\fs18
77: \par }{\f7\fs18 MSG msg;}{\f7\fs18
78: \par }{\f7\fs18
79: \par }{\f7\fs18 if (!hPrevInstance)}{\f7\fs18 \tab }{\f7\fs18 \{}{\f7\fs18 \tab }{\i\fs18\cf2 // Other instances of app running?}{\f7\fs18
80: \par }{\f7\fs18 if (!InitApplication(hInstance)) }{\f7\fs18 \{}{\f7\fs18 \tab }{\i\fs18\cf2 // Initialize shared things}{\f7\fs18
81: \par }{\f7\fs18 return (FALSE);}{\f7\fs18 \tab }{\i\fs18\cf2 // Exits if unable to initialize}{\f7\fs18
82: \par }{\f7\fs18 }{\f7\fs18 \}}{\f7\fs18
83: \par }{\f7\fs18 }{\f7\fs18 \}}{\f7\fs18
84: \par }{\f7\fs18
85: \par }{\i\fs18\cf2 // Perform initializations that apply to a specific instance}{\i\fs18\cf2
86: \par }{\f7\fs18
87: \par }{\f7\fs18 if (!InitInstance(hInstance, nCmdShow)) }{\f7\fs18 \{}{\f7\fs18
88: \par }{\f7\fs18 return (FALSE);}{\f7\fs18
89: \par }{\f7\fs18 }{\f7\fs18 \}}{\f7\fs18
90: \par }{\f7\fs18
91: \par }{\i\fs18\cf2 // Acquire and dispatch messages until a WM_QUIT message is received.}{\i\fs18\cf2
92: \par }{\f7\fs18
93: \par }{\f7\fs18 while (GetMessage(&msg,}{\f7\fs18 \tab }{\i\fs18\cf2 // message structure}{\f7\fs18
94: \par }{\f7\fs18 NULL,}{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 \tab }{\i\fs18\cf2 // handle of window receiving the message}{\f7\fs18
95: \par }{\f7\fs18 NULL,}{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 \tab }{\i\fs18\cf2 // lowest message to examine}{\f7\fs18
96: \par }{\f7\fs18 NULL))}{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 \tab }{\i\fs18\cf2 // highest message to examine}{\f7\fs18
97: \par }{\f7\fs18 }{\f7\fs18 \{}{\f7\fs18
98: \par }{\f7\fs18 TranslateMessage(&msg);}{\f7\fs18 \tab }{\i\fs18\cf2 // Translates virtual key codes}{\f7\fs18
99: \par }{\f7\fs18 DispatchMessage(&msg);}{\f7\fs18 \tab }{\i\fs18\cf2 // Dispatches message to window}{\f7\fs18
100: \par }{\f7\fs18 }{\f7\fs18 \}}{\f7\fs18
101: \par }{\f7\fs18
102: \par }{\f7\fs18
103: \par }{\f7\fs18 return (msg.wParam);}{\f7\fs18 \tab }{\i\fs18\cf2 // Returns the value from PostQuitMessage}{\f7\fs18
104: \par }{\f7\fs18
105: \par }{\f7\fs18 lpCmdLine;}{\f7\fs18 \tab }{\i\fs18\cf2 // This will prevent 'unused formal parameter' warnings}{\f7\fs18
106: \par }\pard \li120 {\f7\fs18 \}}{\f7\fs18
107: \par }{\f7\fs18
108: \par }\pard \li115\keepn {\f7\fs18 \page }{\fs18\up6 ${\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 $} InitApplication}}{\f7\fs18 }{\fs18\up6 #{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 #}
109: InitApplication}}{\f7\fs18 }{\fs18\up6 +{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 +} InitApplication}}{\f7\fs18 }{\fs18\up6 K{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 K}
110: InitApplication}}{\fs18\up6 }{\plain \b\f2\lang1033 InitApplication Function}{\fs18\up6
111: \par }\pard \fi-1320\li1440\sb80\sl-240\tx1440 {\b\f2 FUNCTION}{\f2 :}{\f2 \tab }{\f2 InitApplication(HANDLE)}{\f2
112: \par }{\b\f2 PURPOSE}{\f2 :}{\f2 \tab }{\f2 Initializes window data and registers window class}{\f2
113: \par }{\b\f2 COMMENTS}{\f2 :}{\f2 \tab }{\f2 This function is called at initialization time only if no other instances of the application are running. This function performs initialization tasks that can be done once for any number of running instances.}{\f2
114:
115: \par }{\f2
116: \par }\pard \li1440\sb80\sl-240\tx1440 {\f2
117: In this case, we initialize a window class by filling out a data structure of type WNDCLASS and calling the Windows RegisterClass() function. Since all instances of this application use the same window class, we only need to do this when the first instan
118: }{\f2 ce is initialized.}{\f2
119: \par }\pard \li120\sb80\sl-240 {\f7\fs18
120: \par }{\f7\fs18 BOOL InitApplication(H}{\f7\fs18 ANDLE hInstance)}{\f7\fs18
121: \par }{\f7\fs18 \{}{\f7\fs18
122: \par }{\f7\fs18 WNDCLASS wc;}{\f7\fs18
123: \par }{\f7\fs18
124: \par }{\i\fs18\cf2 // Fill in window class structure with parameters that describe the main window.}{\i\fs18\cf2
125: \par }{\f7\fs18
126: \par }{\f7\fs18 wc.style = CS_HREDRAW | CS_VREDRAW;}{\f7\fs18 \tab }{\i\fs18\cf2 // Class style(s)}{\i\fs18\cf2
127: \par }{\f7\fs18 wc.lpfnWndProc = (WNDPROC)WndProc;}{\f7\fs18 \tab }{\i\fs18\cf2 // Window Procedure}{\i\fs18\cf2
128: \par }{\f7\fs18 wc.cbClsExtra = 0;}{\f7\fs18 \tab }{\i\fs18\cf2 // No per-class extra data.}{\i\fs18\cf2
129: \par }{\f7\fs18 wc.cbWndExtra = 0;}{\f7\fs18 \tab }{\i\fs18\cf2 // No per-window extra data.}{\i\fs18\cf2
130: \par }{\f7\fs18 wc.hInstance = hInstance;}{\f7\fs18 \tab }{\i\fs18\cf2 // Owner of this class}{\i\fs18\cf2
131: \par }{\f7\fs18 wc.hIcon = LoadIcon (hInstance, szAppName); }{\i\fs18\cf2 // Icon name from .RC}{\i\fs18\cf2
132: \par }{\f7\fs18 wc.hCursor = LoadCursor(NULL, IDC_ARROW);}{\i\fs18\cf2 // Cursor}{\i\fs18\cf2
133: \par }{\f7\fs18 wc.hbrBackground = COLOR_WINDOW+1;}{\f7\fs18 \tab }{\i\fs18\cf2 // Default color}{\i\fs18\cf2
134: \par }{\f7\fs18 wc.lpszMenuName = szAppName;}{\f7\fs18 \tab }{\i\fs18\cf2 // Menu name from .RC}{\i\fs18\cf2
135: \par }{\f7\fs18 wc.lpszClassName = szAppName;}{\f7\fs18 \tab }{\i\fs18\cf2 // Name to register as}{\i\fs18\cf2
136: \par }{\f7\fs18
137: \par }{\i\fs18\cf2 // Register the window class and return success/failure code.}{\i\fs18\cf2
138: \par }{\f7\fs18 return (RegisterClass(&wc));}{\f7\fs18
139: \par }\pard \li115 {\f7\fs18 \}}{\f7\fs18
140: \par }\pard \li115\keepn {\f7\fs18 \page }{\fs18\up6 ${\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 $} InitInstance}}{\f7\fs18 }{\fs18\up6 #{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 #}
141: InitInstance}}{\f7\fs18 }{\fs18\up6 +{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 +} InitInstance}}{\f7\fs18 }{\fs18\up6 K{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 K} InitInstance}}
142: {\plain \b\f2\lang1033 }{\plain \b\f2\lang1033 InitInstance Function}{\f7\fs18
143: \par }\pard \fi-1320\li1440\sb80\sl-240\tx1440 {\b\f2 FUNCTION}{\f2 :}{\f2 \tab }{\f2 InitInstance(HANDLE, int)}{\f2
144: \par }{\b\f2 PURPOSE}{\f2 :}{\f2 \tab }{\f2 Saves instance handle and creates main window}{\f2
145: \par }{\b\f2 COMMENTS}{\f2 :}{\f2 \tab }{\f2 This function is called at initialization time for every instance of this application. This function performs initialization tasks that cannot be shared by multiple instances.}{\f2
146: \par }{\f2
147: \par }\pard \li1440\sb80\sl-240\tx1440 {\f2 In this case, we save the instance handle in a static variable and create and display the main program window.}{\f2
148: \par }\pard \li120\sb80\sl-240 {\f7\fs18
149: \par }{\f7\fs18 BOOL InitInstance(}{\f7\fs18
150: \par }{\f7\fs18 HANDLE hInstance,}{\f7\fs18
151: \par }{\f7\fs18 int nCmdShow)}{\f7\fs18
152: \par }{\f7\fs18 \{}{\f7\fs18
153: \par }{\f7\fs18 HWND hWnd;}{\f7\fs18 \tab }{\i\fs18\cf2 // Main window handle.}{\i\fs18\cf2
154: \par }{\f7\fs18
155: \par }{\i\fs18\cf2 // Save the instance handle in static variable, which will be used in}{\i\fs18\cf2
156: \par }{\i\fs18\cf2 // many subsequence calls from this application to Windows.}{\i\fs18\cf2
157: \par }{\f7\fs18
158: \par }{\f7\fs18 hInst = hInstance;}{\f7\fs18 \tab }{\i\fs18\cf2 // Store instance handle in our global variable}{\i\fs18\cf2
159: \par }{\f7\fs18
160: \par }{\i\fs18\cf2 // Create a main window for this application instance.}{\i\fs18\cf2
161: \par }{\f7\fs18
162: \par }{\f7\fs18 hWnd = CreateWindow(}{\f7\fs18
163: \par }{\f7\fs18 szAppName,}{\f7\fs18 \tab }{\f7\fs18 \tab }{\i\fs18\cf2 // See RegisterClass() call.}{\i\fs18\cf2
164: \par }{\f7\fs18 szTitle, }{\f7\fs18 \tab }{\i\fs18\cf2 // Text for window title bar.}{\i\fs18\cf2
165: \par }{\f7\fs18 WS_OVERLAPPEDWINDOW,}{\f7\fs18 \tab }{\i\fs18\cf2 // Window style.}{\i\fs18\cf2
166: \par }{\f7\fs18 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,}{\f7\fs18 \tab }{\i\fs18\cf2 // Use default positioning}{\i\fs18\cf2
167: \par }{\f7\fs18 NULL,}{\f7\fs18 \tab }{\i\fs18\cf2 // Overlapped windows have no parent.}{\i\fs18\cf2
168: \par }{\f7\fs18 NULL,}{\f7\fs18 \tab }{\i\fs18\cf2 // Use the window class menu.}{\i\fs18\cf2
169: \par }{\f7\fs18 hInstance,}{\f7\fs18 \tab }{\i\fs18\cf2 // This instance owns this window.}{\i\fs18\cf2
170: \par }{\f7\fs18 NULL}{\f7\fs18 \tab }{\i\fs18\cf2 // We don't use any data in our WM_CREATE}{\i\fs18\cf2
171: \par }{\f7\fs18 );}{\f7\fs18
172: \par }{\f7\fs18
173: \par }{\i\fs18\cf2 // If window could not be created, return "failure"}{\i\fs18\cf2
174: \par }{\f7\fs18 if (!hWnd) }{\f7\fs18 \{}{\f7\fs18
175: \par }{\f7\fs18 return (FALSE);}{\f7\fs18
176: \par }{\f7\fs18 }{\f7\fs18 \}}{\f7\fs18
177: \par }{\f7\fs18
178: \par }{\i\fs18\cf2 // Make the window visible; update its client area; and return "success"}{\i\fs18\cf2
179: \par }{\f7\fs18 ShowWindow(hWnd, nCmdShow);}{\f7\fs18 \tab }{\i\fs18\cf2 // Show the window}{\i\fs18\cf2
180: \par }{\f7\fs18 UpdateWindow(hWnd);}{\f7\fs18 \tab }{\i\fs18\cf2 // Sends WM_PAINT message}{\i\fs18\cf2
181: \par }{\f7\fs18
182: \par }{\f7\fs18 return (TRUE);}{\f7\fs18 \tab }{\i\fs18\cf2 // We succeeded}{\i\fs18\cf2
183: \par }{\f7\fs18
184: \par }\pard \li120 {\f7\fs18 \}}{\f7\fs18
185: \par }\pard \li115\keepn {\f7\fs18 \page }{\fs18\up6 ${\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 $} WndProc}}{\f7\fs18 }{\fs18\up6 #{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 #} WndProc}}{
186: \f7\fs18 }{\fs18\up6 +{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 +} WndProc}}{\f7\fs18 }{\fs18\up6 K{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 K} WndProc}}{\f7\fs18 }{\plain
187: \b\f2\lang1033 WndProc Function}{\f7\fs18
188: \par }\pard \li120\sb80\sl-240\tx1440 {\b\f2 FUNCTION}{\f2 :}{\f2 \tab }{\f2 WndProc(HWND, UINT, UINT, LONG)}{\f2
189: \par }{\b\f2 PURPOSE}{\f2 :}{\f2 \tab }{\f2 Processes messages}{\f2
190: \par }{\b\f2 MESSAGES}{\f2 :}{\f2
191: \par }\pard \li1440\sb80\sl-240\tx1440 {\f2 WM_COMMAND - application menu (About dialog box)}{\f2
192: \par }{\f2 WM_DESTROY - destroy window}{\f2
193: \par }\pard \li120\sb80\sl-240\tx1440 {\f2
194: \par }\pard \fi-1320\li1440\sb80\sl-240\tx1440 {\b\f2 COMMENTS}{\f2 :}{\f2 \tab }{\f2
195: To process the IDM_ABOUT message, call MakeProcInstance() to get the current instance address of the About() function. Then call Dialog box which will create the box according to the information in your }{\f2
196: generic.rc file and turn control over to the About() function. When it returns, free the instance address.}{\f2
197: \par }\pard \li120\sb80\sl-240 {\f7\fs18
198: \par }\pard \li120\tx450\tx720\tx990\tx1260\tx1530\tx1800\tx2070\tx2340\tx2610\tx2880 {\f7\fs18 LONG APIENTRY WndProc(}{\f7\fs18
199: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 HWND hWnd,}{\f7\fs18 \tab }{\i\f2\fs18\cf2 // window handle}{\i\f2\fs18\cf2
200: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 UINT message,}{\f7\fs18 \tab }{\i\f2\fs18\cf2 // type of message}{\i\f2\fs18\cf2
201: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 UINT uParam,}{\f7\fs18 \tab }{\i\f2\fs18\cf2 // additional information}{\i\f2\fs18\cf2
202: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 LONG lParam)}{\f7\fs18 \tab }{\i\f2\fs18\cf2 // additional information}{\i\f2\fs18\cf2
203: \par }{\f7\fs18 \{}{\f7\fs18
204: \par }{\f7\fs18 \tab }{\f7\fs18 FARPROC lpProcAbout;}{\f7\fs18 \tab }{\i\f2\fs18\cf2 // pointer to the "About" function}{\i\f2\fs18\cf2
205: \par }{\f7\fs18 \tab }{\f7\fs18 int wmId, wmEvent;}{\f7\fs18
206: \par }{\f7\fs18
207: \par }{\f7\fs18 \tab }{\f7\fs18 switch (message) }{\f7\fs18 \{}{\f7\fs18
208: \par }{\f7\fs18
209: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 case WM_COMMAND:}{\f7\fs18 \tab }{\i\f2\fs18\cf2 // message: command from application menu}{\i\f2\fs18\cf2
210: \par }{\f7\fs18
211: \par }{\i\f2\fs18\cf2 // Message packing of uParam and lParam have changed for Win32, let us}{\i\f2\fs18\cf2
212: \par }{\i\f2\fs18\cf2 // handle the differences in a conditional compilation:}{\i\f2\fs18\cf2
213: \par }{\f7\fs18 #if defined (WIN32)}{\f7\fs18
214: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 wmId = LOWORD(uParam);}{\f7\fs18
215: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 wmEvent = HIWORD(uParam);}{\f7\fs18
216: \par }{\f7\fs18 #else}{\f7\fs18
217: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 wmId = uParam;}{\f7\fs18
218: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 wmEvent = HIWORD(lParam);}{\f7\fs18
219: \par }{\f7\fs18 #endif}{\f7\fs18
220: \par }{\f7\fs18
221: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 switch (wmId) }{\f7\fs18 \{}{\f7\fs18
222: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_ABOUT:}{\f7\fs18
223: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 lpProcAbout = MakeProcInstance((FARPROC)About, hInst);}{\f7\fs18
224: \par }{\f7\fs18
225: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 DialogBox(hInst,}{\f7\fs18 \tab }{\f7\fs18 \tab }{\i\f2\fs18\cf2 // current instance}{\i\f2\fs18\cf2
226: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 "AboutBox",}{\f7\fs18 \tab }{\f7\fs18 \tab }{\i\f2\fs18\cf2 // dlg resource to use}{\i\f2\fs18\cf2
227: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 hWnd,}{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\i\f2\fs18\cf2 // parent handle}{\i\f2\fs18\cf2
228: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 (DLGPROC)lpProcAbout);}{\f7\fs18 \tab }{\i\f2\fs18\cf2 // About() instance address}{\i\f2\fs18\cf2
229: \par }{\f7\fs18
230: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 FreeProcInstance(lpProcAbout);}{\f7\fs18
231: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 break;}{\f7\fs18
232: \par }{\f7\fs18
233: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_EXIT:}{\f7\fs18
234: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 DestroyWindow (hWnd);}{\f7\fs18
235: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 break;}{\f7\fs18
236: \par }{\f7\fs18
237: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_HELPCONTENTS:}{\f7\fs18
238: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 if (!WinHelp (hWnd, "GENERIC.HLP", HELP_KEY, (DWORD)(LPSTR)"CONTENTS")) }{\f7\fs18 \{}{\f7\fs18
239: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 MessageBox (GetFocus(),}{\f7\fs18
240: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab \tab }{\f7\fs18 "Unable to activate help",}{\f7\fs18
241: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab \tab }{\f7\fs18 szAppName, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND);}{\f7\fs18
242: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 \}}{\f7\fs18
243: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 break;}{\f7\fs18
244: \par }{\f7\fs18
245: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_HELPSEARCH:}{\f7\fs18
246: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 if (!WinHelp(hWnd, "GENERIC.HLP", HELP_PARTIALKEY, (DWORD)(LPSTR)"")) }{\f7\fs18 \{}{\f7\fs18
247: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 MessageBox (GetFocus(),}{\f7\fs18
248: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab \tab }{\f7\fs18 "Unable to activate help",}{\f7\fs18
249: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab \tab }{\f7\fs18 szAppName, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND);}{\f7\fs18
250: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 \}}{\f7\fs18
251: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 break;}{\f7\fs18
252: \par }{\f7\fs18
253: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_HELPHELP:}{\f7\fs18
254: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 if(!WinHelp(hWnd, (LPSTR)NULL, HELP_HELPONHELP, 0)) }{\f7\fs18 \{}{\f7\fs18
255: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 MessageBox (GetFocus(),}{\f7\fs18
256: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab \tab }{\f7\fs18 "Unable to activate help",}{\f7\fs18
257: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab \tab }{\f7\fs18 szAppName, MB_SYSTEMMODAL|MB_OK|MB_ICONHAND);}{\f7\fs18
258: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 \}}{\f7\fs18
259: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 break;}{\f7\fs18
260: \par }{\f7\fs18
261: \par }{\i\f2\fs18\cf2 // Here are all the other possible menu options,}{\i\f2\fs18\cf2
262: \par }{\i\f2\fs18\cf2 // all of these are currently disabled:}{\i\f2\fs18\cf2
263: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_NEW:}{\f7\fs18
264: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_OPEN:}{\f7\fs18
265: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_SAVE:}{\f7\fs18
266: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_SAVEAS:}{\f7\fs18
267: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_UNDO:}{\f7\fs18
268: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_CUT:}{\f7\fs18
269: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_COPY:}{\f7\fs18
270: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_PASTE:}{\f7\fs18
271: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_LINK:}{\f7\fs18
272: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 case IDM_LINKS:}{\f7\fs18
273: \par }{\f7\fs18
274: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 default:}{\f7\fs18
275: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 return (DefWindowProc(hWnd, message, uParam, lParam));}{\f7\fs18
276: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 \}}{\f7\fs18
277: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 break;}{\f7\fs18
278: \par }{\f7\fs18
279: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 case WM_DESTROY:}{\f7\fs18 \tab }{\i\f2\fs18\cf2 // message: window being destroyed}{\i\f2\fs18\cf2
280: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 PostQuitMessage(0);}{\f7\fs18
281: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 break;}{\f7\fs18
282: \par }{\f7\fs18
283: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 default:}{\f7\fs18 \tab }{\i\f2\fs18\cf2 // Passes it on if unproccessed}{\i\f2\fs18\cf2
284: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 return (DefWindowProc(hWnd, message, uParam, lParam));}{\f7\fs18
285: \par }{\f7\fs18 \tab }{\f7\fs18 \}}{\f7\fs18
286: \par }{\f7\fs18 \tab }{\f7\fs18 return (NULL);}{\f7\fs18
287: \par }{\f7\fs18 \}}{\f7\fs18
288: \par }\pard \li115\keepn {\f7\fs18 \page }{\fs18\up6 ${\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 $} CenterWindow}}{\f7\fs18 }{\fs18\up6 #{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 #}
289: CenterWindow}}{\f7\fs18 }{\fs18\up6 +{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 +} CenterWindow}}{\f7\fs18 }{\fs18\up6 K{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 K} CenterWindow}}
290: {\plain \b\f2\lang1033 }{\plain \b\f2\lang1033 CenterWindow Function}{\f7\fs18
291: \par }\pard \fi-1320\li1440\sb80\sl-240\tx1440 {\b\f2 FUNCTION}{\f2 :}{\f2 \tab }{\f2 CenterWindow (HWND, HWND)}{\f2
292: \par }{\b\f2 PURPOSE}{\f2 :}{\f2 \tab }{\f2 Center one window over another}{\f2
293: \par }{\b\f2 COMMENTS}{\f2 :}{\f2 \tab }{\f2 Dialog boxes take on the screen position that they were designed at, which is not always appropriate. Centering the dialog over a particular window usually results in a better position}{\f2
294: \par }\pard \li120\sb80\sl-240 {\f7\fs18
295: \par }{\f7\fs18 BOOL CenterWindow (HWND hwndChild, HWND hwndParent)}{\f7\fs18
296: \par }{\f7\fs18 \{}{\f7\fs18
297: \par }{\f7\fs18 RECT rChild, rParent;}{\f7\fs18
298: \par }{\f7\fs18 int wChild, hChild, wParent, hParent;}{\f7\fs18
299: \par }{\f7\fs18 int wScreen, hScreen, xNew, yNew;}{\f7\fs18
300: \par }{\f7\fs18 HDC hdc;}{\f7\fs18
301: \par }{\f7\fs18
302: \par }{\i\fs18\cf2 // Get the Height and Width of the child window}{\i\fs18\cf2
303: \par }{\f7\fs18 GetWindowRect (hwndChild, &rChild);}{\f7\fs18
304: \par }{\f7\fs18 wChild = rChild.right - rChild.left;}{\f7\fs18
305: \par }{\f7\fs18 hChild = rChild.bottom - rChild.top;}{\f7\fs18
306: \par }{\f7\fs18
307: \par }{\i\fs18\cf2 // Get the Height and Width of the parent window}{\i\fs18\cf2
308: \par }{\f7\fs18 GetWindowRect (hwndParent, &rParent);}{\f7\fs18
309: \par }{\f7\fs18 wParent = rParent.right - rParent.left;}{\f7\fs18
310: \par }{\f7\fs18 hParent = rParent.bottom - rParent.top;}{\f7\fs18
311: \par }{\f7\fs18
312: \par }{\i\fs18\cf2 // Get the display limits}{\i\fs18\cf2
313: \par }{\f7\fs18 hdc = GetDC (hwndChild);}{\f7\fs18
314: \par }{\f7\fs18 wScreen = GetDeviceCaps (hdc, HORZRES);}{\f7\fs18
315: \par }{\f7\fs18 hScreen = GetDeviceCaps (hdc, VERTRES);}{\f7\fs18
316: \par }{\f7\fs18 ReleaseDC (hwndChild, hdc);}{\f7\fs18
317: \par }{\f7\fs18
318: \par }{\i\fs18\cf2 // Calculate new X position, then adjust for screen}{\i\fs18\cf2
319: \par }{\f7\fs18 xNew = rParent.left + ((wParent - wChild) /2);}{\f7\fs18
320: \par }{\f7\fs18 if (xNew < 0) }{\f7\fs18 \{}{\f7\fs18
321: \par }{\f7\fs18 xNew = 0;}{\f7\fs18
322: \par }{\f7\fs18 }{\f7\fs18 \}}{\f7\fs18 else if ((xNew+wChild) > wScreen) }{\f7\fs18 \{}{\f7\fs18
323: \par }{\f7\fs18 xNew = wScreen - wChild;}{\f7\fs18
324: \par }{\f7\fs18 }{\f7\fs18 \}}{\f7\fs18
325: \par }{\f7\fs18
326: \par }{\i\fs18\cf2 // Calculate new Y position, then adjust for screen}{\i\fs18\cf2
327: \par }{\f7\fs18 yNew = rParent.}{\f7\fs18 top + ((hParent - hChild) /2);}{\f7\fs18
328: \par }{\f7\fs18 if (yNew < 0) }{\f7\fs18 \{}{\f7\fs18
329: \par }{\f7\fs18 yNew = 0;}{\f7\fs18
330: \par }{\f7\fs18 }{\f7\fs18 \}}{\f7\fs18 else if ((yNew+hChild) > hScreen) }{\f7\fs18 \{}{\f7\fs18
331: \par }{\f7\fs18 yNew = hScreen - hChild;}{\f7\fs18
332: \par }{\f7\fs18 }{\f7\fs18 \}}{\f7\fs18
333: \par }{\f7\fs18 }{\f7\fs18
334: \par }{\i\cf2 // Set it, and return}{\i\cf2
335: \par }{\f7\fs18 return SetWindowPos (hwndChild, NULL, }{\f7\fs18
336: \par }{\f7\fs18 xNew, yNew, 0, 0, SWP_NOSIZE | SWP_NOZORDER);}{\f7\fs18
337: \par }\pard \li115 {\f7\fs18 \}}{\f7\fs18 \page }{\fs18\up6 ${\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 $} About}}{\f7\fs18 }{\fs18\up6 #{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 #} About}}{
338: \f7\fs18 }{\fs18\up6 +{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 +} About}}{\f7\fs18 }{\fs18\up6 K{\footnote \pard\plain \s245\li120\sb80\sl-240 \f3\fs20\lang1033 {\fs18\up6 K} About}}{\plain \b\f2\lang1033 }{\plain
339: \b\f2\lang1033 About Dialog Function}{\f7\fs18
340: \par }\pard \li120\sb80\sl-240 {\b\f2 FUNCTION}{\f2 :}{\f2 \tab }{\f2 About(HWND, unsigned, WORD, LONG)}{\f2
341: \par }{\b\f2 PURPOSE}{\f2 :}{\f2 \tab }{\f2 Processes messages for "About" dialog box}{\f2
342: \par }{\b\f2 MESSAGES}{\f2 :}{\f2
343: \par }\pard \li1440\sb80\sl-240 {\f2 WM_INITDIALOG - initialize dialog box}{\f2
344: \par }{\f2 WM_COMMAND - Input received}{\f2
345: \par }{\f2
346: \par }\pard \fi-1320\li1440\sb80\sl-240 {\b\f2 COMMENTS}{\f2 :}{\f2 \tab }{\f2 Display program version information based on settings from the Version section in the resource. Wait for user to click on "Ok" button, then close the dialog box.}{\f2
347: \par }\pard \li120\sb80\sl-240 {\f7\fs18
348: \par }{\f7\fs18
349: \par }\pard \li120\sb80\sl-240\tx450\tx720\tx990\tx1260\tx1530\tx1800\tx2070\tx2340\tx2610\tx2880 {\f7\fs18 BOOL APIENTRY About(}{\f7\fs18
350: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 HWND hDlg,}{\f7\fs18 \tab \tab }{\i\fs18\cf2 // window handle of the dialog box}{\f7\fs18
351: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 UINT message,}{\f7\fs18 \tab }{\i\fs18\cf2 // type of message}{\i\fs18\cf2
352: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 UINT uParam,}{\f7\fs18 \tab \tab }{\i\fs18\cf2 // message-specific information}{\i\fs18\cf2
353: \par }{\f7\fs18 \tab }{\f7\fs18 LONG lParam)}{\f7\fs18
354: \par }{\f7\fs18 \{}{\f7\fs18
355: \par }{\f7\fs18 \tab }{\f7\fs18 static HFONT hfontDlg;}{\f7\fs18
356: \par }{\f7\fs18 \tab }{\f7\fs18 LPSTR lpVersion; }{\f7\fs18
357: \par }{\f7\fs18 \tab }{\f7\fs18 DWORD dwVerInfoSize;}{\f7\fs18
358: \par }{\f7\fs18 \tab }{\f7\fs18 DWORD dwVerHnd;}{\f7\fs18
359: \par }{\f7\fs18 \tab }{\f7\fs18 WORD wVersionLen;}{\f7\fs18
360: \par }{\f7\fs18 \tab }{\f7\fs18 WORD wRootLen;}{\f7\fs18
361: \par }{\f7\fs18 \tab }{\f7\fs18 BOOL bRetCode;}{\f7\fs18
362: \par }{\f7\fs18 \tab }{\f7\fs18 int i;}{\f7\fs18
363: \par }{\f7\fs18 \tab }{\f7\fs18 char szFullPath[256];}{\f7\fs18
364: \par }{\f7\fs18 \tab }{\f7\fs18 char szResult[256];}{\f7\fs18
365: \par }{\f7\fs18 \tab }{\f7\fs18 char szGetName[256];}{\f7\fs18
366: \par }{\f7\fs18
367: \par }{\f7\fs18 \tab }{\f7\fs18 switch (message) }{\f7\fs18 \{}{\f7\fs18
368: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 case WM_INITDIALOG:}{\f7\fs18 \tab }{\i\fs18\cf2 // message: initialize dialog box}{\i\fs18\cf2
369: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 hfontDlg = CreateFont(14, 0, 0, 0, 0, 0, 0, 0,}{\f7\fs18
370: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 0, 0, 0, 0,}{\f7\fs18
371: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 VARIABLE_PITCH | FF_SWISS, "");}{\f7\fs18
372: \par }{\f7\fs18
373: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));}{\f7\fs18
374: \par }{\f7\fs18
375: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 GetModuleFileName (hInst, szFullPath, sizeof(szFullPath));}{\f7\fs18
376: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);}{\f7\fs18
377: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 if (dwVerInfoSize) }{\f7\fs18 \{}{\f7\fs18
378: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 LPSTR lpstrVffInfo;}{\f7\fs18
379: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 HANDLE hMem;}{\f7\fs18
380: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);}{\f7\fs18
381: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 lpstrVffInfo = GlobalLock(hMem);}{\f7\fs18
382: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpstrVffInfo);}{\f7\fs18
383: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 lstrcpy(szGetName, "}{\f7\fs18 \\}{\f7\fs18 \\}{\f7\fs18 StringFileInfo}{\f7\fs18 \\}{\f7\fs18 \\}{\f7\fs18 040904E4}{\f7\fs18 \\}{\f7\fs18 \\}{\f7\fs18 ");}{\f7\fs18
384: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 wRootLen = lstrlen(szGetName);}{\f7\fs18
385: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 for (i = DLG_VERFIRST; i <= DLG_VERLAST; i++) }{\f7\fs18 \{}{\f7\fs18
386: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 GetDlgItemText(hDlg, i, szResult, sizeof(szResult));}{\f7\fs18
387: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 szGetName[wRootLen] = (char)0;}{\f7\fs18
388: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 lstrcat (szGetName, szResult);}{\f7\fs18
389: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 wVersionLen = 0;}{\f7\fs18
390: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 lpVersion = NULL;}{\f7\fs18
391: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 bRetCode = VerQueryValue((LPVOID)lpstrVffInfo,}{\f7\fs18
392: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 (LPSTR)szGetName,}{\f7\fs18
393: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 (void FAR* FAR*)&lpVersion,}{\f7\fs18
394: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 (UINT FAR *) &wVersionLen);}{\f7\fs18
395: \par }{\f7\fs18
396: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 if ( bRetCode && wVersionLen && lpVersion) }{\f7\fs18 \{}{\f7\fs18
397: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 lstrcpy(szResult, lpVersion);}{\f7\fs18
398: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 SetDlgItemText(hDlg, i, szResult);}{\f7\fs18
399: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab \tab }{\f7\fs18 SendMessage (GetDlgItem (hDlg, i), WM_SETFONT, (UINT)hfontDlg, TRUE);}{\f7\fs18
400: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab \tab }{\f7\fs18 \}}{\f7\fs18
401: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 \}}{\f7\fs18 }{\i\fs18\cf2 // for (i = DLG_VERFIRST; i <= DLG_VERLAST; i++)}{\i\fs18\cf2
402: \par }{\f7\fs18
403: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 GlobalUnlock(hMem);}{\f7\fs18
404: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 GlobalFree(hMem);}{\f7\fs18
405: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 \}}{\f7\fs18 }{\i\fs18\cf2 // if (dwVerInfoSize)}{\i\fs18\cf2
406: \par }{\f7\fs18
407: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 return (TRUE);}{\f7\fs18
408: \par }{\f7\fs18
409: \par }{\f7\fs18 \tab }{\f7\fs18 \tab }{\f7\fs18 case WM_COMMAND:}{\f7\fs18 \tab \tab }{\f7\fs18 \tab \tab }{\i\fs18\cf2 // message: received a command}{\i\fs18\cf2
410: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 if (LOWORD(uParam) == IDOK}{\f7\fs18 \tab }{\i\fs18\cf2 // "OK" box selected?}{\i\fs18\cf2
411: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 || LOWORD(uParam) == IDCANCEL) }{\f7\fs18 \{}{\f7\fs18 \tab }{\i\fs18\cf2 // System menu close command?}{\i\fs18\cf2
412: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 EndDialog(hDlg, TRUE);}{\f7\fs18 \tab }{\i\fs18\cf2 // Exit the dialog}{\i\fs18\cf2
413: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 DeleteObject (hfontDlg);}{\f7\fs18
414: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab \tab }{\f7\fs18 return (TRUE);}{\f7\fs18
415: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 \}}{\f7\fs18
416: \par }{\f7\fs18 \tab }{\f7\fs18 \tab \tab }{\f7\fs18 break;}{\f7\fs18
417: \par }{\f7\fs18 \tab }{\f7\fs18 \}}{\f7\fs18
418: \par }{\f7\fs18 \tab }{\f7\fs18 return (FALSE);}{\f7\fs18 \tab }{\i\fs18\cf2 // Didn't process the message}{\i\fs18\cf2
419: \par }{\f7\fs18
420: \par }{\f7\fs18 \tab }{\f7\fs18 lParam;}{\f7\fs18 \tab }{\i\fs18\cf2 // This will prevent 'unused formal parameter' warnings}{\i\fs18\cf2
421: \par }\pard \li120\tx450\tx720\tx990\tx1260\tx1530\tx1800\tx2070\tx2340\tx2610\tx2880 {\f7\fs18 \}}{\f2\fs18
422: \par }}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.