Petzold 1

495
Ч. Петзолд Программирование для Windows ® 95 в двух томах Том I «BHV — Санкт-Петербург» Дюссельдорф Киев Москва Санкт-Петербург

Transcript of Petzold 1

.

Windows 95 I

BHV - -

I ..................................................................................................................................................... 9 1 README.TXT................................................................................................................................................ 11 , ........................................................................................................................... 11 ......................................................................................................................................................... 12 Windows.......................................................................................................................................... 13 ..................................................................................................................................... 14 ........................................................................................................................................................................... 15 2 HELLO, WINDOWS 95 ....................................................................................................................................... 17 Windows ......................................................................................................................17 ................................................................................................................... 17 GUI ............................................................................................................................... 18 .................................................................................................................. 18 ............................................................................................................................ 18 ................................................................................................................................................ 19 ................................................................................ 19 Windows ...................................................................................................... 19 ...................................................................................................................................................... 20 - ................................................................................................... 20 , ................................................................................................................... 20 ................................................................................................................................................... 21 Windows......................................................................................................................... 21 ? ...................................................................................................................... 22 HELLOWIN .................................................................................................................................................. 22 Make- ................................................................................................................................................................. 25 ..................................................................................................... 25 Windows ...................................................................................................................................... 26 , .......................................................................................... 26 ................................................................................................................................................. 27 .................................................................................................................................................................. 27 .................................................................................................................................................. 28 ........................................................................................................................................... 28 .......................................................................................................................................... 29 ........................................................................................................................................................... 31 .................................................................................................................................................... 32 .................................................................................................................................... 33 ................................................................................................................................................... 34 .............................................................................................................................................. 34 ......................................................................................................................... 35 WM_PAINT .......................................................................................................................................... 35 WM_DESTROY.................................................................................................................................... 36 Windows ............................................................................................................ 37 , ............................................................................................................................. 37 ................................................................................................................ 38 .................................................................................................................................................. 39 ....................................................................................................................................................... 39 3 ........................................................................................................................................ 41 ............................................................................................................................................... 41 WM_PAINT .......................................................................................................................................... 42 ........................................................................................ 42 (GDI) ........................................................................................... 43 ................................................................................................................................................ 43 . ................................................................................ 43 ...................................................................................................................... 44 . ................................................................................ 45 TextOut. .............................................................................................................................. 46 .................................................................................................................................................... 47 ......................................................................................................................................................... 47 . ...................................................................................................... 48 ........................................................................................................................................... 49

4 ................................................................................................................................................ 50 SYSMETS1....................................................................................................... 53 !...................................................................................................................................................... 54 ........................................................................................................................................... 55 ....................................................................................................................................................... 55 ............................................................................................................... 56 ................................................................................................................................... 57 SYSMETS......................................................................................................................... 58 ........................................................................................... 62 ........................................................................................................................... 62 .................................................................................................................. 67 4 ....................................................................................................................................... 69 GDI.............................................................................................................................................................. 69 GDI ............................................................................................................................................................ 70 .......................................................................................................................................................... 70 GDI........................................................................................................................................................ 71 ......................................................................................................................................................... 72 ................................................................................................................................................ 72 .......................................................................................................... 72 ................................................................................................. 74 DEVCAPS1............................................................................................................................................ 74 .................................................................................................................................................... 77 ..................................................................................................................................................................... 77 ............................................................................................................................. 78 .......................................................................................................................... 79 ..................................................................................................................................................... 80 .......................................................................................................................... 84 .......................................................................................................................................................... 89 ....................................................................................................................... 93 , ....................................................................................................................... 94 ............................................................................................................................................... 96 ................................................................................................................................................... 96 .............................................................................................................................. 97 Polygon .................................................................................. 98 ......................................................................................................................... 99 ................................................................................................................................................ 100 ( ) ................................................ 101 ............................................................................................................................ 102 ........................................................................................................................................... 102 MM_TEXT ................................................................................................................................. 103 ..................................................................................................................... 105 ............................................................................................................ 106 WHATSIZE ......................................................................................................................................... 109 , .................................................................................................................... 112 .................................................................................................................................. 112 .................................................................................................................................. 113 ............................................................................................................................ 117 : ............................................................................................................... 118 CLOVER .............................................................................................................................................. 118 ............................................................................................................................................................................ 121 ...................................................................................................................... 121 ................................................................................................................................................ 122 Bits and Blts ................................................................................................................................................................. 125 ......................................................................................................................................... 126 , (DIB)........................................................................................... 126 DIB ................................................................................................................................................................. 127 DIB .................................................................................................................... 128 DIB ................................................................................................................................................... 128 DIB " "............................................................................................... 128 GDI.................................................................................................................................. 129 .............................................................................................................. 129 .............................................................................................................. 130 ........................................................................................................................ 131 ..................................................................................................................................................... 131

5 BitBlt.......................................................................................................................................... 132 BitBlt .......................................................................................................... 135 DrawBitmap ............................................................................................................................................. 136 ROP ........................................................................................................................ 136 ................................................................................................... 138 .......................................................................................................................................... 141 ............................................................................................................... 141 StretchBlt ........................................................................... 141 ........................................................................................................................................ 142 ................................................................................................................................................................. 143 ........................................................................................................ 144 ......................................................................................................................... 147 ......................................................................................................................................... 147 ................................................................................................................................................... 147 .................................................................................................................................................. 148 ...................................................................................................................................................... 151 .................................................................................................................................. 153 ........................................................................................................................................................ 154 ........................................................................................................................................... 154 .............................................................................................................. 156 ................................................................................................................. 157 ........................................................................................................................................................ 157 TrueType .................................................................................................................................................. 158 EZFONT ................................................................................................................................................... 158 ................................................................................................................................................. 161 ......................................................................................................................... 162 ................................................................................................................................................... 163 II ................................................................................................................................... 169 5 ................................................................................................................................................. 171 . ............................................................................................................................... 171 ................................................................................................................................... 171 ............................................................................................................................................................. 172 ................................................................................................................. 172 ............................................................................................................................................. 173 ....................................................................... 173 lParam ................................................................................................................................................ 173 .................................................................................................................................... 175 -....................................................................................... 177 ............................................................................................................... 178 SYSMETS: ............................................................................ 178 WM_KEYDOWN................................................................................................. 178 ....................................................................................................................... 179 .............................................................................................................................................. 184 WM_CHAR ......................................................................................................................................... 185 ................................................................................................................................. 186 ....................................................................................................................... 186 ( ) ................................................................................................................................................... 190 .................................................................................................................................. 190 TYPER ................................................................................................................................................. 191 Windows ........................................................................................................................................ 196 OEM ............................................................................................................................................ 197 ANSI ............................................................................................................................................ 198 OEM, ANSI ............................................................................................................ 198 ....................................................................................................................................... 199 ................................................................................................................................... 199 MS-DOS ..................................................................................................................................................... 199 .................................................................................................................. 200 UNICODE Windows NT ...................................................... 201 6 ............................................................................................................................................................ 203 ............................................................................................................................................. 203 ........................................................................................................................... 203 , ........................................................................................ 204 .................................................................................................... 205

