Основы программирования на языке C++ [Часть 4]

Пособие предназначено для обучения студентов, обладающих навыками пользовательской работы на персональном компьютере, ос

254 18 2MB

Russian Pages 124 Year 2002

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

Основы программирования на языке C++ [Часть 4]

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

. .

, . .

++ IV.

Microsoft Windows Visual C++ MFC

(

)

, 2002

32.97 73 681.142.2(075.8)

-

73

. .,

. .

73

++: . –

:

,

2002. – 490 .

,

-

, . 324

++ Windows. ++; (2)

: (1) ; (3) ++

Microsoft Windows

(4)

C++

Visual

MFC. -

, Win32

-

. ++

-

Microsoft Visual C++ 5.0.

: . .

. .





. . ., . . . . . .,

,

.

-

. .

2

............................................................................................................................5 1. 1. 2. 3. 4. 5. 6. 7.

32-

WINDOWS ................................6

.........................................................................................................................6 ........................................................................................................6 ..............................................................................10 WINDOWS API ................................................................................11 ..................................................15 ..........................................................................................................................17 .................................................................................................................17 2.

1. 2. 3. 4. 5. 6. 7. 8. 9.

WINDOWS-

"HELLO, WORLD!" .........................................19 ......................................................19 ...........21 .................................................23 ................................................................................25 ......................................26 ..........................27 ..........................................................................................................................30 . ................................................................................................................30 3.

1. 2. 3. 4. 5. 6.

WINDOWS.

....................................32

.............................................................................................................32 .......................................................................................................33 ..............................................................................36 ...............................................................................................39 ..........................................................................................................................41 . ................................................................................................................42 4.

1. 2. 3. 4.

WINDOWS ...........................................19

MFC....................................................................43 MFC...................................................................................43 MFC............................................................................46 ..........................................................................................................................53 .................................................................................................................54

5. Щ GDI ................................................................................................................................................56 1. 2. 3. 4.

................................................................................................56 GDI.....................61 ..........................................................................................................................69 .................................................................................................................70 6. . ..................................................................................................................................71

1. 2. 3.

....................................................................................71 ...........................................................................74 ......................................................77 3

4.

.................................................................................................................83 7.

...................................................................84

1. 2. 3.

......................................................................84 ..............91 .................................................................................................................93 8.

..............................................................................94

1. 1.5 2. 3.

CDIALOG ..................................................94 ................103 .............................................................................................................105 WINDOWS ...........................................................106 9. /

1. 2. 3. 4. 5. 6. 7. 7.1

"

............................................................................................................108 / ...............................................108 CWINAPP::INITINSTANCE .....................109 .......................................................................................................111 ...................................................................................................................114 ".................................................................................................116 .......................................................................116 ............................................................118 ..........................120 ..................................................................................................................122

4

В ++ MS Windows

,

,

. Borland Delphi,

, MS Visual Basic

,

-

.

,

Windows . Windows API

, -

,

-

.

API

. MS Visual

C++ "

"

MFC (Microsoft Foundation Classes) – . , ",

"

-

. Visual

Windows. ,

API,

MFC,

.

C++

, (

(

, ,

,

,

.),

-

,

. .), (

,

. .)

GDI. MFC AppWizard. ,

-

, , , Windows

MFC

MFC Windows API.

, (

-

).

"

", . .

5

-

Л

1. А

32-

Windows

1. В

3216-

Windows (Win32) , (

32i386-Pentium III)

Intel-

-

. ,



16-

,

32-

,

-

. : (1) Windows NT/2000 Windows NT

Windows. 32(2) Windows 95/98/ME.

(

, -

)

. ,

Intel-

.

. Windows NT Win16 MS-DOS (

-

, -

).

(Windows 95) 32Windows 3.1

DOS

,

, 16MS. -

.

,

, 16Windows 95 ,

).

( 16-

( Win32

,

MS-DOS, , ). ,

,

, Win16 Windows NT (

). (

), Win32

. API. ,

-

, Windows 95

Windows NT ,

.

,

.

2.

Windows . "

, "

, /

. . Windows)

(

)

– ,

,

-

( ,

. -

. 6

,

, –

,

.

,



, .

2.1

,

,

Windows .

. .

.

,

, -

,

, –

.

,

. , . .

. .

,

-

, . "

"

.

-

,

. :



( 1

,

-

,

-

. 1.1). 1

1

2

2

2

2

,

. 1.1.

Windows ,

.

. ,

(

,

) .

,

. ,

,

,

. . 1.2 ( (

).

Windows 95 c , Spy++

7

, Visual C++).

.

. 1.2.

2.2



,

.



,

,

,

– DispatchMessage

. -

.

, Win API.

DispatchMessage,

,

. ,

. .

, Windows

, Button)

( RegisterClass.

, (

Edit).

. .

, .

,

-

. Windows . SetWindowLong (

. SetClassLong (

) ,

). ,



(

). ,

-

. GetClassInfo,

, RegisterClass.

WNDCLASS

,

,

-

. -

,

-

. ++ ( Windows

,

MFC). ,

-

. 8

-

2.3

, .

,

-

, .

. 1.1

, OK.

Spy++. ,

. "

,

1.1.

"

"

-

"

.

MS Word

OK. . WM_LBUTTONDOWN WM_PAINT WM_LBUTTONUP WM_PAINT WM_WINDOWPOSCHANGING WM_WINDOWPOSCHANGED WM_NCACTIVATE WM_ACTIVATE WM_WINDOWPOSCHANGING WM_KILLFOCUS WM_DESTROY WM_NCDESTROY

. OK, . . . OK, . . . . . . . . .

MSG:

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

// // // // // В //

,

hwnd –

, Windows

. .

message

Windows

. .

Windows

.

.

,

. (

, WM_PAINT, WM_TIMER). Windows ( ,

-

windows.h;

-

, ).

#include

. , ,

BM –

, . 9

, WM .

(WM_...). . MDI (

, ,

,

)

,

.



-

.

-

, . . . (EM), (SBM),

, (CB),

(BM), (TVM)

(LB), .

,

, . ,

Windows

,

.

-

RegisterWindowMessage.

. 3. 3.1

Windows .

. .

,

.

,

. . . WinMain(),

Windows. ,

. .

.

,

.

,

,

,

-

, . (

,

UNIX) .

-

, . ., . , ,

fork

( -

UNIX).

: 1)

( -

); 2)

; 3) . ,

.

10

.

; ;

.

3.2

Windows

. .

.

-

. . . Windows , Windows . (

,

,

. . -

,

,

).

.

Win32

-

, . ,

. "

-

"

. ,

++

:

(

) 4. В

MFC -

. Windows API

Windows . Programming Interfaces, API). " (DLL). , ,

(Application " . . , . ++ -

" ".

API

, API , . . API

/

++.

, API (windows.h) (Visual C++

). API.

"





" ,

• Windows API (ODBC).

,

Windows KERNEL.DLL ( ); USER.DLL ( , GDI.DLL ( (MAPI), API

OLE

,

: ,

,

,

); ). API. (TAPI), .

, ,

11

"

" Windows. .

API,

,

"

,

, WinSock,

-



-

" Windows,

.C API

,

,

Kernel,

,

DLL. 4.1

(

Kernel)

: ,

,

.

, ,

Kernel. Windows .

++

Kernel

.

-

.

,

,

malloc())

.

, new)

++ ( . Win32 Win32 API.

(

, (

-

,

, ,

). . . .

– ,

Windows

.

-

,

, ,

,

(

-

),

.

Win32 ,

,

. -

, , Win32

( )

,

,

. ,

. –

(

).

, ), Kernel

(

. -

– .

,

,

,

, Kernel

.

.

, ,

(

),

12

.

4.2

(

User)

User : . Kernel ,

,

,

,

,

, User. , . User,

. , ,

,

GDI

-

,

-

. ,

,

,

. , .

,

,

User (MDI). User:



(

• • •

,

,

-

); ; ; . User ,

-

,

-

. SendMessage),

(

(PostMessage).

-

, -

.

, -

.

SendMessage

-

.

-

.

4.3

(

GDI)

GDI (Graphics Device Interface,

-

)

. .

,

-

. ( ,

,

-

.). (

,

,

. .)

, .

,

, .

,

Ellipse,

GDI ,

.

-

(

) 13

.

GDI

.

-

( ),

(

,

-

),

( ).

.

.

,

-

. GDI . . .

.

: . .

GDI:

,

,

,

,

. ,

. , -

GDI -

,

.

, . . .

-

, GDI ,

– DirectDraw API. ( ) Windows, . .

,



, (clipping). ( , -

, ). . 4.4

API

"

Windows ".



, API,



: . Windows 95.

,

-

. , ,

,

. • MAPI

. .

14

• DirectX API. . DirectX,

(

, Windows

) -

Microsoft .

DirectDraw , DirectSound . • ActiveX, COM OLE.

DirectX , DirectInput

-

Direct3D ,

-

. OLE, ( " Microsoft

OLE MS Word), ActiveX.

, " ActiveX

• TAPI

OLE, -

Windows. . ,

-

-

,

. Windows API , Windows), RAS (Remote Access Service, RPC ( ). API . MFC ++. API. , crosoft Windows , API – . dows ( , DirectX) API. ActiveX. ActiveX , OLE COM.

, WinSock (

)

MiWin-

4.5

Windows API ,

.

-

. GetLastError. 32winerror.h

API. SetLastError.

29-

. .

5. 5.1 Windows NT

Windows NT 4.0, Windows NT

Win32 API. , Windows 95. 15

WinNT Unicode, -

,

. WinNT 32-

Win95.

, WinNT . , WinNT WinNT

.

32

1

( API

-

). WinNT.

Kernel

NT Kernel .

,

,

,

. GDI WinNT

.

Win95

Win95

16Windows 3.1).

32-

-

( WinNT

, ,

,

.

5.2 Windows 95

Win95

WinNT, .

-

,

Win95 DirectX API Win95

Win95, . Unicode.

NT

, ,

WinNT Win95 Windows 3.1.

WinNT.



.

++.

Win95 ,

Visual C++ .

/

,

486.

Win95 , Visual C++,

,

WinNT.

32,

Win95. (

25 MHz 486 CPU, 8MB RAM

120MB HDD).

5.3

Windows NT DEC Alpha Intel.

PowerPC, API, Windows NT.

MIPS. , -

.

Visual C++, Windows NT

Visual C++ ,

. Win-

16

dows – Windows CE. , -

Windows CE , . ". Windows CE

Win32 API. ,

1997 . -

Windows CE – " -

Visual C++ for Windows CE. Windows 95.

Windows NT, 6.

32Windows dows 95/98/ME. – Win32 API. API. 32Windows

: Windows NT/2000 , Windows NT.

WinWin32 -

Visual C++. Windows

.

-

Windows .

,

-

. –

,

,

.

.



( . .

).

API.

-

. Windows, " "

" Windows,

.

" ,

: User (

), ,

Kernel (

. .

)

, -

GDI ( ). ,

, ActiveX, MAPI, ,

,

-

.

7.

1)

[9] C++

2, "

Windows".

Visual WM_... ,

winuser.h

MSG. Visual C++ WM_PAINT, WM_LBUTTONDOWN winuser.h. MSG . 3) Visual C++ , )", "Overview ( ".

2)

