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


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


WS_VISIBLE, 0,129, 150,12

ListBoxMenu MENU

{ POPUP "&File"

{ MENUITEM "E&xit", IDM_Exit

} MENUITEM "&Display Dialog", IDM_DisplayDialog

}

Далее следует файл заголовков, также используемый в программе:

#defme IDM_Exit 101

#defme IDM_CanceI 102

#define IDM_DisplayDialog    103

#defmeID_OK 201

#defme ID_Cancel 202

«define ID_MyListBox 203

#defme ID_StatusBar 204

И, наконец, основной файл программы:

#include <windows.h>

#include "list.h" ^include <commctrl.h>

HINSTANCE hlnst;

LRESULT CALLBACK ListBoxExampleWndProc(HWND, U1TMT, UINT, LONG);

126

BOOL CALLBACK ListBoxExampleDialogProc(HWND, UINT, WPARAM,

LPARAM);

int WINAPI WinMain (HINSTANCE hlnstance, HINSTANCE hPrevInstance,

LPSTR IpszCindParam, int nCmdShow ) {

HWND hWnd ; WNDCLASS WndClass ; MSG Msg; char szClassName[] = "ListExample";

hlnst= hlnstance;

InitCommonControls(); /* Registering our window class */ /* Fill WNDCLASS structure */

WndClass.style - CS_HREDRAW | CS_VREDRAW;

WndClass.IpfnWndProc = ListBoxExampleWndProc;

WndClass.cbClsExtra = 0;

WndClass.cbWndExtra = 0;

WndClass.hlnstance = hlnstance ;

WndClass.hlcon = Loadlcon (NULL,IDI_APPLICATION),

WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);

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

WndClass.IpszMenuName = "ListBoxMenu";

WndClass.IpszClassName = szClassName;

if ( !RegisterClass(&WndClass)) !

MessageBox(NULL,"Cannot register class","Error",MB_OK); return 0; } hWnd = CreateWindow(szClassName, "ListBox Example Program",

WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT, CWJJSEDEFAULT, CWJJSEDEFAULT, NULL, NULL, hlnstance.NULL); if(!hWnd) {

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

/* Show our window */

ShowWindow(hWnd,nCmdShow);

UpdateWindow(hWnd);

/* Beginning of messages cycle */

while(GetMcssage(&Msg, NULL, 0, 0))

TranslatcMessage(&Msg);




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



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