6 ..................................................................................................................................... 208 ............................................................................................................................ 209 ...................................................................................................................... 209 .................................................................................................................................. 210 ...................................................................................................................... 211 ........................................................................................................ 211 ......................................................................................................................................... 211 ................................................................................................................................................ 212 ............................................................................................................ 215 CHECKER .......................................................................... 216 ............................................................................. 219 CHECKER ............................................................................................................... 220 .............................................................................................................................................................. 223 ................................................................................................................................... 224 ................................................................................................................................ 227 BLOKOUT2......................................................................................................................................... 227 7 ......................................................................................................................................................... 231 ............................................................................................................................... 231 ................................................................................................................................................... 232 ........................................................................................... 232 : ..................................................................................................................... 233 ........................................................................................................................................................ 233 ......................................................................................................................................................... 237 ......................................................................................................................................................... 239 ............................................................................................................................ 240 ........................................................................ 243 .................................................................................................................................... 243 ............................................................................................................ 243 ................................................................................................................................... 244 Windows ................................................................................................................................... 248 ..................................................................................................................................................................... 249 8 ...................................................................................................................... 253 ............................................................................................................................................................... 254 ........................................................................................................................................ 257 ................................................................................................. 258 ............................................................................................... 258 .............................................................................................................................................. 259 .................................................................................................................................................................... 259 ....................................................................................................................................................... 260 ............................................................................................................................................................ 260 ...................................................................................................................................... 260 .............................................................................................................................. 261 ............................................................................................................................................ 261 ........................................................................................................................... 262 .................................................................................................................................................... 262 ........................................................................................................................................................... 263 WM_CTLCOLORBTN ....................................................................................................................... 263 , ................................................................................................................. 264 ........................................................................................................................... 269 .............................................................................................................................................. 270 COLORS1 ............................................................................................................................................ 271 , ................................................................................. 276 .................................................................................................................... 276 ................................................................................................................................................ 277 ....................................................................................... 278 ............................................................................................................................................... 278 ............................................................................................................................... 280 .................................................................................... 281 .......................................................................................... 281 .............................................................................................. 281 ....................................................................................................................................................... 282 .................................................................................................................................................. 283 ........................................................................................................................... 283 ................................................................................................................ 284

7 ................................................................................................................. 285 , ................................................................................................. 285 ........................................................................................................................................................ 288 Head Windows ................................................................................................................................... 289 III ........................................................................................................... 293 9 , , .......................................................................................... 295 .................................................................................................................................................. 295 ........................................................................................................................................................ 296 ........................................................................................................................................... 298 ............................................................................................................................... 300 ........................................................................................................ 301 ........................................................................................................... 301 : ................................................................................................................. 302 ........................................................................................................... 302 .................................................................................................................................................... 305 - ........................................................................................................ 305 - MessageBox ..................................................................................... 305 , ................................................................................................................... 306 10 ....................................................................................................................... 313 ............................................................................................................................................................................ 313 ...................................................................................................................................................... 314 .......................................................................................................................................................... 314 .................................................................................................................... 315 ................................................................................................................................................. 316 ................................................................................................................................................ 318 .............................................................................................................................. 322 .................................................................................................................... 322 .................................................................................................................... 324 ........................................................................................................................ 324 ......................................................................................................................... 328 ..................................................................................................................................................... 330 ........................................................................................................................................... 330 ............................................................................................................................. 331 .................................................................................................................. 335 .............................................................................................. 341 ..................................................................................................................................................... 341 , ................................................................................................... 341 ..................................................................................................................... 342 ................................................................................................................................................ 343 .................................................................................................................... 344 ...................................................................................................................................................... 344 ? .......................................................................................................................... 344 ............................................................................................... 345 ...................................................................................................................................... 345 ...................................................................................................................... 346 .................................................................................................... 346 .............................................................................................................. 347 POPPAD, ................................................................................ 348 ..................................................................................................................................... 352 .......................................................................................................................................... 353 11 .............................................................................................................................................. 355 ............................................................................................................................................ 355 About ................................................................................................................................ 355 ............................................................................................................................................. 358 ............................................................................................................................................ 359 ................................................................................................................................................ 360 ........................................................................................... 361 ................................... 362 ................................................................................................................................. 364 ............................................................................... 368 OK Cancel ............................................................................................................................................... 370 ................................................................................................................................ 371 ...................................................................................................................................... 373

8 ............................................................................................... 373 ....................................................................................................... 373 .......................................................................................................................................................... 378 ................................................................................................................... 379 ........................................................................................................................................ 379 ....................................................................... 380 COLORS.................................................................................................................................... 381 HEXCALC: ? ................................................................................. 385 ..................................... 390 ...................................................................................................................... 391 POPPAD............................................................................................................ 391 ................................................................................................................................................. 407 ........................................................................................................................................................ 408 Windows, ................................................................... 408 12 ...................................................................................... 411 ............................................................................................... 412 .................................................................................................................................. 413 ....................................................................................... 413 ............................................................................................. 414 .................................................................... 417 .................................................... 418 ........................................................................................................................ 421 ............................................................................................................................................ 421 ............................................................................................................................ 422 .................................................................................................................................................... 434 GADGETS ........................................................................................................................................... 438 .......................................................................................................................................... 465 ........................................................................................................................ 466 ................................................................................................ 470 PROPERTY ......................................................................................................................................... 475