17

, wParam

"Quick Info (

lParam

-

API GetMessage. )" "Group (

,

GetKeyboardState

API 4) 5)

.

[1] [1]

.3,

2"

Win32.13,

". 6"

,

6)

, -

Spy++". -

Finder Tool . 1-

-

18

(

. CD-ROM).

Л

2.

Windows

1.

Windows-

"Hello, World!"

(

2.1),

, "Hello,

. 2.1, World!".

Windows-

. 2.1.

"Hello, World!"

#include int WINAPI WinMain( HINSTANCE d1, HINSTANCE d2, LPSTR d3, int d4 ) { MessageBox( NULL, "Hello, World!", "", MB_OK ); return 0; }

Windows-

2.1.

C

"Hello, World!".

" "Hello, World!"

.

"

. Windows-

-

.

, .

-

OK

.

,

OK, . ,

OK, ,

OK, . ),

, ( Alt+

.

-

.

Enter, Escape

-

? .

,

.

,

-

. . 2.

2.1 (

)

MessageBox.

, ,

, MessageBox.

19

,

. 2.2.

hello.cpp

World!" (

"Hello,

, ).

"Hello, World!"

. 2.2.

"

"

.

Windows

.

.

, , BUTTON (" .1.

,

-

").

, (

2.2).

#include int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE d2, LPSTR d3, int d4 ) { HWND hwnd; hwnd = CreateWindow( "BUTTON", "Hello, World!", WS_VISIBLE | BS_CENTER, 100, 100, 100, 80, NULL, NULL, hInstance, NULL ); MSG msg; while ( GetMessage( &msg, NULL, 0, 0 ) ) { if ( msg.message == WM_LBUTTONUP ) { DestroyWindow( hwnd ); PostQuitMessage( 0 ); } DispatchMessage( &msg ); } return msg.wParam; }

"Hello, World!"

2.2.

.

.

Windows API .

while,

– GetMessage. FALSE

WM_QUIT , WM_LBUTTONUP,

.

,

DestroyWindow WM_QUIT.

PostQuitMessage GetMessage WM_LBUTTONUP,

. DispatchMessage. DispatchMessage

, " BUTTON.

"

MessageBox,

"

,

, . .

" .

20

,

.1

, .

-

,

. . "Hello, World!", ,

.

3. hello.cpp (

2.3)

.

( ),

BUTTON

,

-

.

. 2.3.

"Hello, World!"

.

#include void DrawHello( HWND hwnd ) { PAINTSTRUCT paintStruct; HDC hDC = BeginPaint( hwnd, &paintStruct ); if ( hDC != NULL ) { RECT clientRect; GetClientRect( hwnd, &clientRect ); DPtoLP( hDC, (LPPOINT)&clientRect, 2 ); DrawText( hDC, "Hello, World!", -1, &clientRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); EndPaint( hwnd, &paintStruct ); } } LRESULT CALLBACK WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch(uMsg) { case WM_PAINT : DrawHello( hwnd ); break; case WM_DESTROY : PostQuitMessage( 0 ); break; default : return DefWindowProc( hwnd, uMsg, wParam, lParam ); } return 0; } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR d3, int nCmdShow ) { if ( hPrevInstance == NULL ) {

21

WNDCLASS wndClass; memset( &wndClass, 0, sizeof(wndClass) ); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WndProc; wndClass.hInstance = hInstance; wndClass.hCursor = LoadCursor( NULL, IDC_ARROW ); wndClass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 ); wndClass.lpszClassName = "HELLO"; if ( !RegisterClass( &wndClass ) ) return FALSE; } HWND hwnd; hwnd = CreateWindow( "HELLO", "HELLO", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL ); ShowWindow( hwnd, nCmdShow ); UpdateWindow( hwnd ); MSG msg; while( GetMessage( &msg, NULL, 0, 0 ) ) DispatchMessage( &msg ); return msg.wParam; }

"Hello, World!"

2.3.

"

.

60 (

" Windows-

, ,

. . 2.3),

,

,

,

-

Alt+F4. WinMain.

, , ,

.

. , WNDCLASS.

lpfnWndProc

.

WndProc.

,

.

CreateWindow

.

WinMain GetMessage FALSE WndProc

, WM_QUIT.

, "Hello, World!". switch.

-

, : WM_PAINT

. WM_DESTROY. WM_PAINT

. ,

.

,

WM_PAINT WM_DESTROY

, "Hello, World!". ,

. PostQuitMessage.

22

. .

,

-

GetMessage

WinMain

-

WM_QUIT

. ,

,

.

DefWindowProc

(

,

).

4. 4.1

RegisterClass

WNDCLASS

,

,

-

. : ATOM RegisterClass( CONST WNDCLASS* lpwc );

, lpwc, .

WNDCLASS,

Windows atom,

16-

, Windows.

WNDCLASS

: typedef struct _WNDCLASS { UINT style; WNDPROC lpfnWndProc; int cbClsExtra; int cbWndExtra; HANDLE hInstance; HICON hIcon; HCURSOR hCursor; HBRUSH hbrBackground; LPCTSTR lpszMenuName; LPCTSTR lpszClassName; } WNDCLASS;

.

, hIcon

-

,

-

, . hCursor –

; hbrBackground – (

GDI),

. C (

lpszMenuName

, MAKEINTRESOURCE), . lpszClassName cbClsExtra

. cbWndExtra

-

. ,

. WNDCLASS.

,

, .

(style)

(lpfnWndProc). 23

-



,

.

, -

, "

", DefWindowProc. :

,

,

,

,

, -

. . DefWindowProc, DefDlgProc.

"

– ,

"

. ,

. ,

style,

.

-

( , . .

|).

,

Windows,

CS_DBLCLKS

. CS_HREDRAW

,

CS_VREDRAW

.

4.2

CreateWindow

– CreateWindow.

, ,

,

. -

.

HWND CreateWindow( LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HANDLE hInstance, LPVOID lpParam );

lpClassName –

.

, ,

RegisterClass,

(

,

:

BUTTON, COMBOBOX, EDIT, SCROLLBAR, STATIC). dwStyle .

-

, WNDCLASS.

RegisterClass

-

,

.

,

CreateWindow,

