Операционная система Microsoft Windows 3.1 для программиста -том 3


Листинг 1.5. Файл dmenu/dmenu.cpp - часть 2


wc.lpszMenuName = NULL; wc.style = 0; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszClassName = (LPSTR)szClassName;

// Регистрация класса aWndClass = RegisterClass(&wc); return (aWndClass != 0); }

// ===================================== // Функция WndProc // =====================================

LRESULT CALLBACK _export WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: { // Создаем пустое меню верхнего уровня hmenu = CreateMenu();

// Подключаем меню к главному окну приложения SetMenu(hwnd, hmenu);

// Создаем два временных меню - "File" и "Help" hmenuFile = CreatePopupMenu(); hmenuHelp = CreatePopupMenu();

// Добавляем строки к меню "File" AppendMenu(hmenuFile, MF_ENABLED | MF_STRING, CM_FILENEW, "&New"); AppendMenu(hmenuFile, MF_ENABLED | MF_STRING, CM_FILEOPEN, "&Open"); AppendMenu(hmenuFile, MF_GRAYED | MF_STRING, CM_FILECLOSE, "&Close"); AppendMenu(hmenuFile, MF_GRAYED | MF_STRING, CM_FILESAVE, "&Save"); AppendMenu(hmenuFile, MF_GRAYED | MF_STRING, CM_FILESAVEAS, "Save &as...");

// Добавляем разделительную линию AppendMenu(hmenuFile, MF_SEPARATOR, 0, NULL);

AppendMenu(hmenuFile, MF_GRAYED | MF_STRING, CM_FILEPRINT, "&Print"); AppendMenu(hmenuFile, MF_GRAYED | MF_STRING, CM_FILEPAGE_SETUP, "Page Se&tup"); AppendMenu(hmenuFile, MF_GRAYED | MF_STRING, CM_FILEPRINTER_SETUP, "P&rinter Setup");

AppendMenu(hmenuFile, MF_SEPARATOR, 0, NULL);

AppendMenu(hmenuFile, MF_DISABLED | MF_STRING, CM_FILEDEMO, "&Demo Version");

AppendMenu(hmenuFile, MF_SEPARATOR, 0, NULL);

AppendMenu(hmenuFile, MF_ENABLED | MF_STRING, CM_FILEEXIT, "E&xit");

// Отмечаем галочкой строку "Demo Version" CheckMenuItem(hmenuFile, CM_FILEDEMO, MF_BYCOMMAND | MF_CHECKED);




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