I

1

README.TXT

1

, , Microsoft Windows 95. . 32- Microsoft Visual ++ 4.0. Windows 95 . , Windows 95 , 1985 IBM PC . , , Windows , , . , IBM PC , Windows. . , . , Windows, ( ) , . , , , . , , , , , . , , , .

, , : " - , ." Windows. Windows. . , , , . . . , . . , , , . (, WordStar) (VisiCalc), , . , , . , : . , . , , ; , , . . , , - . , , .

12 , Windows 95. , . , (Application programming interface, API), , , , Windows. Windows, . , , Windows, 6 . ( , , 26 180 .) Windows , , , , . , , . , , , Windows . , .

, Windows. ( ++) , , , , API. Windows 95 Windows, , ( ) Microsoft Windows 1.0 . Windows, , , . Windows, . , Windows, API, , Windows , . , . . Windows, . , Windows. ++, , Microsoft Foundation Classes (MFC) Object Windows Library (OWL) Borland. Visual Basic Microsoft Delphi Borland. , , , Windows. Windows, , ToolBook Asymetrix. , ; , , . , , (Integrated Development Environment, IDE), Microsoft Visual ++ 4.0. (, ), make (, , ), , . IDE . . , , Windows. , IDE; . , . , , , , . , , , IDE. , , . , make , IDE. . , , .

13 , - , MS-DOS, make- , . , . , . , Windows. , Windows , , , . , , , . , , . , , . Windows 95. . , , Windows 95. Windows, Microsoft Press. Windows IDE, , , Windows 95 MFC, "Programming Windows 95 with MFC" ( 1996 ). Windows 95, "Inside Windows 95" ( : , "Windows 95 ", Microsoft Press & , 1995). , 12, "Programming the Windows 95 User Interface". OLE 20 "Inside OLE". Windows 95 "Programmer's Guide Microsoft Windows 95 ". "Inside Visual C++" . , "OLE Controls Inside Out " "Hardcore Visual Basic" . , Windows 95. , Windows, - . , , . API, . , , , . . .

Windows 1981 IBM PC , PC ( ) MS-DOS, Microsoft Disk Operating System. MS-DOS , DIR TYPE, , , ( ). - , . Apple , 1983 Lisa, 1984 Apple, Macintosh, , ( ) , . Windows Microsoft 1983 (, Lisa, , Macintosh) , 1985 . , Microsoft Windows 1.0 , . . Windows 2.0 1987 . . , , , Windows 1.x. Windows 2.0 , , , . Windows Intel 8086 8088, , 1 . Windows/386 ( Windows 2.0)

14 Intel 80386 MS-DOS . Windows 2.1 Windows/286. Windows 3.0 22 1992 . Windows/286 Windows/386. Windows 3.0 Intel 80286, 80386 80486. Windows 16 . "" Windows . Windows 3.0 Windows, "" . Windows 3.1 1992 . , TrueType ( Windows), multimedia ( ), OLE . Windows 3.1 80286 80386 , , . Windows OS/2, DOS Windows, Microsoft IBM. OS/2 1.0 ( ) Intel 80286 ( ) 1987 . Presentation Manager (PM) OS/2 1.1 1988 . PM, , Windows, , . 1990 IBM Microsoft , . IBM OS/2, Microsoft , Windows . OS/2 , Windows. Windows NT, 1993 , Windows, 32- Intel 80386 80486, Pentium. Windows NT (flat) 32- 32- . Windows NT , RISC-. Windows 95 ( Chicago, Windows 4.0) 1995 . Windows NT, Windows 95 32- (, , 80386 ). Windows 95 Windows NT, , RISC-; , 4 . , , Windows NT Windows 95 16- Windows, 32- Windows; , . API, Microsoft . API Win16 Windows 3.1. API Win32 Windows NT Windows 95. . Microsoft 32- Windows 3.1: (Dynamic Link Library, DLL) 32- 16- . API Win32s ( "s" "subset" , API Win16). API Windows 95 Win32c ("c" "compatible" ), . , Windows NT Windows 95 API Win32. , , . , , . , .

1988 , " Windows" Windows, . " Windows 95", , 1995 Windows . , .

15 , , , , , . , . 1985 PC Magazine One Park Avenue -. Microsoft ( - ) , Windows. , Windows, . PC Magazine EGA, Windows . Windows ( , ), , , . 1985 , Windows. , , . , , . Microsoft Windows Software Development Kit (SDK) . , SDK , , Windows. , , , Microsoft. Windows 1.0 1985 , , Windows . , TopView IBM, GEM Digital Research DESQview Quarterdeck. 25 1985 PC Magazine "Windows Wars!" , , TopView , Windows. , Windows ; 1986 Microsoft Systems Journal. , , WHATSIZE, 4, Windows. Microsoft Systems Journal , - Ziff-Davis , PC Magazine. Microsoft, - . Windows Microsoft Systems Journal Microsoft Press. 1986 , , Microsoft ( Microsoft) , Microsoft Systems Journal Windows. , Microsoft Press. Microsoft Press , , " MS-DOS " , , , . 1986 - Microsoft ( ), . " Windows" . ( Windows 1.0 Windows 2.0), , . , " Windows". Windows 3.0, Windows 3.1. , , , " Windows" . , , , - Windows.

, . Windows. , Microsoft Visual ++ 4.0. AUTOEXEC.BAT :CALL \MSDEV\BIN\VCVARS32.BAT

16 , VC++, DOS MS-DOS. , . , MSC.BAT, AUTOEXEC.BAT, CALL, . 1.1. , make- . MSC.BATREM REM REM SET SET SET SET SET SET SET SET SET -----------------------------------------------------------MSC.BAT -- Set up environment for Microsoft C/C++ 7.0 NMAKE -----------------------------------------------------------CC=cl CFLAGS=-c -DSTRICT -G3 -Ow -W3 -Zp -Tp CFLAGSMT=-c -DSTRICT -G3 -MT -Ow -W3 -Zp -Tp LINKER=link GUIFLAGS=-SUBSYSTEM:windows DLLFLAGS=-SUBSYSTEM:windows -DLL GUILIBS=-DEFAULTLIB:user32.lib gdi32.lib winmm.lib comdlg32.lib comctl32.lib RC=rc RCVARS=-r -DWIN32