. (

, dwStyle ,

, |).

). (

,

,

, .

,

BUTTON,

BS_PUSHBUTTON

WM_COMMAND. WS_POPUP

,

WS_OVERLAPPED WS_OVERLAPPED

24

. ,

-

.

WS_POPUP

,



. -

hwndParent.

. WS_CHILD.

-

, .

Windows , " " . WS_OVERLAPPEDWINDOW WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX WS_MAXIMIZEBOX. WS_POPUPWINDOW WS_POPUP, . WS_BORDER WS_SYSMENU. . 5.

GDI. ,(

, GetDC)

,

LineTo, Rectangle 5.1

GDI

TextOut.

WM_PAINT

,

WM_PAINT

-

.

-

WM_PAINT BeginPaint EndPaint. PAINTSTRUCT:

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

.

BeginPaint

WM_ERASEBKGND. BeginPaint WM_PAINT. EndPaint. hDC rcPaint -

BeginPaint

. ,

-

, ,

.

.

25

5.2 InvalidateRect

-

InvalidateRgn

"

".

Windows .

WM_PAINT

. ,

( -

. WM_PAINT rcPaint

PAINTSTRUCT)

. 6. Ч WM_PAINT,

-

.

.

WM_CREATE.

,

.

,

, .

CreateWindow

,

-

,

. WM_DESTROY.

, .

WM_CLOSE.

,

.

DefWindowProc

DestroyWindow. DestroyWindow WM_QUIT.

,

,

.

, .

FALSE,

GetMessage

. WM_QUIT

-

PostQuitMessage. WM_QUERYENDSESSION.

Windows

,

. Windows.

FALSE, WM_QUERYENDSESSION Windows WM_ENDSESSION

WM_QUERYENDSESSION. WM_ENDSESSION. WM_QUERYENDSESSION.

, . ,

Windows ,

WM_ENDSESSION

.

-

, .

WM_ACTIVATE.

, .

,

,

26

,

.

WM_SHOWWINDOW.

,

.

. .

ShowWindow

. WM_ENABLE.

,

. EnableWindow.

-

. WM_MOVE. WM_SIZE. WM_SETFOCUS.

. .

WM_SIZE

,

-

. . WM_KILLFOCUS.

. ,

.

WM_KILLFOCUS

WM_GETTEXT.

.

– ,

.

,

. .

,



. DefWindowProc. WM_SETTEXT.

,

,

,

.

-

WM_SETTEXT

.

DefWindowProc 7.

( . .,

hello.cpp) hello.cpp

. MessageBox.

. , MessageBox.

,

-

MessageBox,

,

. (

, )

,

-

, , . . . . .

hello.cpp

"Hello, World!"

( .

, . , . ,

.

27

-

. 2.4).

. , . . .

4-

2.4 GetMessage.

, WinMain,

DrawHello.

"Hello, World!".

. 2.4. #include

void AddSegmentAtMessagePos( HDC hDC, HWND hwnd, BOOL bDraw ) { DWORD dwPos; POINTS points; POINT point; dwPos = GetMessagePos(); points = MAKEPOINTS( dwPos ); point.x = points.x; point.y = points.y; ScreenToClient( hwnd, &point ); DPtoLP( hDC, &point, 1 ); if ( bDraw ) LineTo( hDC, point.x, point.y ); else MoveToEx( hDC, point.x, point.y, NULL ); } void DrawHello( HWND hwnd ) { if ( GetCapture() != NULL ) return; HDC hDC = GetDC( hwnd ); if ( hDC != NULL ) { SetCapture( hwnd ); AddSegmentAtMessagePos( hDC, hwnd, FALSE ); MSG msg; while( GetMessage( &msg, NULL, 0, 0 ) ) { if ( GetCapture() != hwnd ) break; switch ( msg.message ) { case WM_MOUSEMOVE : AddSegmentAtMessagePos( hDC, hwnd, TRUE ); break; case WM_LBUTTONUP: goto ExitLoop; default: DispatchMessage( &msg ); } } ExitLoop:

28

-

ReleaseCapture(); ReleaseDC( hwnd, hDC ); } } LRESULT CALLBACK WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch( uMsg ) { case WM_LBUTTONDOWN : DrawHello( hwnd ); break; case WM_DESTROY : PostQuitMessage( 0 ); break; default : return DefWindowProc( hwnd, uMsg, wParam, lParam ); } return 0; } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR d3, int nCmdShow ) { if ( hPrevInstance == NULL ) { WNDCLASS wndClass; memset( &wndClass, 0, sizeof( wndClass ) ); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WndProc; wndClass.hInstance = hInstance; wndClass.hCursor = LoadCursor( NULL, IDC_ARROW ); wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wndClass.lpszClassName = "HELLO"; if ( !RegisterClass( &wndClass ) ) return FALSE; } HWND hwnd; hwnd = CreateWindow( "HELLO", "HELLO", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); ShowWindow( hwnd, nCmdShow ); UpdateWindow( hwnd ); MSG msg; while ( GetMessage( &msg, NULL, 0, 0 ) ) DispatchMessage( &msg ); return msg.wParam; }

"Hello, World!".

2.4.

DrawHello

"Hello, World!"

,

.

. -

-

,

.

, . SetCapture.

,

Windows .

-

DrawHello AddSegmentAtMessagePos,

, ,

. 29

, GetMessagePos.

AddSegmentAtMessagePos

, ,

,

.

AddSegmentAtMessagePos

. ,

DrawHello

,

.

, AddSegmentAtMessagePos, WM_MOUSEMOVE.

TRUE

, ,

-

.

DrawHello WinMain.

?

-

WM_MOUSEMOVE

, . . 8.

Windows-

. (GetMessage

PeekMessage), DispatchMessage. RegisterClass. case

switch

-

,

.

" DefWindowProc (

" ).

DefDlgProc

,

. ,

GetMessage

-

-

PeekMessage.

: . .

9.

.

1)

Visual C++

-

Win32 Application 2.1.

2) 3)

, "Hello, World!"

2("

.

")

1),

BUTTON STATIC ("

4) 5) World!".

.

"Hello, World!". , ,

"). API, 4-

30

"Hello, ,

, API (

API

-

). 6)

,

3-

, 7)

4-

"Hello, World!" .

-

. 4-

"Hello, World!"

API

( POINT). WM_PAINT.

. DrawHello

.3

8)

WM_PAINT AddSegmentAtMessagePos WM_CLOSE,

.4. -

. : MessageBox( hwnd, "В "

?", ", MB_YESNO | MB_ICONQUESTION )

"

"

"

" ,

. IDYES

IDNO.

.

9)

-

2-

31

(

. CD-ROM).

Л

3.

Windows. Windows –

.

. -

,

, ,

Windows " –

: ",

"

" ,

,

.

,

, Windows

, .

Windows -

, -

:

-

,

. Windows

( ,

, Windows).

, HWND.

Windows .

,

.

-

(

-

, -

.

1. И

Windows ,

. :

/

/

.

).

,

Windows

. . ,

.

. 3.1

Windows. (Desktop Window) и

и (parent)

(parent)

и

(

)

и

(

В ц (owner)

и

) и

К

1

К

2

К (

)

Windows.

. 3.1.

32

-

. " Z,

-

". -

. (

. .,

. WM_EX_TOPMOST,

). ,

.

/

/

,

-

. / Z-

. -

,

.

-

/

. ( . .

-

),

.

Win32 API .

. .

GetDesktopWindow EnumWindows

.

-

. .

EnumWindows EnumChildWindows

,

. . EnumChildWindows ,

. .

. ,

EnumThreadWindows

.

. , .

,

-

. FindWindow

. GetParent

. -

GetWindow

.

, uCmd, , -

,

,

. 2. Д

,

.

, . , . 33

.

,

-

. . ,

.

. .

Win32 API

, .

,

-

. Windows

:

.

2.1

,

,

,

.

.

DialogBox.

(



)

.

) -

DialogBox

.

(

. DialogBox (

EndDialog

-

,

,

-

,

OK). .

, , Windows -

,

.

-

.

2.2

, .

-

, . . ,

-

. ,

. CreateDialog.

Win32 API

,

DialogBox

. IsDialogMessage.

, . 34

,

-

. SendMessage. EndDialog.

DestroyWindow,

, .

, . 2.3



,

-

, . (

,

,

, OK).

,

:

. MessageBox.

, . 2.4 Ш

, .

CreateWindow

. -

. , . ,

-

. .

MS Developer Studio

. 2.5



, .

, "

DefDlgProc,

,

"

DefWindowProc. WM_INITDIALOG

WM_COMMAND.

WM_INITDIALOG

. Windows WM_CREATE,

WM_INITDIALOG,

,

,

,

. , 35

.

)

WM_COMMAND.

( . . -

, ,

WM_COMMAND.

, .

3.

Win32 API

,

-

. Windows: ,

,

,

,

. : ,

-

API; -

. 3.1

,

,

.

-

, . (

. 3.2)

GetOpenFileName. OPENFILENAME.

– , -

,

, ,

-

. .

.

. 3.2.

(

. 3.3.

. 3.3)

36

.

GetSaveFileName. OPENFILENAME.

3.2

(

. 3.4)

.

ChooseColor,

, -

CHOOSECOLOR.

(

rgbResult)

.

.

. 3.4.

.

. 3.5.

3.3

( ,

. 3.5)

,

,

.

CHOOSEFONT. LOGFONT,

-

lpLogFont

. (

GDI) GDI – CreateFontIndirect.

LOGFONT 3.4

(

. 3.6)

. ,

. 3.6.

(

. 3.7).

.

. 3.7.

37

.

PrintDlg, PRINTDLG. PageSetupDlg, PAGESETUPDLG.

,

-

.

3.5

(

. 3.8)

(

. 3.9) ,

. .

, ,

-

, IsDialogMessage. FindText.

-

, IsDialogMessage. FINDREPLACE.

.

-

FindText,

-

RegisterWindowMessage "FINDMSGSTRING".

,

.

.

. 3.8.

(

.

. 3.9.

. 3.9)

-

FINDREPLACE. ReplaceText.

, FINDREPLACE,

Flags

,

. FindText ReplaceText.

, FINDREPLACE

. , .

38

-

4. Э

Э



,

-

,

-

. .

,

,

,

,

(

-

-

WM_COMMAND.

) Windows

. . 3.10.

-

. 3.10.

. 3.11.

Windows.

Windows 95.

Windows 95

,

,

Windows, . 3.11).

Windows 95 (

. " ( –

-

".

,

,

.)

.

CreateWindow.

, -

,

,

.

4.1

,

. ,

,

. -

.

4.2 К



,

.

. -

WM_COMMAND. К

: (

). К

– , .

39

. -

4.3 Э

,

-

. (

,

)

(

,

). ,

.

4.4

,

. .

,

, .

4.5 К

-

. , "

".

4.6

, ,

-

.

.

-

. ,

Windows 95

. 4.7

Windows 95

