Вы находитесь на странице: 1из 7

ATI

: PW

1
: WINDOWS

:
TI 095 .
:

2011

1
.
: .
1 .
.

-,

,

.
Windows , Windows
, .
,
.
, Windows,
, . Windows
, (Graphics
Device Interface, GDI), . Windows
. ,
Windows, ,
Windows.
.
, .
- , ,
Windows, .
- , .
, ,
, .

3
.
.

Windows MS-DOS:
Win32 :

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int


iCmdShow),
HINSTANCE hInstance - (instance handle),
HINSTANCE hPrevInstance - (previous instance),
PSTR szCmdLine - ,
,
int iCmdShow , ,

,
( ).
WndProc
. WinMain
:
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

WNDCLASSEX wndclass

, :
:
wndclass.cbSize = sizeof(wndclass);

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

wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
,
Windows.
, 0.
:
wndclass.hInstance = hInstance;
,
:
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);


,
:
wndclass.hbrBackground =(HBRUSH) GetStockObject(WHITE_BRUSH);
.
NULL:
wndclass.lpszMenuName = NULL;
. ,
szAppName:
wndclass.lpszClassName = szAppName;
wndclass
RegisterClassEx(&wndclass)
:
hwnd = CreateWindow(
szAppName, //
"The Hello Program", //
WS_OVERLAPPEDWINDOW, //
CW_USEDEFAULT, //
CW_USEDEFAULT, //
CW_USEDEFAULT, //
CW_USEDEFAULT, //
NULL, //
NULL, //
hInstance, //
NULL
); //
2 :
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
hwnd
iCmdShow. WM_PAINT WndProc
hwnd.
:
while(GetMessage(&msg,NULL,0,0)){
TranslateMessage(&msg);

DispatchMessage(&msg);
}

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

(TranslateMessage(&msg))
(DispatchMessage(&msg)).
WndProc ,
WM_PAINT WM_DESTROY. WM_PAINT
, .
" 1 -084
" , :
DrawText (hdc, " 1 -084
", -1, &rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
WM_DESTROY
WM_QUIT :
PostQuitMessage (0) ;

,
.
, ,
.
.

1) Windows 95. 1.
2) . UTM.

//--------------------------------------------------------------------------#include <windows.h>
#include <vcl.h>
//--------------------------------------------------------------------------LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPSTR szCmdLine,int iCmdShow){
static char* szAppName[]={"Hello World"};
WNDCLASSEX wndclass;
MSG msg;
HWND hwnd;
wndclass.cbSize

= sizeof (wndclass) ;

wndclass.style

= CS_HREDRAW | CS_VREDRAW ;

wndclass.lpfnWndProc

= WndProc;

wndclass.cbClsExtra

= 0 ;

wndclass.cbWndExtra

= 0 ;

wndclass.hInstance

= hInstance ;

wndclass.hIcon

= LoadIcon (NULL, IDI_APPLICATION) ;

wndclass.hCursor

= LoadCursor (NULL, IDC_ ARROW) ;

wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;


wndclass.lpszMenuName

= NULL ;

wndclass.lpszClassName = *szAppName ;
wndclass.hIconSm

= LoadIcon (NULL, IDI_APPLICATION) ;

RegisterClassEx (&wndclass) ;
hwnd

CreateWindow

(*szAppName,"The

Hello

Program

",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NU
LL,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_PAINT :
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
DrawText (hdc, " 1 -095
", -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) ;
}
//---------------------------------------------------------------------------

Вам также может понравиться