. 1.1 MSC.BAT CHAP01 CD-ROM. , .

2

Hello, Windows 95

2

Microsoft Windows 95, , , , . Windows , . Windows , . , , , Windows. , . Windows . , , . , , "!" ( , ", !" , ). , , , Windows, . , ( , ) . : " Windows , ?" : ", ". Windows PC- , "" MS-DOS ( ) . , , Windows. , ( !) , Windows, .

WindowsWindows , MS-DOS. , , , , . Windows 95 .

Windows (Graphical User Interface, GUI), " " " ". , , , , Xerox Palo Alto Research Center (PARC) Alto Star, Smalltalk. Apple Computer, -, Lisa , , Macintosh, 1984 . Macintosh, , , . , ( Microsoft) " " .

18

GUI . , WYSIWYG (What you see is what you get, , ) , . , . , . , . (, , , , ), . , , . , , . , .

, . Windows , Windows . Windows . . . . , . , Windows, . ( ) Windows . , Windows, . . Windows , . Windows , . , , , Windows. , Windows, -, .

, , , , . MS-DOS, , , Sidekick, . , , , . , , . Windows . Windows . . , , . (, , , , ), Windows , , , " " (desktop). Windows , "" "". , Windows , . , , "" . Windows 95 , , , , .

19

. , , . . , . Windows 1, 8088, . . , Windows ; , . Windows , EXE-. , "" ; . , Windows, , " " (DLL). Windows . Windows . , Windows 1, 640 , , . Microsoft : Windows 2 Windows (EMS), Windows 3, , Windows 16 . Windows 95 , 32- .

Windows , Windows , . , . , Windows, , . Windows , (Graphics Device Interface, GDI), . Windows . , Windows, , Windows. . IBM PC , , Windows . PC . PC . , PC . , MS-DOS , . Windows 95 , .

Windows Windows 95 : . , MS-DOS Windows - . Windows, Windows. , Windows. Windows . - , " ". , " ". "" . , " ". Windows. .

20

Windows 95 , . - . , Windows, - . Windows , , , CreateWindow. ( ) . : IsClipboardFormatAvailable , . Windows . WINDOWS.H, . , Windows 95 . Windows. . Windows Windows , , strlen. , , Windows (DLL). Windows, Windows , " ". EXE- Windows , . DLL SYSTEM Windows. Windows , , , , . Windows, , " ", . Windows . EXE- , Windows Windows.

- Windows - (Object Oriented Programming, OOP). , Windows , , Windows , , , , , , , , , , "". , . . (title bar), (menu), (sizing border) (scroll bars). . , , "" (child windows). (push buttons), (radio buttons), (check boxes), (text entry fields), (list boxes) (scroll bars). , , . , . "". . , , Windows.

, , . , . , .

21 , , . , ? , ? , , . , , . Windows, , . . "Windows ". , , , . ? , . ? : "Windows ," , Windows . . , Windows, (window procedure).

, , , . , , . , , , , . , - Windows 95. , , . , , . Windows , - Windows. , " ". , . , , . , Windows . ( Windows), . - "" . . . , , , Windows , . , . , . , , "" , . , , . Windows , Windows (message queue). , . , (message loop), . , . Windows , , , , , , , . .

Windows The C Programming Language (2d ed., Prentice Hall, 1988), , , , "Hello, world":#include main() { printf("Hello, world\n"); }

22 , Microsoft Windows 95. HELLOWIN, , "Hello, Windows 95!" , . HELLOWIN, , HELLOWIN. 80 . 80 . Windows. , , "Hello, Windows 95!" , , "Hello, world" .

? "Hello, world" , . . , , . , . , , . " ", , . "Hello, world" , ? , , , . , - , . , ? , , , . , "Hello, world" , , , . , , "Hello, world". ! . , . , "Hello, world" , . , , . "Hello, world" , , . , .

HELLOWIN , "HELLOWIN", . 2.1. make HELLOWIN.MAK HELLOWIN.. HELLOWIN.MAK#-----------------------# HELLOWIN.MAK make file #-----------------------hellowin.exe : hellowin.obj $(LINKER) $(GUIFLAGS) -OUT:hellowin.exe hellowin.obj $(GUILIBS) hellowin.obj : hellowin.c $(CC) $(CFLAGS) hellowin.c

HELLOWIN.C/*-----------------------------------------------------------HELLOWIN.C -- Displays "Hello, Windows 95!" in client area (c) Charles Petzold, 1996 ------------------------------------------------------------*/

23

#include LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static char szAppName[] = "HelloWin"; HWND hwnd; MSG msg; WNDCLASSEX wndclass; wndclass.cbSize wndclass.style wndclass.lpfnWndProc wndclass.cbClsExtra wndclass.cbWndExtra wndclass.hInstance wndclass.hIcon wndclass.hCursor wndclass.hbrBackground wndclass.lpszMenuName wndclass.lpszClassName wndclass.hIconSm = sizeof(wndclass); = CS_HREDRAW | CS_VREDRAW; = WndProc; = 0; = 0; = hInstance; = LoadIcon(NULL, IDI_APPLICATION); = LoadCursor(NULL, IDC_ARROW); =(HBRUSH) GetStockObject(WHITE_BRUSH); = NULL; = szAppName; = LoadIcon(NULL, IDI_APPLICATION);

RegisterClassEx(&wndclass); hwnd = CreateWindow( szAppName, "The Hello Program", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); ShowWindow(hwnd, iCmdShow); UpdateWindow(hwnd); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rect; switch(iMsg) { case WM_CREATE: PlaySound("hellowin.wav", NULL, SND_FILENAME | SND_ASYNC); return 0;

// // // // // // // // // //

window class name window caption window style initial x position initial y position initial x size initial y size parent window handle window menu handle program instance handle

// creation parameters

24case WM_PAINT: hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rect); DrawText(hdc, "Hello, Windows 95!", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint(hwnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, iMsg, wParam, lParam); }