Windows 95, (

Э

"

Windows, . 3.11).

-

"

(

). )

, ( ,

. ,

, .

.

,

,

.

-

, . . . , . . , ,

, . 40

-

Э

"

"

-

.

-

, .

. .

,

-

-

. . -

,

-

.

Э

,

. Microsoft RTF (Rich Text Format). . Э " " . WM_SETHOTKEY.

,

-

Windows 95

"

", "

", "

", "

"

.

5.



,

-

. Windows .

.

,

,

, Windows

.

. –

-

. ,

,

,

. -

. (

).

,

Z-

,

,

. .

-

-

(

-

.

);

(

( Win32 API

)

). , .

.

Windows ,

: ,

.

,

. -

41

.

-

IsDialogMessage.

Windows , ,

,

, ,

. ,

, .

,

,

,

. Windows 95

:

,

,

,

,

,

, -

. . (

WM_COMMAND) 6.

1) 2)

-

( . .

).

.

-

№1, "

42

3( . CD-ROM). Windows" ( . CD-ROM).

,

Л

4.

MFC

1.

MFC

Microsoft Foundation Classes ( MFC) – ++, Microsoft Windows API. Windows, MFC , . MFC , Windows. MFC 200 , Windows: ActiveX. , – . MFC , CPoint . , , , CWnd Windows. MFC Windows API . MFC . MFC , API, API. SetWindowPos. , API MFC CWnd::SetWindowPos. MFC , . , Windows, , , . . , . MFC CWinApp. , , . MFC , Windows API. , " / " , API . API MFC. 1.1

++/MFC

/Windows API

Windows API

.

Windows

,

-

. switch,

.

-

: ,

. Windows

,

, . – . .

43

-

-

.

,

,

.

MFC CToolBar,

Windows, COM

,

ActiveX (

OLE)

. ,

.

MFC, – Windows (

,

,

,

.)

++.

1.2

MFC

MFC

Microsoft

-

: 1)

MFC API

-

Windows



.

2)

MFC

. ,

,

.

,

. MFC MFC –

,

,

. MFC

Windows.

-

– Windows ,

-

.

, HWND).

( CWnd. HWND.

-

MFC "

, .

CWnd CWnd::m_hWnd

HWND.

-

(

CWnd

"

.,

-

),

API,

. MFC Windows, . .

,

-

. 1.3

"

/

"

MFC "

/

".

, -

-

,

,

,

. MFC

CView. CDocument

CWinApp, CFrameWnd CView,

CDocument

. .

44

" ,

" MFC

,

/

/

",

, MFC. ( -

",

MFC). s"

/

". ,

. "

, . -

,

(

"

"),

"– ,

.

,

. MFC

"

/

,

"? ,

-

, ActiveX (

,

Internet Explorer). 1.4

/

.

MFC

MFC • • •

CObject.

:

CObject

(

); ; .

"

"

-

,

. ,

CObject

. ,

, MFC. (Run-time class information, RTCI)

RTCI (RTTI),

-

++. .

RTCI

CObject CObject

Visual C++. . CObject, Visual

CObject

, new

delete.

, C++

MFC

.

1.5

MFC

. ,

. Afx.

45

-

-

, -

, . . 4.1 AFX. AfxBeginThread AfxMessageBox AfxGetApp AfxGetMainWnd

MessageBox

.

. Windows API. -

,

,

. EXE-

AfxGetInstanceHandle

Windows API (

MFC

-

API). . 4.1.

AFX

AfxAbort

( )

AfxBeginThread AfxEndThread AfxMessageBox AfxGetApp AfxGetAppName AfxGetMainWnd AfxGetInstanceHandle AfxRegisterWndClass

Windows -

EXE-

WNDCLASS MFC

2.

MFC

, "Hello, world" – "Hello, MFC". WindowsMFC-

• • • 4.1

MFC: CWinApp

CPaintDC

CFrameWnd; WM_PAINT.

. Hello Hello.h

4.1 . .

.

Hello.cpp 4.1 .

-

Hello –

#if !defined( __HELLO_H ) # define __HELLO_H class CMyApp : public CWinApp { public: virtual BOOL InitInstance(); }; class CMainWindow : public CFrameWnd { public: CMainWindow(); protected:

46

Hello.h

afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() }; #endif

Hello –

4.1 . #include // #include "Hello.h"

Hello.cpp

CWinApp

MFC

CMyApp myApp; // CMyApp BOOL CMyApp::InitInstance() { m_pMainWnd = new CMainWindow; m_pMainWnd->ShowWindow( m_nCmdShow ); m_pMainWnd->UpdateWindow(); return TRUE; } // К CMainWindow BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd ) ON_WM_PAINT() END_MESSAGE_MAP() CMainWindow::CMainWindow() { Create( NULL, " }

Hello" );

void CMainWindow::OnPaint() { CPaintDC dc( this ); CRect rect; GetClientRect( &rect ); dc.DrawText("Hello, MFC", -1, &rect, DT_SINGLELINE ¦ DT_CENTER ¦ DT_VCENTER ); }

. 4.1.

Hello

Windows: , MFC"

,

, . .

Hello.

. 4.1.

47

"Hello,

2.1

-

MFC-



CWinApp. CWinApp

,

.

-

, . MFC

-

.

, . -

CMyApp.

Hello

:

Hello.cpp CMyApp myApp;

CMyApp

,

CWinApp –

.

InitInstance. InitInstance

.

MFCInitInstance.

CWinApp 2.2

-

InitInstance CWinApp::InitInstance

: return TRUE;

,

InitInstance

( ).

, InitInstance

/

.

(

FALSE)

. -

CMyApp::InitInstance CMainWindow, CWinApp::m_pMainWnd:

-

m_pMainWnd = new CMainWindow;

InitInstance CMainWindow:

-

m_pMainWnd->ShowWindow( m_nCmdShow ); // В m_pMainWnd->UpdateWindow(); //

ShowWindow

UpdateWindow

MFC,

CFrameWnd,

CMainWindow. ShowWindow

:

-

,

SW_SHOWNORMAL). CWinApp::m_nCmdShow, nCmdShow WinMain.

CWnd –

( Hello

ShowWindow

48

2.3

CWinApp InitInstance,

-

CWinApp

, .

CWinApp , WinHelp ProcessWndProcException,

,

. ExitInstance

( stance).

,

,

"

"

InitIn-

-

ExitInstance

,

, .

ExitInstance ExitInstance,

,

,

WinMain. CWinApp

OnIdle, Run

PreTranslateMessage. OnIdle

, "

,

.

.

".

"idle"

-

.

OnIdle

,

. -

Run

,

. ,

.

PreTranslateMessage 2.4

-

MFC

MFC-

Hello



. main,

Hello

WinMain.



-

.

,

, . MFC (

Winmain.cpp,

MFC–

Visual C++),

AfxWinMain. AfxWinMain

.

-

WinMain

-

,

( -

,

-

AfxWinMain). AfxWinMain AfxWinInit, hInstance, nCmdShow

-

AfxWinMain

.

-

InitInstance (InitApplication

-

InitApplication

32-

, InitApplication

Windows -

Windows 3.x). AfxWinInit, FALSE, AfxWinMain

InitInstance

. AfxWinMain

,

. 49

-

-

-

. .

Run

: pApp->Run();

WM_QUIT. Run AfxWinMain. return 2.5 К

"

-

ExitInstance

.

" CFrameWnd

MFC

CWnd.

,

,

. CMainWindow. CWnd.

Hello CFrameWnd,

,

"

CFrameWnd

-

,

".

-

, "

-

/

".

,

-

. MFC-

-

Hello CMainWindow

Create.

InitInstance,

CMainWindow

Windows,

-

CFrameWnd,

-

: Create( NULL, "

-

Hello" );

Create,

CMainWindow

: BOOL Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle = WS_OVERLAPPEDWINDOW, const RECT& rect = rectDefault, CWnd* pParentWnd = NULL, LPCTSTR lpszMenuName = NULL, DWORD dwExStyle = 0, CCreateContext* pContext = NULL )

,

Create

"

". .

(

6-

8-

-

Hello lpszClassName WNDCLASS),

Create

NULL, .

. .

, lpszWindowName

2.6

Windows, -

Hello WM_PAINT.

,

,

.

50

,

-

WM_PAINT. Hello CMainWindow::OnPaint, WM_PAINT.

WM_PAINT

"Hello, MFC"

.

CPaintDC:

CPaintDC dc( this );

MFC

CDC,

CPaintDC

Windows.

-

CDC

,

.

CPaintDC

CDC,

-

WM_PAINT.

Windows API

WM_PAINT ::BeginPaint

, .

, -

::EndPaint

Windows

.

WM_PAINT

::BeginPaint

::EndPaint,

Windows

WM_PAINT

. CPaintDC ::EndPaint –

,

::BeginPaint

. CPaintDC

OnPaint

-

CRect

CWnd::GetClientRect

: CRect rect; GetClientRect( &rect );

OnPaint

"Hello, MFC":

CDC::DrawText

dc.DrawText( "Hello, MFC", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );

DrawText –

.

:

,

(

),

RECT

,

.

,

4 -1, CRect

-

Hello

, ,

rect.

,

DrawText

. SetTextColor.

. .

CDC,

Hello

,

" ,

(

, SelectObject "(

, –

).

51

). DrawText

-

2.7 К



WM_PAINT, CMainWindow::OnPaint?

-

– .

Windows, -

,

-

-

,

Hello

,

MFC

WM_PAINT

OnPaint.

