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


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


#include <windows.h>

#include <commctrl.h>

const IDM_Enable_Disable = 0;

const IDM_Exit = i;

const IDM_About = 2;

const lDP_File = 3;

const IDP_Help = 4;

char* pMcssages[] {

"Enable or disable exit", "Exit from the program", "About this program", "File operations", "Help operations", "Menu example", "System menu"

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

HWND hStatusWindow;

UINT wld;

HMENU hMenu,hFileMenu,hHe!pMenu;

HINSTANCE hlnst;

int APIENTRY WinMain (HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR IpszCmdParam, int nCmdShow )

HWND hWnd ; WNDCLASS WndClass ; MSG Msg;

hlnst = hinstance; /* Registering our window class */ /* Fill WNDCLASS structure */

WndClass.style = CS_HREDRAW | CS_VREDRAW;

WndClass.lpfiiWndProc = (WNDPROC) MenuDemoWndProc;

WndClass.cbClsExtra = 0;

WndClass.cbWndExtra = 0;

WndClass. hinstance = hinstance ;

WndClass.hlcon = Loadlcon (NULL,IDI_APPLICATION);

WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);

WndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE J3RUSH);

WndClass. IpszMenuName = NULL;

WndClass. IpszClassName = "MenuExample";

if ( !RegisterCiass(&WndClass) )

{

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

hWnd = CreateWindow("MenuExample", "Program No 2",

WS_O VERLAPPEDWIN DOW,

CWJJSEDEFAULT,

CWJJSEDEFAULT,

CWJJSEDEFAULT,

CWJJSEDEFAULT,

NULL, NULL,

hlnstance.NULL); if(!hWnd)

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

return 0;

InitCommonConlrols();

hStatusWindow = CreateStatusWindow(WS_CHILD | WSJVISIBLE,

if(!hStatusWindow)

"Menu sample", hWnd,w!d);

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

/* Try to create menu */

AppendMenu( (hFileMenu=CreatePopupMenu()), MF_ENABLED, MF_STRING,

IDM_Enable_Disable, "&Enable exit");




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



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