. 2.1 HELLOWIN 9 , Windows, (resource script) .RC. make-, , , , . , HELLOWIN. , Windows. ; , Windows, . , , . Windows 95, Microsoft Visual C++ 4.0, (batch) VCVARS32.BAT, Visual C++, MSC.BAT, 1, MS-DOS:NMAKE HELLOWIN.MAK

, , HELLOWIN.EXE. , MS-DOS, :HELLOWIN

, . 2.2. , , "Hello, Windows 95!". , . ( , ?) , 80 . . . "Hello, Windows 95!" . HELLOWIN . . . , , : , , . , HELLOWIN Windows, , , . , .

25

. 2.2 HELLOWIN, Windows 95

Make- Windows, NMAKE, Microsoft Visual C++ 4.0. - HELLOWIN., , HELLOWIN.EXE NMAKE , . Make- , , , , (target file), - (dependent file), . , , . -. - , , NMAKE . NMAKE , make. , - make- , NMAKE . make- HELLOWIN.MAK . HELLOWIN.OBJ , HELLOWIN.EXE, . HELLOWIN.C , HELLOWIN.OBJ, . HELLOWIN.OBJ - make-, , NMAKE, HELLOWIN.EXE, HELLOWIN.OBJ. , make- , , . , HELLOWIN.C HELLOWIN.OBJ. , HELLOWIN.OBJ HELLOWIN.EXE. 1 , make- , , . , , , , , 1.

, . 2.1, HELLOWIN.C. , , !

26 , HELLOWIN.C . : WinMain WndProc. WinMain . main . Windows WinMain. WndProc " " HELLOWIN. , , , Windows, , , . , ( ) . , "" . , . , . HELLOWIN.C WndProc: WndProc Windows. , WinMain WndProc, , WinMain.

WindowsHELLOWIN 17 Windows. ( ): LoadIcon . LoadCursor . GetStockObject ( ). RegisterClassEx . CreateWindow . ShowWindow . UpdateWindow . GetMessage . TranslateMessage , . DispatchMessage . PlaySound . BeginPaint . GetClientRect . DrawText . EndPaint . PostQuitMessage "" . DefWindowProc .

, , WINDOWS.H.

, HELLOWIN.H , . Windows. , : CS_HREDRAW DT_VCENTER WM_CREATE CS_VREDRAW IDC_ARROW WM_DESTROY CW_USEDEFAULT IDI_APPLICATION WM_PAINT DT_CENTER SND_ASYNC WS_OVERLAPPEDWINDOW DT_SINGLELINE SND_FILENAME . , , :

27

CS IDI IDC WS CW WM SND DT

Windows, . , Windows, .

HELLOWIN.C ; typedef, #define. Windows 16- , 32- ( ) . , , . . , UINT, WndProc , Windows 95 32-. PSTR, WinMain, , . . char*. . , WndProc WPARAM LPARAM . . Windows 16- , WndProc WORD, 16- , LONG, 32- , "W" "L" "PARAM". Windows 95 WPARAM UINT, LPARAM LONG ( ), 32-. , WORD Windows 95 - 16- , "W" "PARAM" . WndProc LRESULT. LONG. WinMain WINAPI ( Windows, ), WndProc CALLBACK. stdcall, , Windows . HELLOWIN ( ), Windows. : MSG WNDCLASSEX PAINTSTRUCT RECT

WinMain , msg wndclass. WndProc ps rect.

, , (handles): HINSTANCE HWND HDC

(instance)

28 Windows . , HICON ( ), HCURSOR ( ) HBRUSH ( ). ( 32 ), . Windows MS-DOS. Windows. Windows, . , Windows, , "", .

, HELLOWIN. . , szCmdLine WinMain. Windows , , Microsoft . : , . , sz szCmdLine , (string terminated by zero). h hInstance hPrevInstance (handle); i iCmdShow (integer). WndProc , , , wParam uiParam ( unsigned integer). WPARAM LPARAM, . ( ) , , . , WinMain HELLOWIN. msg MSG; wndclass WNDCLASSEX. WndProc, ps PAINTSTRUCT, rect RECT. . , , . , : c by n i x, y cx, cy b f w l dw fn s sz h p

BYTE ( ) ( x y) ( x y), "" (count) BOOL ( ); f "" (flag) WORD ( ) LONG ( ) DWORD ( ) , (handle) (pointer)

HELLOWIN. , . #include, WINDOWS.H:#include

WINDOWS.H , Windows, Windows, . #include WndProc:LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

29 , WinMain WndProc. , , main. . ( main , . . main.) Windows WinMain. WinMain :int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)

WINAPI , , Windows . WinMain. . hInstance (instance handle). , , Windows. , Windows . "" hInstance. " " " " . hPrevInstance (previous instance) . Windows , , , . , hPrevInstance = 0 NULL. Windows 95 NULL. szCmdLine , , . Windows , MS-DOS Run, Start. iCmdShow , , . . , . 1 7. . SW_SHOWNORMAL ( Windows 1) SW_SHOWMINNOACTIVE ( 7). SW " " (show window). , .

. , , . , : . , , . . , - Windows . , . , , . RegisterClassEx. ( Ex, . . extended ) RegisterClass Windows. RegisterClass Windows 95. RegisterClassEx : WNDCLASSEX. WNDCLASSEX Windows :typedef struct tagWNDCLASSEX { UINT cbSize; UINT style; WNDPROC lpfnWndProc; int cbClsExtra; int cbWndExtra; HINSTANCE hInstance; HICON hIcon; HCURSOR hCursor;

30HBRUSH LPCSTR LPCSTR HICON } WNDCLASSEX; hbrBackground; lpszMenuName; lpszClassName; hIconSm;

: LP lp " " (long pointer), 16- Windows, ( , near) 16- ( , far) 32- . Windows 95 32 . l , - . : lpfn " " (long pointer to a function). cb " " (counter of bytes). hbr " " (handle to a brush). WinMain WNDCLASSEX, :WNDCLASSEX wndclass;

12 RegisterClassEx:RegisterClassEx(&wndclass);

. ( , , ). (lpfnWndProc) , , ( HELLOWIN.C WndProc). , . cbSize . :wndclass.style = CS_HREDRAW | CS_VREDRAW;