MFC

,

,

, .

-

CCmdTarget.

MFC

,

, MFC. 1)

, : -

DECLARE_MESSAGE_MAP.

2)

. END_MESSAGE_MAP.

BEGIN_MESSAGE_MAP

,

.

3)

Hello

. -

CMainWindow

, WM_PAINT,

:

BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd ) ON_WM_PAINT() END_MESSAGE_MAP()

BEGIN_MESSAGE_MAP,

-

.( .

,

, .).

END_MESSAGE_MAP BEGIN_MESSAGE_MAP END_MESSAGE_MAP . ON_WM_PAINT

.

-

MFC Afxmsg_.h. WM_PAINT. WM_PAINT

, -

OnPaint.

MFC WM_ACTIVATE

100

Windows,

WM_WININICHANGE. ON_WM

MFC,

WM_

, ,

.

OnPaint, WM_LBUTTONDOWN

On

-

, WM_PAINT . .

OnLButtonDown

MFC.

OnPaint

. OnLButtonDown

,

,

:

afx_msg void OnLButtonDown( UINT nFlags, CPoint point )

52

-

,

nFlags

,

Ctrl

Shift.

point

.

,

-

, lParam.

wParam

Windows API

wParam

-

lParam

. MFC ,

, . . .

,

,

MFC

-

? ON_MESSAGE.

: -

. -

WM_SETTEXT

,

OnSetText

: ON_MESSAGE( WM_SETTEXT, OnSetText )

-

:

OnSetText

afx_msg LRESULT OnSetText( WPARAM wParam, LPARAM lParam );

MFC

.

, ,

-

ON_COMMAND

.

ON_UPDATE_COMMAND_UI

.

. Hello. Hello.h:

OnPaint

-

CMainWindow

afx_msg void OnPaint(); DECLARE_MESSAGE_MAP()

,

afx_msg , OnPaint

-

. .

, . .

-

DECLARE_MESSAGE_MAP

, . .

++. DECLARE_MESSAGE_MAP, public, protected

private.

3.

MFC-

Hello. CWinApp. InitInstance.

MFC AfxWinMain Windows. -

InitInstance WM_PAINT InitInstance

-

AfxWinMain Run,

. MFC 53

, , ShowWindow UpdateWindow. -

-

WM_PAINT

-

CMainWindow::OnPaint,

DrawText

MFC, .

.

WinMain.

API.

,

"Hello, MFC". CPaintDC. Windows API, . Windows

MFC,

OnPaint

-

Hello

API,

MFC. MFC , . . . -

, MFC .

MFC Windows.

-

MFC Windows,

,

ActiveX

OLE.

4.

1)

, Visual C++

MFC"

" "Hierarchy Chart". Hello.

2) File⇒New Win32 Application

Visual C++ 1. 2.

: Projects. Project Name .

OK. 3.

:

Hello.h

File⇒New, . , Add To Project , . OK, . General. 4. Project⇒Settings Microsoft Foundation Classes Use MFC In A Shared DLL OK. MFC Use MFC In A Shared DLL , . . MFC DLL. Use MFC In A Static Library, Visual C++ EXEMFC, EXE. , , MFC, , , MFC DLL . Hello.cpp.

3)

" Windows" ( . CD-ROM). szMsg, nAge, cxLength, clrBtn? .

bRepaint,

-

54

4)

WinMain.cpp ( AfxWinMain goto? CWinThread::Run ( OnIdle ExitInstance.

5)

\DevStudio\Vc\Mfc\Src)

.2.4

.

CWinApp::Run ( ThrdCore.cpp) ,

AppCore.cpp)

-

Hello

. SetBkColor.

SetTextColor

COLORREF. RGB(r, g, b), ,

-

: RGB(255, 0, 0). 6)

,

Hello

-

Windows: WM_LBUTTONDOWN WM_RBUTTONDOWN WM_KEYDOWN WM_MOVE WM_SIZE WM_NCRBUTTONDOWN WM_CLOSE

.

AfxMessageBox CFrameWnd,

(

,

,

). -

-

CMainWnd

, (ON_WM_LBUTTONDOWN 7)

-

. .) 4-

55

(

. CD-ROM).

Л GDI

щ

5.

1. К

(MS-DOS),

, . . . -

. , A,

, , ,

B.

. Windows-

,

. Windows

GDI. -

-

, -

. "

. К

", –

GDI GDI

Windows, , -

. . GDI. , GDI .

, ,

GDI .

GDI

, . .

.

MFC . GDI

" – CDC. ( .

"

. 5.1).

5.1. CPaintDC CClientDC CWindowDC CMetaFileDC

(

OnPaint)

, GDI (

,

-

GDI

)

, GDI .

,

:

OnPaint CPaintDC dc(this); // В -

. -

-

,

CPaintDC

. CPaintDC WM_PAINT.

Windows 56

-

OnPaint.

,

-

. ,

WM_PAINT. CClientDC.

,

,

OnPaint.

-

CClientDC

,

CDC.

void CMainWindow::OnLButtonDown( UINT nFlags, CPoint point ) { CRect rect; GetClientRect(&rect); CClientDC dc(this); dc.MoveTo( rect.left, rect.top ); dc.LineTo( rect.right, rect.bottom ); dc.MoveTo( rect.right, rect.top ); dc.LineTo( rect.left, rect.bottom ); }

( ,

). CClientDC

.

CWindowDC,

-

,

:

CClientDC dc( NULL ); dc.Ellipse( 0, 0, 100, 100 );

1.1

, .

-

CDC

(

-

. 5.2).

5.2.

CDC

-

-

СDC

-

OPAQUE MM_TEXT

SetTextColor SetBkColor SetBkMode SetMapMode

GetTextColor GetBkColor GetBkMode GetMapMode

R2_COPYPEN (0,0) BLACK_PEN WHITE_BRUSH SYSTEM_FONT

SetROP2 MoveTo SelectObject SelectObject SelectObject

GetROP2 GetCurrentPosition SelectObject SelectObject SelectObject

-

CDC

,

,

(

,

. .) .

LineTo Rectangle

GDI .

, ,

.

57

.

-

