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


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


WndClass.cbClsExtra = 0;

WndClass.cbWndExtra = 0;

WndClass.hlnstance = hlnstance ;

WndClass.hlcon - Loadlcon (NULL,IDI_APPLICATION);

WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);

WndClass.hbrBackground = (HBRUSH) GctStockObjcct (WHITEJ3RUSH);

WndClass.IpszMenuName = "MyMenu";

WndClass. IpszClassName szClassNamc;

50

il'( !RegisterClass(&WndClass) )

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

hWnd = CreateWindow(szClassNamc, "Program No 1", WS_OVERLAPPEDWINDOW | WS_VSCROLL| WS_HSCROLL, CWJJSEDEFAULT, CWJJSEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hlnstance.NULL);

il'(!hWnd)

MessageBox(NULL,"Cannot create window","Error",MB_OK); return 0;

/* Show our window */ ShowWindow(hWnd,nCmdShow); UpdatcWindow(hWnd);

/* Beginning of messages cycle */

whilc(GctMcssage(&Msg, NULL, 0, 0))

TranslatcMessage(&Msg); DispatchMessage(&Msg);

return Msg.wParam;

LRESULT CALLBACK DCDcmoWndProc (HWND hWnd. UINT Message,

UINT wParam, LONG IParam )

HOC hDC, hCompatibleDC;

PAINTSTRUCT PamtStruct;

static HANDLE hBitmap;

HANDLE hOldBitmap;

RECTRect;

BITMAP Bitmap;

static int nliorizDifference = 0, nVertDilTerence ~ 0;

static int nHorizPosition = 0, nVertPosition - 0;

switch(Messagc) i

case WM CREATL:

hBitmap =• LoadlmagcfNULL, "MSDOGS.BMP" IMAGE_BITMAP,

51

о, о,

LR_LOADFROMFILE); return 0;

case WM_PAINT:

hDC ^ BeginPaint(hWnd, &PaintStruct); GetObject(hBitmap, sizeof(BITMAP), &Bitmap); hCompatibleDC = CreateCompalibleDC(hDC); hOldBitmap = SelectObject(hCompatibleDC, liBitmap); GctClientRcct(hWnd,&Rcct); BitBltdiDC, 0, 0, Rect.right, Rect.bottom,

hCompatibleDC, nHorizPosition, nVertPosilion, SRCC'OPY); if( (nHorizDii'terence = (Bitmap.bmWidth - Rect.right)) > 0)

SetScrollRange(hWnd, SBJTORZ, 0, nHonzDifference, TRUE); else

SctScrollRange(liWnd, SBJIORZ, 0. 0, TRUE); if( (nVertDifference = (Bitmap.bmHeight - Rect.bottom)) > 0)




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



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