" " (class style) OR . Windows, , CS, 32- , 1. , CS_VREDRAW 0x0001, CS_HREDRAW 0x0002. " " (bit flags). OR . , , (CS_HREDRAW) (CS_VREDRAW) . HELLOWIN, , . , . , . WNDCLASSEX :wndclass.lpfnWndProc = WndProc;

WndProc , HELLOWIN.. , . , lpfn " ". :wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0;

, Windows. . HELLOWIN , 0. , , " " . ( WinMain):wndclass.hInstance = hInstance;

:wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);

31 wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

, . , Windows . , Windows. . , LoadIcon, NULL. ( , .) , IDI (" " ID for icon) Windows. IDI_APPLICATION . LoadIcon . . wndclass.hIcon wndclass.hIconSm. WNDCLASSEX HICON, " " (handle to an icon). :wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);

. LoadCursor IDC_ARROW . hCursor WNDCLASSEX. , , . , . hbr hbrBackground " " (handle to a brush). , , . Windows , (stock) . GetStockObject, , :wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);

, , . . HELLOWIN , NULL:wndclass.lpszMenuName = NULL;

. , "HelloWin", szAppName:wndclass.lpszClassName = szAppName;

12 , HELLOWIN RegisterClassEx. WNDCLASSEX:RegisterClassEx(&wndclass);

, . , CreateWindow, , , , . Windows , , . , . , - . , , Windows. , , . , , . , , . , , . , . , RegisterClassEx, CreateWindow , . CreateWindow HELLOWIN.C:

32hwnd = CreateWindow( szAppName, "The Hello Program", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL );

// // // // x // y // x // y // // // //

, // CreateWindow. " " szAppName "HelloWin", . , . , , , , , . , WS_OVERLAPPEDWINDOW " ". " " , . " x" " y" . CW_USEDEFAULT, Windows, . (CW_USEDEFAULT 0x80000000.) Windows , . " x" " y". CW_USEDEFAULT , , Windows . " " NULL, . ( -, .) " " NULL, . " " , WinMain. , " " NULL. - , . CreateWindow . hwnd, HWND ( handle to a window). Windows . , . Windows hwnd, Windows , . , . , Windows.

, CreateWindow , Windows. , . . :ShowWindow(hwnd, iCmdShow);

CreateWindow . iCmdShow, WinMain. . iCmdShow SW_SHOWNORMAL (. . 1), . iCmdShow SW_SHOWMINNOACTIVE (. . 7), , . ShowWindow . ShowWindow SW_SHOWNORMAL, , . :UpdateWindow(hwnd);

33 . ( WndProc HELLOWIN.C) WM_PAINT. , WndProc .

UpdateWindow, . . Windows " " (message queue) , Windows. , Windows "", . , , " " (message loop):while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam;

msg MSG, Windows :typedef struct tagMSG { HWND hwnd; UINT message; WPARAM wParam; LPARAM lParam; DWORD time; POINT pt; } MSG;

POINT , :typedef struct tagPOINT { LONG x; LONG y; } POINT;

GetMessage, , :GetMessage(&msg, NULL, 0, 0)

Windows msg MSG. , , NULL 0, , , . Windows . : hwnd , . HELLOWIN, , hwnd, CreateWindow, . message . , . , Windows WM ( window message). , HELLOWIN , Windows message WM_LBUTTONDOWN, 0x0201. wParam 32- (message parameter), . lParam 32- , . time , . pt .

34 message , , , WM_QUIT (. ., 0x0012), GetMessage . WM_QUIT . , wParam msg. :TranslateMessage(&msg);

msg Windows - . ( 5.) :DispatchMessage(&msg);

msg Windows. Windows , Windows . HELLOWIN WndProc. , WndProc , Windows, DispatchMessage. Windows HELLOWIN DispatchMessage , , GetMessage.

, , : , , , . , "window proc". , , . HELLOWIN WndProc. (, , , ). Windows . , , RegisterClassEx. CreateWindow . . :LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)

, MSG. hwnd, . , CreateWindow. HELLOWIN, , . ( ), hwnd , . ( 32- UINT), . (wParam WPARAM lParam LPARAM) . " " (message parameters). .

, iMsg . Windows , WM ("window message") . Windows switch case , , . , 0. , , Windows, DefWindowProc. , DefWindowProc, . HELLOWIN WndProc : WM_CREATE, WM_PAINT WM_DESTROY. :

35switch(iMsg) { case WM_CREATE: [process WM_CREATE message] return 0; case WM_PAINT: [process WM_PAINT message] return 0; case WM_DESTROY: [process WM_DESTROY message] return 0; } return DefWindowProc(hwnd, iMsg, wParam, lParam);

, DefWindowProc , .

, , WndProc WM_CREATE. WndProc , Windows CreateWindow WinMain. , HELLOWIN CreateWindow, Windows , , . . Windows WndProc WM_CREATE . WndProc WM_CREATE Windows. Windows CreateWindow HELLOWIN, WinMain. , . WM_CREATE. HELLOWIN HELLOWIN.WAV. PlaySound. . (sound alias name), Sounds (Control Panel) . , . . , , , . . PlaySound , . WndProc WM_CREATE .

WM_PAINT WM_PAINT WndProc . Windows. , (invalid), . ? , . WM_PAINT ( , UpdateWindow WinMain) - . , . , style wndclass HELLOWIN CS_HREDRAW CS_VREDRAW. Windows . WM_PAINT. HELLOWIN, , Windows . , . , Windows . WM_PAINT . , , Windows , . , Windows . WM_PAINT . WM_PAINT BeginPaint:hdc = BeginPaint(hwnd, &ps);

36 EndPaint:EndPaint(hwnd, &ps);

, PAINTSTRUCT. PAINTSTRUCT , . ( .) BeginPaint, Windows , . , hbrBackground WNDCLASSEX, . HELLOWIN , Windows , . BeginPaint ( ) . (, ) . . , BeginPaint, , . EndPaint , . WM_PAINT ( ), DefWindowProc. DefWindowProc BeginPaint EndPaint , , , . . , . , WndProc BeginPaint, GetClientRect:GetClientRect(hwnd, &rect);

. rect, WndProc RECT. RECT "" (rectangle), Windows. LONG, : left, top, right bottom. GetClientRect . left top 0. right bottom . WndProc RECT, DrawText:DrawText(hdc, "Hello, Windows 95!", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);