. (

"

,

-

"):

dc.SetBkMode( TRANSPARENT );

SelectObject.

CDC

• • • • • •

"

"

GDI 6-

:

CPen, CBrush

CFont.

(pens) (brushes) (fonts) (bitmaps) (palettes) (regions). MFC

, " ":

"

":

1 ;

12

"

.

;

": ,

-

. ,

pBrush –

pPen

10

. -

:

dc.SelectObject( pPen ); dc.SelectObject( pBrush ); dc.Ellipse( 0, 0, 100, 100 );

-

-

SelectObject

GDI. ,

,

. 1.2

GDI – .



CDC.

, . – ( . .

). ,

Rectangle:

dc.Rectangle( 0, 0, 200, 100 );

, 100

200 .

100

200 .

MM_TEXT, 1

1( 1/10

. .

-

. 5.3).

. ,

MM_LOMETRIC 1

,

, -

Rectangle

20

10

. 58

.

,

MM_TEXT,

5.3.

, -

MM_TEXT MM_LOMETRIC MM_HIMETRIC MM_LOENGLISH MM_HIENGLISH MM_TWIPS MM_ISOTROPIC

GDI

, 1 0.1 0.01 0.01 0.001 1/1440

-

(0.0007

x x x x x x

)

, , , , , , -

(

x

y

x

y

-

) MM_ANISOTROPIC

( )

. 5.1. ( ,

MM_TEXT

, ).

,

.

,"

y

", ,

,1 y

-

, 1,

-

. (0, 0) x

1

=1

y

MM_TEXT.

. 5.1.

1.3

( )

CDC::LPtoDP.

-

CDC::DPtoLP.

,

.

, . . CWnd::GetClientRect:

CRect rect; GetClientRect( &rect ); CPoint point( rect.Width()/2, rect.Height()/2 );

MM_LOMETRIC DPtoLP: CRect rect; GetClientRect( &rect ); CPoint point( rect.Width()/2, rect.Height()/2 ); CClientDC dc( this ); dc.SetMapMode( MM_LOMETRIC );

59

dc.DPtoLP( &point );

LPtoDP

-

DPtoLP

. Windows .

,

"

"

MM_LOMETRIC,

. Windows"

"

"

".

, -

– .



,

. CWnd::ScreenToClient.

CWnd::ClientToScreen 1.4

. . . ,

,

. : CDC::SetWindowOrg ( )

-

CDC::SetViewportOrg (

). , .

(

,

dc –

CDC):

CRect rect; GetClientRect( &rect ); dc.SetViewportOrg( rect.Width()/2, rect.Height()/2 );

1.5

, .

CDC::GetDeviceCaps.

(

, 1024 768)

,

:

CClientDC dc( this ); int cx = dc.GetDeviceCaps( HORZRES ); int cy = dc.GetDeviceCaps( VERTRES );

. 5.4.

GetDeviceCaps 5.4.

GetDeviceCaps ,

HORZRES VERTRES HORZSIZE VERTSIZE LOGPIXELSX LOGPIXELSY NUMCOLORS

GetDeviceCaps , , , ,



,

TECHNOLOGY

, ,

– –

.

60

,

-

2.

GDI

2.1

(

)

5.5.

, 5.5.

-

CDC,

CDC

MoveTo LineTo Polyline PolylineTo

,

. .

Arc ArcTo PolyBezier PolyBezierTo

-

PolyDraw

:

LineTo dc.MoveTo( 0, 0 ); dc.LineTo( 0, 100 );

MoveTo

,

:

dc.MoveTo( 0, 0 ); dc.LineTo( 0, 100 ); dc.LineTo( 100, 100 );

Polyline PolylineTo ( , Polyline –

, ).

PolylineTo

,

:

POINT aPoint[5] = { 0, 0, 0, 100, 100, 100, 100, 0, 0, 0 }; dc.Polyline( aPoint, 5 );

PolylineTo: dc.MoveTo( 0, 0 ); POINT aPoint[4] = { 0, 100, 100, 100, 100, 0, 0, 0 }; dc.PolylineTo( aPoint, 4 );

CDC::Arc.

( , 100

). 200

:

CRect rect(0, 0, 200, 100); CPoint point1(0, -500); CPoint point2(-500, 0); dc.Arc(rect, point1, point2);

61

-

GDI . . .

,

(0, 0)

(100, 100): dc.MoveTo( 0, 0 ); dc.LineTo( 100, 100 );

(100, 100)

.

,

, CDC::SetPixel,

.

2.2

,

GDI

,

.

. 5.6. 5.6.

CDC

-

Chord Ellipse Pie Polygon Rectangle RoundRect

,

GDI,

, .

, ,

,

-

Ellipse

,

:

dc.Ellipse( 0, 0, 100, 100 );

CRect:

RECT

CRect rect( 0, 0, 100, 100 ); dc.Ellipse( rect );

, . . .

CDC::Rectangle:

dc.Rectangle( 0, 0, 8, 4 );

,

. 5.2.

. 5.2.

,

dc.Rectangle(0,0,8,4)

62

2.3

GDI

CPen

,

GDI

,

-

. 1

.

,

CDC::SelectObject.

MFC

GDI

CPen. CPen,

:

CPen pen( PS_SOLID, 1, RGB(255, 0, 0) );

: GDI

CPen,

CPen::CreatePen:

CPen pen; pen.CreatePen( PS_SOLID, 1, RGB(255, 0, 0) );

:

CPen, CPen::CreatePenIndirect

,

LOGPEN

GDI: CPen pen; LOGPEN lp; lp.lopnStyle = PS_SOLID; lp.lopnWidth.x = 1; lp.lopnColor = RGB(255, 0, 0); pen.CreatePenIndirect(&lp);

LOGPEN

POINT,

lopnWidth

, x

y

-

. TRUE,

CreatePen CreatePenIndirect (FALSE –

:

,

-

). .

. 5.3. PS_DASHDOT PS_DASHDOTDOT PS_NULL PS_INSIDEFRAME

PS_SOLID PS_DASH PS_DOT

.

. 5.3.

,

PS_INSIDEFRAME

. 100

,

-

20

PS_SOLID

120

. (

.

PS_INSIDEFRAME,

100

.

,

,

.

63

PS_INSIDEFRAME

.5.4). -

PS_INSIDEFRAME.

. 5.4.

(

PS_NULL

),

,

-

. .

PS_DOT, PS_DASHDOT

.

PS_DASH,

1

PS_DASHDOTDOT

0

,

-

1 . ,

.

,

10

,

-

: CPen pen( PS_SOLID, 10, RGB(255, 0, 0) ); CPen* pOldPen = dc.SelectObject( &pen ); dc.Ellipse( 0, 0, 100, 100 );

2.4 К

GDI

CBrush

(Rectangle, Ellipse . .)

. ,

. MFC

CBrush.

,

:

.

.

6

, (

. 5.5).

.

-

CBrush

.

.

. 5.5.

CBrush

: 64

-

CBrush brush( RGB(255, 0, 0) );

(

MFC,

GDI):

CBrush brush; brush.CreateSolidBrush( RGB(255, 0, 0) );

CBrush

,

:

CBrush brush( HS_DIAGCROSS, RGB(255, 0, 0) );

: CBrush brush; brush.CreateHatchBrush( HS_DIAGCROSS, RGB(255, 0, 0) );

GDI (

"

, /

OPAQUE

CDC::SetBkMode).

" CDC::SetBkColor TRANSPARENT

,

-

100

: CBrush brush( HS_DIAGCROSS, RGB (255, 255, 255) ); dc.SelectObject( &brush ); dc.SetBkColor( RGB(192, 192, 192) ); dc.Rectangle( 0, 0, 100, 100 );

2.5 CDC::DrawText.

,

,

,

.

,

, :

rect

dc.DrawText( "Hello, MFC", -1, &rect, DT_SINGLELINE ¦ DT_CENTER ¦ DT_VCENTER );

DrawText,

– -

CDC

.

. 5.7. TextOut,

DrawText,

.

:

dc.TextOut( 0, 0, "Hello, MFC" );

"Hello, MFC", dc.

,

-

TabbedTextOut

(

). ,

,

TextOut, TabbedTextOut

ExtTextOut,

.

, .

CDC::SetTextAlign,

,

:

dc.SetTextAlign( TA_RIGHT );

65

-

TextOut

,

SetTextAlign TextOut

TA_UPDATECP.

. . 5.7.

CDC

-

DrawText TextOut TabbedTextOut ExtTextOut

, -

GetTextExtent GetTabbedText Extent GetTextMetric s SetTextAlign

(

,

. .) TextOut

SetTextJustif ication SetTextColor SetBkColor

,

-

,

GetTextMetrics

GetTextExtent

,

. GetTextMetrics TEXTMETRIC. GetTextExtent (

GetTabbedTextExtent)

.

GetTextExtent –

, .

,

-

nWidth.

: CString string = " "; CSize size = dc.GetTextExtent( string ); dc.SetTextJustification( nWidth - size.cx, 3 ); dc.TextOut( 0, y, string );

.

-

(

-

SetTextJustification

.

-

SetTextJustification,

TextOut

, SetTextJustification', 2.6 Ш

GDI

-

CFont

. )

.

,

CDC



(

,

, 66

,

). –

-

.1 1/6

1/72 Windows " Courier New

,

.

12

. " . , Times New Roman . – GDI. MFC CFont. , CreateFont, CreateFontIndirect, CreatePointFont CreatePointFontIndirect GDI. CreateFont CreateFontIndirect , CreatePointFont CreatePointFontIndirect – . , 12Times New Roman CreatePointFont ( 1/10 ): CFont font; font.CreatePointFont( 120, "Times New Roman" );

, . .

CreateFont

-

, : CClientDC dc(this); int nHeight = -((dc.GetDeviceCaps(LOGPIXELSY)*12)/72); CFont font; font.CreateFont( nHeight, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH ¦ FF_DONTCARE, "Times New Roman" );

CreateFont

,

.

LOGFONT CreatePointFontIndirect,

:

LOGFONT lf; memset( &lf, 0, sizeof(lf) ); lf.lfHeight = 120; lf.lfWeight = FW_BOLD; lf.lfItalic = TRUE; strcpy( lf.lfFaceName, "Times New Roman" ); CFont font; font.CreatePointFontIndirect( &lf );

,

,

GDI

-

. GDI . 2.7

,

,

,

.

GDI

Windows

, GDI,

, GDI (

.

,

. 5.8).

CDC::SelectStockObject CPen, CBrush, . CGdiObject

CGdiObject::CreateStockObject. CPen, CBrush, CFont MFC-

, 67

GDI.

5.8.

GDI

NULL_PEN BLACK_PEN WHITE_PEN NULL_BRUSH HOLLOW_BRUSH BLACK_BRUSH DKGRAY_BRUSH GRAY_BRUSH LTGRAY_BRUSH WHITE_BRUSH ANSI_FIXED_FONT ANSI_VAR_FONT SYSTEM_FONT SYSTEM_FIXED_FONT

(

) 1 1

( ,

) NULL_BRUSH

ANSI ANSI , (

. . -

Windows)

,

,

-

.

:

CPen pen( PS_NULL, 0, (RGB (0, 0, 0)) ); dc.SelectObject( &pen ); CBrush brush( RGB(192, 192, 192) ); dc.SelectObject(&brush); dc.Ellipse( 0, 0, 100, 100 );

. .

-

GDI,

:

dc.SelectStockObject( NULL_PEN ); dc.SelectStockObject( LTGRAY_BRUSH ); dc.Ellipse( 0, 0, 100, 100 );

2.8

GDI

,

GDI

,

GDI,

.

GDI, CPen, CBrush, CFont

. .

GDI

CGdiObject

. new,

CGdiObject delete. CGdiObject,

GDI, " Visual C++ .

"

GDI,

CGdiObject::DeleteObject. CreateStockObject,

.

GDI,

-

new.

, :

Afxwin.h #define new DEBUG_NEW

, Visual C++.

GDI,

68

-

GDI .

,

, :

void CMainWindow::OnPaint() { CPaintDC dc( this ); CBrush brush( RGB(255, 0, 0) ); dc.SelectObject( &brush ); dc.Ellipse( 0, 0, 200, 100 ); }

, . .

, .

CBrush.

CPaintDC CBrush –

,

,

GDI .

dc.

,

, -

. ,

.

GDI

,

UnselectObject. CPaintDC

, GDI, :

-

,

GDI. , ,

GDI SelectObject.

,

, "

".

:

CPen pen( PS_SOLID, 1, RGB(255, 0, 0) ); CPen* pOldPen = dc.SelectObject(&pen); CBrush brush( RGB(0, 0, 255) ); CBrush* pOldBrush = dc.SelectObject( &brush ); dc.SelectObject( pOldPen ); dc.SelectObject( pOldBrush );

GDI

:

CPen pen( PS_SOLID, 1, RGB(255, 0, 0) ); dc.SelectObject( &pen ); CBrush brush( RGB(0, 0, 255) ); dc.SelectObject( &brush ); dc.SelectStockObject( BLACK_PEN ); dc.SelectStockObject( WHITE_BRUSH );

GDI

delete:

CPen* pPen = new CPen( PS_SOLID, 1, RGB(255, 0, 0) ); CPen* pOldPen = dc.SelectObject( pPen ); dc.SelectObject( pOldPen ); delete pPen;

3.

, –

Windows

. .

, ,

GDI

69

.

MFC

CDC,

Windows,

, CPaintDC, CClientDC, CWindowDC. -

. , , . ,

. -

(0, 0) x

,

y–

.

. ,

( ). GDI

:

,

,

CDC,

. Visual C++ -

. ,

,

,

– ,

-

GDI ( ). CGdiObject: CPen

.

CFont

, ,

GDI , CBrush GDI (

MFC , -

m_hObject).

GDI , . .

. GDI

.

4.

1)

