Азбука программирования в Win32 API


Азбука программирования в Win32 API - стр. 57


^include <windows.h>

LRESULT CALLBACK GraphDemoWndProc ( HWND, UINT, UINT, LONG );

hit WINAPI WinMain (HINSTANCE hlnstancc, HINSTANCE hPrevInstance, LPSTR IpszCmdParam, int nCmdShow )

HWND hWnd ;

WNDCLASS WndClass ;

MSG Msg;

char szClassName[] = "GraphDcmo";

/* Registering our window class */ /* Fill WNDCLASS structure */

WndClass.style - CSJHREDRAW | CS_VREDRAW;

WndClass.IpfnWndProc = GraphDemoWndProc;

WndClass.cbClsExtra = 0;

WndClass.cbWndExtra = 0;

WndClass.hlnstancc = hlnstance ;

WndClass.hlcon = Loadlcon (NULL.IDIJVPPLTCATION);

WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);

WndClass.hbrBackground - (HBRUSH) GetStockObject (WHITE_BRUSH);

WndClass.lpszMenuName = NULL;

WndClass.IpszClassName — szClassName;

if ( !RegisterClass(&WndClass))

I (

MessageBox(NULL."Cannot register class","Error",MB_OK); return 0;

hWnd = CreateWindow(szClassName, "Graph Demo",

WS_OVERLAPPEDWINDOW, CW USEDEFAULT. CWJJSEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hlnstance.NULL);

if(!hWnd) >

MessageBoxfNULL,"Cannot create window","Error",MB_OK); return 0;

66

/* Show our window */

ShowWmdow(hWnd,nCmdSho\v);

UpdateWindovv(hWnd);

/* Beginning of messages cycle */

whilc(GetMcssage(&Msg, NULL, 0, 0)) i

TranslateMessage(&Msg); DispatchMessage(&Msg); i return Msg.vvParam;

LRESULT CALLBACK GraphDemoWndProc (HWND hWnd, UtNT Message,

UINT wParam, LONG IParam )

HDC hDC, hCompatibleDC;

PAINTSTRUCT PaintStruct;

RFXT Reel;

HBITMAP hCompatibleBitmap, hOldBitmap;

HPENhOldPen;

static HPENPens[5];

HBRUSH hOklBnish;

static HBRUSH Brushcs[6];

int i;

swilch(Message)

case WM_PAINT: randomizcf); for(i = 0; i <=• 4; j-r~) {

Pcnsfil = (CreatePen(i, 1, RGB(random(255),random(255), random(255)))); Bnishesfil - (CreateHa(cliBrush(i, RCiB(random(255), random(255),

random(255))));

GetClientRect(h\Vnd. &Recl);

hDC - BeginPaint(hWnd, &PamtSiruct);

hCompatiblcDC - CreatcCompatibleDC(hDC);




Начало  Назад  Вперед



Книжный магазин