DrawText ( ) . - , , BeginPaint. , 1, , . , Windows. , , , . , , "Hello, Windows 95!" . ( ), WndProc WM_PAINT. WndProc , GetClientRect, .

WM_DESTROY WM_DESTROY. , Windows . , Close, Close , +. HELLOWIN , :PostQuitMessage(0);

WM_QUIT . , GetMessage , WM_QUIT. GetMessage WM_QUIT, 0. WinMain , .

37

Windows Hellowin, , . , , main. HELLOWIN WinMain , , / . . HELLOWIN . , Windows . , , Windows.

, , - . , fopen . , , , . . Windows . Windows , Windows , , WndProc. , RegisterClassEx. , , . Windows , . Windows WndProc . Windows WndProc . Windows WndProc , , . Windows WndProc . Windows WndProc . Windows WndProc, . . Windows, . 200 , Windows , , "WM" Windows. , , , , . signal +. ON Microsoft BASIC. Microsoft , Windows. Windows . , , . DefWindowProc . wParam lParam HELLOWIN DefWindowProc. . . . , Windows . hwnd , . iMsg WM_SIZE. wParam WM_SIZE SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN, SIZEZOOMSHOW SIZEZOOMHIDE ( Windows 0 4). wParam , , ( ). lParam . (16- ) (16- ) 32- lParam. Windows , lParam. . , DefWindowProc, . , , HELLOWIN Close , . DefWindowProc . , Close, WM_SYSCOMMAND . WndProc DefWindowProc. DefWindowProc , WM_CLOSE . WndProc DefWindowProc. DefWindowProc

38 WM_CLOSE, DestroyWindow. DestroyWindow Windows WM_DESTROY . , WndProc , PostQuitMessage WM_QUIT . WinMain .

, Windows . Windows , , GetMessage, , DispatchMessage. , Windows- ( ) , ( Windows) ? , . "" (queued), "" (nonqueued)1. , Windows , . , Windows . , , . Windows , . , (post), (send). , , , (, WM_KEYDOWN WM_KEYUP), , (WM_CHAR), (WM_MOUSEMOVE) (WM_LBOTTONDOWN). (WM_TIMER), (WM_PAINT) (WM_QUIT). . . DefWindowProc , Windows , . , , Windows, . , . - , . " " (ultimate hook). , . Windows SendMessage. ( , PostMessage.) , WinMain CreateWindow, Windows WM_CREATE. WinMain ShowWindow, Windows WM_SIZE WM_SHOWWINDOW. WinMain UpdateWindow, Windows WM_PAINT. . . , , , , .

1

"" "". , . send ( SendMessage) post ( PostMessage). SendMessage, , , . PostMessage, , . , , : SendMessage, ; PostMessage, . (. .).

39 . , DispatchMessage WinMain. DispatchMessage , . , - (reentrant). , Windows WndProc , DefWindowProc WndProc . , . , , Windows. , , ? , , Windows, , , . , Windows . , , , . , . , , .

Windows 95 . , , Windows . Windows 95 , DOS, Windows. , Windows , , . , , . , . . , , , . . . , , , . , , , , , . DefWindowProc, , , . , 14 . , . , .

, , , , Windows MS-DOS. , Windows . Windows , . MS-DOS , / . , Windows . , , . . Windows, - , . , , - . , WINDUMP ( ) . , , WINDUMP , . , WINDUMP . , WINDUMP , . : , , , , ?

40 , : , , ? Windows? , : , 1000 , ? : Windows, ? , . , .

3

3

Windows 95, , , , . : , , , , . , , . , , , . MS-DOS, . , . . 25 ( 43, 50) 80 . . Windows , . ( ), . . . , "Hello". , , , , . Windows. Windows (GDI) , . , Windows, (system font), Windows . , . , , , Windows . (, , Windows Calculator), , Windows, . , , , , . Windows . , , .

MS-DOS , , . , , . , . (, ) , , , . Windows , , - , - . , . Windows

42 , . , Windows , , . Windows , . Windows . WM_PAINT, Windows , .

WM_PAINT Windows UpdateWindow WinMain, . Windows WM_PAINT. , . WM_PAINT , , . WM_PAINT : , - , . ( CS_HREDRAW CS_HVREDRAW). ScrollWindow ScrollDC. WM_PAINT InvalidateRect InvalidateRgn.

, , Windows , . . Windows WM_PAINT. , : Windows , . .

Windows , . , : . .

WM_PAINT , , . , , , " " Windows WM_PAINT. , Windows WM_PAINT. , .

, WM_PAINT, , ( ). , . , . " " (invalid region) " " (update region). Windows WM_PAINT . WM_PAINT , , . . . Windows " " (paint information structure). ( ) , . " "

43 (invalid rectangle); " " (invalid region). WM_PAINT, Windows , . Windows WM_PAINT. , InvalidateRect, . WM_PAINT, Windows . Windows WM_PAINT . WM_PAINT ( ), . , GetUpdateRect. BeginPaint WM_PAINT, . , ValidateRect, . , WM_PAINT, , .

(GDI) , . ( GDI ). Windows GDI . 2 DrawText, TextOut. :TextOut(hdc, x, y, psString, iLength);

TextOut . psString , iLength . x y . ( .) hdc " " (handle to a device context), GDI. GDI .

, , Windows . Windows . GDI. , , . , GDI. , , . , . "" (attributes). GDI. , TextOut , , x y, TextOut , , . , . . , . . , CreateDC ( ), . Windows , .

. WM_PAINT. : BeginPaint EndPaint. ( ) PAINTSTRUCT. , Windows, ps :

44PAINTSTRUCT ps;

WM_PAINT BeginPaint ps. BeginPaint . hdc. :HDC hdc;

HDC 32- . GDI, TextOut. EndPaint . WM_PAINT :case WM_PAINT: hdc=BeginPaint(hwnd, &ps); [ GDI] EndPaint(hwnd, &ps); return 0;

WM_PAINT BeginPaint EndPaint . WM_PAINT , DefWindowProc ( ), Windows. DefWindowProc WM_PAINT :case WM_PAINT: BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps); return 0;