,

, Hello (

OnPaint

). 2) 3)

-

5№2, "

70

( GDI" (

. CD-ROM). . CD-ROM).

-

Л

6.

.

Windows

. Windows

, -

, , .

WM_COMMAND

,

. .

.

,

.

. Windows

-

, API ( MFC),

. MFC-

. USER Windows (

,

-

). .

MFC -

.

-

. 1.

Windows

20 :

,

,

,

,

.

,

.

• • •

: ; ; .

Windows

(

,

). 1.1

,

6.1. , -

WM_LBUTTON, WM_RBUTTON – CWnd

, , WM_MBUTTON –

.

. 6.2.

71

6.1.

, К

WM_LBUTTONDOWN WM_LBUTTONUP WM_LBUTTONDBLCLK WM_MBUTTONDOWN WM_MBUTTONUP WM_MBUTTONDBLCLK WM_RBUTTONDOWN WM_RBUTTONUP WM_RBUTTONDBLCLK WM_MOUSEMOVE

(

WM_xBUTTONUP

)

WM_xBUTTONDOWN.

.

, ,

,

,

WM_LBUTTONDOWN.

.

, "

"

(

,

. .1.2).

6.2.

,

-

. WM_xBUTTONDOWN WM_xBUTTONUP WM_xBUTTONDBLCLK WM_MOUSEMOVE

ON_WM_xBUTTONDOWN ON_WM_xBUTTONUP ON_WM_xBUTTONDBLCLK ON_WM_MOUSEMOVE

OnxButtonDown OnxButtonUp OnxButtonDblClk OnMouseMove

, OnLButtonDown,

,

:

afx_msg void OnMsgName( UINT nFlags, CPoint point )

.

point

, .

CDC::DPtoLP.

nFlags

Shift

.

Ctrl

-

nFlags

,

. 6.3. 6.3.

,

nFlags К

MK_LBUTTON MK_MBUTTON MK_RBUTTON MK_CONTROL MK_SHIFT

Ctrl Shift

,

,

,

NC (

72

nonclient).

,

WM_LBUTTONDOWN – WM_NCLBUTTONDOWN.

. 1.2

,

,

-

.

( "

").

,

, .

"

,

(

. "

Windows )

,

-

,

"

.

,

"

.

,

,

. "

"

-

. CWnd::SetCapture,



API ::ReleaseCapture. , // ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP()

:

CMainWindow

void CMainWindow::OnLButtonDown( UINT nFlags, CPoint point ) { SetCapture(); } void CMainWindow::OnLButtonUp( UINT nFlags, CPoint point ) { ::ReleaseCapture(); }

, CMainWindow WM_MOUSEMOVE,

.

-

. CWnd

, NULL,

(

CWnd::GetCapture, CWnd). Win32 GetCapture

. ,

GetCapture

,

-

: if ( GetCapture() == this )

1.3 WM_SETCURSOR,

. .

::SetCursor

73

,

CMainWindow::m_hCursor. CMainWindow : // ON_WM_SETCURSOR()

-

CMainWindow

BOOL CMainWindow::OnSetCursor( CWnd* pWnd, UINT nHitTest, UINT message) { if ( nHitTest == HTCLIENT ) { ::SetCursor( m_hCursor ); return TRUE; } return CFrameWnd::OnSetCursor( pWnd, nHitTest, message ); }

,

,

-

Developer Studio. (

,

IDC_CROSS)

IDC_ARROW CWinApp::LoadStandardCursor,

.

:

AfxGetApp()->LoadStandardCursor( IDC_ARROW );

-

,

Windows. CWinApp::LoadStandardCursor.

-

CWinApp::LoadCursor

, Developer Studio.

,

,

"

".

IDC_WAIT. LoadStandardCursor –

, MFC CWaitCursor. ,

:

CWaitCursor wait;

CWaitCursor

,

.

CWaitCursor,

-

-

CWaitCursor::Restore.

,

.

2.

Windows :

, .

,

.

,

, ,

. "

. 74

".

-

" . , PgUp,

,

"

,

WM_KEYDOWN/WM_KEYUP

, ,

.

-

,

/

,

WM_CHAR,

.

-

,

Shift Windows .

Caps Lock.

caret.. , (

,

WM_SETFOCUS)

(WM_KILLFOCUS). CWnd , , ShowCaret ( ) SetCaretPos ( ,

), HideCaret (

-

). .

2.1

Windows

, ,

,

WM_KEYDOWN

WM_KEYUP.

F10 – "

"

Alt

-

,

Windows

.

WM_SYSKEYDOWN

WM_SYSKEYUP. WM_SYSKEYDOWN

Alt WM_SYSKEYUP (

WM_KEYDOWN/WM_KEYUP). MFC OnKeyDown,

OnKeyUp, OnSysKeyDown OnSysKeyUp ( ON_WM_KEYDOWN, ON_WM_KEYUP, ON_WM_SYSKEYDOWN

ON_WM_SYSKEYUP).

,

. :

afx_msg void OnMsgName( UINT nChar, UINT nRepCnt, UINT nFlags )

nChar –

,



, nRepCnt

/ 1

(

1

WM_KEYUP).

.

nRepCnt

-

nFlags

,

WM_KEYDOWN

-

,

,

Alt.

,

. ASCII, A

,

0x41

0x5A

-

Z.

Winuser.h.

VK_ (

.

. 6.4).

6.4. К VK_F1 VK_F12

-

К

-

VK_NEXT F1 - F12

75

-

PgDn

К

-

VK_CANCEL VK_RETURN VK_BACK VK_TAB VK_SHIFT VK_CONTROL VK_MENU VK_PAUSE VK_ESCAPE VK_SPACE VK_PRIOR

К

-

-

-

VK_END VK_HOME VK_LEFT VK_UP VK_RIGHT VK_DOWN VK_INSERT VK_DELETE VK_CAPITAL VK_NUMLOCK VK_SCROLL

Ctrl-Break Enter Backspace Tab Shift Ctrl Alt Pause Esc Spacebar PgUp

End Home

Ins Del Caps Lock Num Lock Scroll Lock

2.2

Shift, Ctrl

Alt.

::GetKeyState.

,.

,

,

:

Shift,

::GetKeyState( VK_SHIFT )

,

,

Shift

– ). ,