BeginPaint EndPaint . :case WM_PAINT: return 0; // !!!

Windows WM_PAINT , ( ). BeginPaint EndPaint ( ValidateRect), Windows . Windows WM_PAINT. , , ...

, Windows . PAINTSTRUCT. :typedef struct tagPAINTSTRUCT { HDC hdc; BOOL fErase; RECT rcPaint; BOOL fRestore; BOOL fIncUpdate; BYTE rgbReserved[32]; } PAINTSTRUCT;

Windows , BeginPaint. . Windows. hdc . BeginPaint , Windows. , fErase TRUE (. ., ), , Windows . Windows , , hbrBackground WNDCLASSEX, WinMain. Windows :wndclass.hbrBackground =(HBRUSH) GetStockObject(WHITE_BRUSH);

, , InvalidateRect, , , . FALSE (. . 0), Windows fErase FALSE.

45 rcPaint PAINTSTRUCT RECT. 2, RECT . : left, top, right bottom. rcPaint PAINTSTRUCT , . 3.1. . , . Windows WM_PAINT, , , .0 left right

0

top

Invalid rectanglebottom( )

Client area( )

. 3.1 rcPaint PAINTSTRUCT , "" (clipping) . , Windows . ( , , Windows .) PAINTSTRUCT, Windows rcPaint. WM_PAINT rcPaint, :InvalidateRect(hWnd, NULL, TRUE);

BeginPaint. . FALSE, . , . HELLOWIN 2 WM_PAINT. , , DrawText . DrawText Windows , . . , , WM_PAINT , GDI.

. , WM_PAINT , , , . GetDC ReleaseDC, :hdc=GetDC(hwnd); [ GDI] ReleaseDC(hwnd, hdc);

46 BeginPaint EndPaint, GetDC ReleaseDC . GetDC, ReleaseDC. GetDC , ReleaseDC . , PAINTSTRUCT, , GetDC, , . , ( ). BeginPaint, GetDC - . , GetDC ReleaseDC (, ) (, ). , WM_PAINT. , , WM_PAINT.

TextOut. , Windows . , GDI. GDI, , TextOut:TextOut(hdc, x, y, psString, iLength);

. , GetDC, BeginPaint, WM_PAINT. . , . , . . , Windows , (character box). , . , , , ( ) , Windows . . Windows WHITE_BRUSH, , , Windows . psString , iLength , . ., . ASCII, , , . Windows . TextOut , iLength. x y TextOut . x , y . (x, y). ( x y 0) . x y TextOut 0, , . GDI " " (logical coordinates). , . , Windows " " (mapping mode), , , GDI, . . MM_TEXT (, Windows). MM_TEXT , , . x , y . (. . 3.2.) MM_TEXT , Windows PAINTSTRUCT. . ( ).

47

0 Values of x( )

Values of y( )

Client area( )

. 3.2 x y MM_TEXT " " (clipping region). , , GetDC, , BeginPaint. Windows , . , Windows . - , , .

, Windows . " " (system font) ( Windows) SYSTEM_FONT. , Windows , . Windows , . . , . , Windows 3.0 ( Windows 95 ), , . . . , W i. , , . , , Windows . " " (raster font). , . Windows . , , . , , Windows, . , , , 25 80 . , Windows.

TextOut, . , . GetTextMetrics. GetTextMetrics , , . Windows TEXTMETRIC. ,

48 . MM_TEXT, . GetTextMetrics, -, ( tm):TEXTMETRIC tm;

GetTextMetrics:hdc = GetDC(hwnd); GetTextMetrics(hdc, &tm); ReleaseDC(hwnd, hdc);

, , .

. TEXTMETRIC . , . 3.3. . tmInternalLeading , . 0, , . tmExternalLeading , . . TEXTMETRIC , : tmAveCharWidth ( ) tmMaxCharWidth ( ). . . 150% tmAveCharWidth.

tmExternalLeading

tmInternalLeading

tmAscent tmHeight

Baseline

tmDescent

. 3.3 , , , Windows. Windows , , , . Windows,

49 . . GetTextMetrics .

Windows, GetTextMetrics . WM_CREATE . WM_CREATE , . Windows WM_CREATE, WinMain CreateWindow. , Windows, , . . (cxChar) (cyChar):static int cxChar, cyChar;

, , "" (ount) x y . , ( WM_PAINT). , . WM_CREATE:case WM_CREATE: hdc = GetDC(hwnd); GetTextMetrics(hdc, &tm); cxChar = tm.tmAveCharWidth; cyChar = tm.tmHeight + tm.tmExternalLeading; ReleaseDC(hwnd, hdc); return 0;

(external leading), :cyChar = tm.tmHeight;

, . cyChar , cxChar . TextOut x:cxChar

y TextOut:cyChar *(1 + i)

i , 0. . MS-DOS , , , printf. Windows printf , printf , Windows . Windows sprintf. , printf, , . TextOut. , sprintf TextOut iLength. sprintf TextOut :int iLength; char szBuffer[40]; [ ] iLength = sprintf(szBuffer, " %d %d %d", nA, nB, nA + nB); TextOut(hdc, x, y, szBuffer, iLength);

iLength :TextOut(hdc, x, y, szBuffer, sprintf(szBuffer, " %d %d %d", nA, nB, nA + nB));

50 , . , sprintf wsprintf. wsprintf , sprintf, Windows, EXE-.

, , , . , , TextOut, , . , . , Windows GetSystemMetrics, . Windows, , , . GetSystemMetrics , "" (index). 73 , Windows. GetSystemMetrics , , . , GetSystemMetrics : . , , , GetSystemMetrics , . SYSMETS.H, . 3.4. SYSMETS.H/*----------------------------------------------SYSMETS.H -- System metrics display structure -----------------------------------------------*/ #define NUMLINES((int)(sizeof sysmetrics / sizeof sysmetrics [0])) struct { int iIndex; char *szLabel; char *szDesc; } sysmetrics [] = { SM_CXSCREEN, SM_CYSCREEN, SM_CXVSCROLL, SM_CYHSCROLL, SM_CYCAPTION, SM_CXBORDER, SM_CYBORDER, SM_CXDLGFRAME, SM_CYDLGFRAME, SM_CYVTHUMB, SM_CXHT