( Ctrl+ :

OnKeyDown

if ( (nChar == VK_LEFT) && (::GetKeyState(VK_CONTROL) < 0) ) { }

-

::GetKeyState

. ,

,

, ::GetAsyncKeyState.

2.3

/

-

, .

Caps Lock, Shift WM_CHAR. WM_KEYDOWN/WM_KEYUP

Windows ::TranslateMessage.

-

MFC. WM_CHAR

-

ON_WM_CHAR

:

OnChar

afx_msg void OnChar( UINT nChar, UINT nRepCnt, UINT nFlags )

nRepCnt

nFlags

,

WM_KEYDONW/WM_KEYUP.

, ,

Enter 76

Backspace:

-

// ON_WM_CHAR()

CMainWindow

void CMainWindow::OnChar( UINT nChar, UINT nRepCnt, UINT nFlags ) { if ( ( (nChar >= `A') && (nChar > m_strPhone; }

113

m_strPhone.

}

( , CString,

,

/

CArchive

) –

Serialize >.

CArchive::Read CArchive::Write. ReadString WriteString

,

-

CArchive

).

( -

CArchive CArchive::GetFile

, CFile,

,

CArchive.

,

CDocument OnCloseDocument (

)

, -

OnSaveDocument (

). 4. К

-

-



.

-

: ( )

,

.

,

,

-

. MFC ,

,

CView, CScrollView

C -

CView.

-

-

.

,

-

. -

-

m_pDocument

.

-

GetDocument.

,

GetFirstViewPosition

4.1 Ви

GetNextView, GetDocument.

ции CView CDocument,

-

CView

OnDraw, WM_PAINT. WM_PAINT

( -

. 9.3).

,

/ OnPaint

CPaintDC.

-

, 114

,

OnDraw.

-

:

, -

/ .

WM_PAINT CPaintDC OnDraw

MFC -

,

void CMyView::OnDraw( CDC* pDC ) { CMyDoc* pDoc = GetDocument(); CString string = pDoc->GetString(); CRect rect; GetClientRect( &rect ); pDC->DrawText( string, rect, DT_SINGLELINE ¦ DT_CENTER ¦ DT_VCENTER ); }

,

,

OnDraw

,

.

9.3.

CView

OnDraw OnInitialUpdate

-

. .

-

-

. OnUpdate

, "

.

"

-

,

,

,

-

, .

-

, ,

-

, ,

OnDraw

,

, -

. . . . .

OnDraw

/



CView OnUpdate.

OnInitialUpdate

,

,

SDI.

SDI-

,

OnInitialUpdate

.

OnUpdate,

OnInitialUpdate

OnUpdate

-

. -

OnInitialUpdate

-

, -

, .

,

CScrollView SetScrollSizes

-

OnInitialUpdate

.

-

OnInitialUpdate

,

-

. ,

OnUpdate

-

,

(

-

)

UpdateAllViews. OnUpdate

,

.

MDI-

, ,

.



.

,

, CView::OnActivateView.

CFrameWnd::GetActiveView

CFrameWnd::SetActiveView.

115

-

-

5. К

"

-

"

.



: ,

-

, .

-

-

MDICMDIChildWnd

. -

OnClose

.

– CMDIFrameWnd / ,

, /

SDI-

CFrameWnd,

-

-

. -

.

,

CFrameWnd

OnQueryEndSession,

Windows.

-

CFrameWnd

-

, .

-

,

-

,

. CFrameWnd CWnd. Windows. CFrameWnd

CWnd –

++ ,

CWnd

/

.

6. Д

,

-

, MFC

,



(dynamic creation). MFC



DECLARE_DYNCREATE

IMPLEMENT_DYNCREATE.

1) 2)

: CObject. DECLARE_DYNCREATE.



.

3)

IMPLEMENT_DYNCREATE

– . : RUNTIME_CLASS( CMyClass )->CreateObject();

new.

, ,

++ -

,

CString strClassName = "CMyClass"; CMyClass* ptr = new strClassName; //

: CMyClass

MFC , . 116

-

:

DECLARE_DYNCREATE CRuntimeClass, GetRuntimeClass CreateObject.

,

-

: DECLARE_DYNCREATE( CMyClass )

++

:

public: static const AFX_DATA CRuntimeClass classCMyClass; virtual CRuntimeClass* GetRuntimeClass() const; static CObject* PASCAL CreateObject();

IMPLEMENT_DYNCREATE CRuntimeClass ( GetRuntimeClass IMPLEMENT_DYNCREATE :

)

,

CreateObject.

IMPLEMENT_DYNCREATE( CMyClass, CBaseClass )

:

CreateObject CObject* PASCAL CMyClass::CreateObject() { return new CMyClass; }

6.1

SDI-

CWinApp::InitInstance CSingleDocTemplate – SDICSingleDocTemplate 4 : (IDR_MAINFRAME) RUNTIME_CLASS.

• • • •

.

.

-

, (

)

: ;

; ; (document string), " "

,

,

"

"

. SDI-

-

, -

.

,

LoadFrame.

,

. LoadFrame RC(AppWizard

, ). "\n".





-

"

, "

-

: -

.

,

,

"Microsoft Draw".

,

. "\n"),

( "Untitled".

117

-



File⇒New



, MDI.

, SDI-

. ,

, "Drawing

Files (*.drw)".

• •

. "

",

, ".drw".

,

,

"Draw.Document". ShellFileTypes

,

CWinApp::Register-

Windows,. -

HKEY_CLASSES_ROOT



. ,

, "Microsoft Draw Document". . CWinApp::RegisterShellFileTypes, ( , ). , , "\n". AppWizard Advanced Options, (AppWizard's Step 4). SDIRC:

4-

STRINGTABLE BEGIN IDR_MAINFRAME "Microsoft Draw\n\n\nDraw Files(*.drw)\n.drw\n Draw.Document\nMicrosoft Draw Document" END

-

"Untitled

- Microsoft Draw". – ".drw", "Draw Files (*.drw)".

"

"

7.

/ ". К

" (command messages)

MFC

,

WM_COMMAND,

-

, .

-



,

-

-

.

-

. , ,

-

,

.

, , ON_UPDATE_COMMAND_UI

118

-

.

MFC.

-

WM_COMMAND, CCmdTarget CFrameWnd OnCmdMsg

.

-

OnCmdMsg,

:

BOOL CFrameWnd::OnCmdMsg(...) { // CView* pView = GetActiveView(); if ( pView != NULL && pView->OnCmdMsg(...) ) return TRUE; // if ( CWnd::OnCmdMsg(...) ) return TRUE;

-

// , CWinApp* pApp = AfxGetApp(); if ( pApp != NULL && pApp->OnCmdMsg(...) ) return TRUE;

-

return FALSE; }

,

. .

FALSE

CFrameWnd::OnCmdMsg ::DefWindowProc

,

"

, ?

".

, -

-

,

,

-

-

,

-

.

CFrameWnd::OnCmdMsg

OnCmdMsg

,

. ,

-

-

.

OnCmdMsg

,

-

.

SDI-

,

,

. 9.2.

,

,

,

,

::DefWindowProc.

,

,

, File⇒New, File⇒Open , File⇒Exit OnFileNew, OnFileOpen OnAppExit. File⇒Save File⇒Save As " " CDocument::OnFileSave CDocument::OnFileSaveAs. / CFrameWnd, . , , /

.

,

. WM_CREATE

Windows,

, WM_CHAR, WM_LBUTTONDOWN, . , -

WM_SIZE



-

.

-

,

. 119

,

. 9.2.

-

SDI-

.

7.1

/ MFC File⇒Open

CFrameWnd

, ID_FILE_OPEN

. CWinApp, CDocument, " " , ". " ?" , ID_APP_EXIT -

File⇒Save. "

ID_FILE_SAVE

. 9.4 . , . , : ON_COMMAND( ID_APP_EXIT,

WinApp::OnAppExit )

9.4. "

"

?

ID_FILE_NEW ID_FILE_OPEN ID_FILE_SAVE ID_FILE_SAVE_AS ID_FILE_PAGE_SETUP ID_FILE_PRINT_SETUP ID_FILE_PRINT ID_FILE_PRINT_PREVIEW ID_FILE_SEND_MAIL ID_FILE_MRU_FILE1_ ID_FILE_MRU_FILE16 ID_APP_EXIT

New Open Save Save As Page Setup Print Setup Print Print Preview Send Mail N/A

CWinApp::OnFileNew CWinApp::OnFileOpen CDocument::OnFileSave CDocument::OnFileSaveAs

Exit

CWinApp::OnAppExit

ID_EDIT_CLEAR

Clear

N/A CWinApp::OnFilePrintSetup CView::OnFilePrint CView::OnFilePrintPreview CDocument::OnFileSendMail CWinApp::OnOpenRecentFile

N/A

120

" ID_EDIT_CLEAR_ALL ID_EDIT_CUT ID_EDIT_COPY ID_EDIT_PASTE ID_EDIT_PASTE_LINK ID_EDIT_PASTE_SPECIAL ID_EDIT_FIND ID_EDIT_REPLACE ID_EDIT_UNDO ID_EDIT_REDO ID_EDIT_REPEAT ID_EDIT_SELECT_ALL

"

? N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A

Clear All Cut Copy Paste Paste Link Paste Special Find Replace Undo Redo Repeat SelectAll

ID_VIEW_TOOLBAR CFrameWnd::OnBarCheck Toolbar ID_VIEW_STATUS_BAR CFrameWnd::OnBarCheck Status Bar ( MDI ) ID_WINDOW_NEW CMDIFrameWnd::OnWindowNew New Window ID_WINDOW_ARRANGE CMDIFrameWnd::OnMDIWindowCmd Arrange All ID_WINDOW_CASCADE CMDIFrameWnd::OnMDIWindowCmd Cascade ID_WINDOW_TILE_HORZ Tile Horizontal CMDIFrameWnd::OnMDIWindowCmd ID_WINDOW_TILE_VERT CMDIFrameWnd::OnMDIWindowCmd Tile Vertical ID_APP_ABOUT

N/A

About AppName

MFC : • CFrameWnd::OnUpdateControlBarMenu ID_VIEW_TOOLBAR ID_VIEW_STATUS_BAR; • CMDIFrameWnd::OnUpdateMDIWindowCmd . • CDocument::OnUpdateFileSendMail ID_FILE_SEND_MAIL. CEditView CRichEditView , ( ). . . , .

121

. .

-

Л 1) Microsoft Corporation. : " ", 2000. (

Microsoft Visual C++ 6.0. Microsoft MFC

2) 3)

4)

5)

6)

7)

8)

9)

. Visual C++ 6. ,

.: -

Visual C++). Petzold C. Programming Windows. Microsoft Press. 1990. ( , Windows API) Prosise J. Programming Windows with MFC. Microsoft Press. 1999. ( , Petzold' , Windows MFC. ). Toth V. Visual C++ 4 Unleashed. Sams Publishing, 1996 ( Windows Visual C++ 4.0. . Windows ). . Windows 2000 . : , 2001. ( , Windows 2000 API – COM, , . COM, , .) ., ., . Microsoft Visual C++ 6.0 . : , 2000. ( , . Visual C++ MFC.) . ., . . , . .: " ", 2000. ( . CD-ROM , .) . Windows : Win3264Windows. : , 2001. ( , 32Windows 95/NT/2000 API.) . . MFC. : – , 2000. ( MFC, .)

122

-

. .

, . .

++ 4-

(

. )

. . . . 12.04.2002 60 84 1/16 . . 20,5 №06076 19.10.2001 140410 .

, .

.

.,

.

16.04.2002 -

, 30.

123

. . ____

100

-

124