static void hugsprim_AppendMenuW_27(HugsStackPtr hugs_root) { HsPtr arg1; HsWord32 arg2; HsWord32 arg3; HsPtr arg4; HsBool res1; arg1 = hugs->getPtr(); arg2 = hugs->getWord32(); arg3 = hugs->getWord32(); arg4 = hugs->getPtr(); res1 = AppendMenuW(arg1, arg2, arg3, arg4); hugs->putBool(res1); hugs->returnIO(hugs_root,1); }
static void AppendFavMenuItems(HMENU m, DisplayState* f, UINT& idx, bool combined, bool isCurrent) { for (size_t i = 0; i < f->favorites->size(); i++) { if (i >= MAX_FAV_MENUS) { return; } Favorite* fn = f->favorites->at(i); fn->menuId = idx++; AutoFreeW s; if (combined) { s.Set(FavCompactReadableName(f, fn, isCurrent)); } else { s.Set(FavReadableName(fn)); } auto str = win::menu::ToSafeString(s); AppendMenuW(m, MF_STRING, (UINT_PTR)fn->menuId, str); } }
HMENU makeMenubar(void) { HMENU menubar; HMENU menu; size_t i; menusFinalized = TRUE; menubar = CreateMenu(); if (menubar == NULL) logLastError(L"error creating menubar"); for (i = 0; i < len; i++) { menu = makeMenu(menus[i]); if (AppendMenuW(menubar, MF_POPUP | MF_STRING, (UINT_PTR) menu, menus[i]->name) == 0) logLastError(L"error appending menu to menubar"); } return menubar; }
void addMenu(HWND hwnd) { HMENU hMenubar; HMENU hFileMenu; hMenubar = CreateMenu(); hFileMenu = CreateMenu(); AppendMenuW(hFileMenu, MF_STRING, IDM_EXERCITIU_1, L"&Exercitiul&1"); AppendMenuW(hFileMenu, MF_STRING, IDM_EXERCITIU_2, L"&Exercitiul&2"); AppendMenuW(hFileMenu, MF_STRING, IDM_EXERCITIU_3, L"&Exercitiul&3"); AppendMenuW(hFileMenu, MF_SEPARATOR, 0, NULL); AppendMenuW(hFileMenu, MF_STRING, IDM_EXIT, L"&Quit"); AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR)hFileMenu, L"&File"); AppendMenuW(hMenubar, MF_STRING, IDM_CLEAR, L"&Clear"); SetMenu(hwnd, hMenubar); }
static void appendMenuItem(HMENU menu, uiMenuItem *item) { UINT uFlags; uFlags = MF_SEPARATOR; if (item->type != typeSeparator) { uFlags = MF_STRING; if (item->disabled) uFlags |= MF_DISABLED | MF_GRAYED; if (item->checked) uFlags |= MF_CHECKED; } if (AppendMenuW(menu, uFlags, item->id, item->name) == 0) logLastError(L"error appending menu item"); if (item->len >= item->cap) { item->cap += grow; item->hmenus = (HMENU *) uiRealloc(item->hmenus, item->cap * sizeof (HMENU), "HMENU[]"); } item->hmenus[item->len] = menu; item->len++; }
static void _ShowContextMenu(CSysTray * pSysTray) { CString strOpen((LPCSTR)IDS_PWR_PROPERTIES); HMENU hPopup = CreatePopupMenu(); AppendMenuW(hPopup, MF_STRING, IDS_PWR_PROPERTIES, strOpen); SetMenuDefaultItem(hPopup, IDS_PWR_PROPERTIES, FALSE); SetForegroundWindow(pSysTray->GetHWnd()); DWORD flags = TPM_RETURNCMD | TPM_NONOTIFY | TPM_RIGHTALIGN | TPM_BOTTOMALIGN; POINT pt; GetCursorPos(&pt); DWORD id = TrackPopupMenuEx(hPopup, flags, pt.x, pt.y, pSysTray->GetHWnd(), NULL); switch (id) { case IDS_PWR_PROPERTIES: _RunPower(); break; } DestroyMenu(hPopup); }
static BOOLEAN CALLBACK PowerSchemesEnumProc( UINT uiIndex, DWORD dwName, LPWSTR sName, DWORD dwDesc, LPWSTR sDesc, PPOWER_POLICY pp, LPARAM lParam) { PPWRSCHEMECONTEXT PowerSchemeContext = (PPWRSCHEMECONTEXT)lParam; if (AppendMenuW(PowerSchemeContext->hPopup, MF_STRING, uiIndex + 1, sName)) { if (PowerSchemeContext->uiFirst == 0) PowerSchemeContext->uiFirst = uiIndex + 1; PowerSchemeContext->uiLast = uiIndex + 1; } return TRUE; }
void do_startmenu(HWND hwnd) { LPITEMIDLIST pidl; MENUINFO mi; MENUITEMINFOW mii; RECT rc={0,0,0,0}; TPMPARAMS tpm; WCHAR run_label[50]; destroy_menus(); WINE_TRACE("creating start menu\n"); root_menu.menuhandle = public_startmenu.menuhandle = user_startmenu.menuhandle = CreatePopupMenu(); if (!root_menu.menuhandle) { return; } user_startmenu.parent = public_startmenu.parent = &root_menu; user_startmenu.base = &public_startmenu; user_startmenu.menu_filled = public_startmenu.menu_filled = FALSE; if (!user_startmenu.pidl) SHGetSpecialFolderLocation(NULL, CSIDL_STARTMENU, &user_startmenu.pidl); if (!user_startmenu.folder) pidl_to_shellfolder(user_startmenu.pidl, NULL, &user_startmenu.folder); if (!public_startmenu.pidl) SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_STARTMENU, &public_startmenu.pidl); if (!public_startmenu.folder) pidl_to_shellfolder(public_startmenu.pidl, NULL, &public_startmenu.folder); fill_menu(&user_startmenu); AppendMenuW(root_menu.menuhandle, MF_SEPARATOR, 0, NULL); if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_CONTROLS, &pidl))) add_shell_item(&root_menu, pidl); LoadStringW(NULL, IDS_RUN, run_label, sizeof(run_label)/sizeof(run_label[0])); mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING|MIIM_ID; mii.dwTypeData = run_label; mii.wID = MENU_ID_RUN; InsertMenuItemW(root_menu.menuhandle, -1, TRUE, &mii); mi.cbSize = sizeof(mi); mi.fMask = MIM_STYLE; mi.dwStyle = MNS_NOTIFYBYPOS; SetMenuInfo(root_menu.menuhandle, &mi); GetWindowRect(hwnd, &rc); tpm.cbSize = sizeof(tpm); tpm.rcExclude = rc; if (!TrackPopupMenuEx(root_menu.menuhandle, TPM_LEFTALIGN|TPM_BOTTOMALIGN|TPM_VERTICAL, rc.left, rc.top, hwnd, &tpm)) { WINE_ERR("couldn't display menu\n"); } }
BOOL AP_Win32Dialog_Styles::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { WORD wNotifyCode = HIWORD(wParam); WORD wId = LOWORD(wParam); HWND hWndCtrl = (HWND)lParam; switch (wId) { case AP_RID_DIALOG_STYLES_TOP_BUTTON_APPLY: { const gchar * szStyle = getCurrentStyle(); if(szStyle && *szStyle) { getView()->setStyle(szStyle); } } m_answer = a_OK; return 1; case AP_RID_DIALOG_STYLES_TOP_BUTTON_CLOSE: case IDCANCEL: m_answer = a_CANCEL; EndDialog(hWnd,0); return 1; case IDOK: { const XAP_StringSet * pSS = m_pApp->getStringSet (); WCHAR stylename[MAX_EBX_LENGTH+1]; // Verfiy a name value for the style // TODO - Verify unique name value GetDlgItemTextW(hWnd,AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME,stylename,MAX_EBX_LENGTH); /*_win32DialogNewModify.getControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME, m_newStyleName, MAX_EBX_LENGTH );*/ UT_UTF8String str; str.appendUCS2((const UT_UCS2Char*)stylename,0); strcpy(m_newStyleName,str.utf8_str()); if( !m_newStyleName || !strlen(m_newStyleName) ) { getFrame()->showMessageBox( pSS->getValue (AP_STRING_ID_DLG_Styles_ErrBlankName), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); return 1; } //strcpy (m_newStyleName, (AP_Win32App::s_fromWinLocaleToUTF8(m_newStyleName)).utf8_str()); } m_answer = a_OK; EndDialog(hWnd,0); return 1; case AP_RID_DIALOG_STYLES_TOP_COMBO_LIST: if( wNotifyCode == CBN_SELCHANGE ) { switch(_win32Dialog.getComboSelectedIndex(AP_RID_DIALOG_STYLES_TOP_COMBO_LIST)) { case 0: m_whichType = USED_STYLES; break; case 1: m_whichType = ALL_STYLES; break; case 2: m_whichType = USER_STYLES; break; } _populateWindowData(); } return 1; case AP_RID_DIALOG_STYLES_TOP_LIST_STYLES: if (wNotifyCode == LBN_SELCHANGE) { UT_uint32 nData = -1; const char* name; const PD_Style * pcStyle = NULL; int row = _win32Dialog.getListSelectedIndex(AP_RID_DIALOG_STYLES_TOP_LIST_STYLES); nData = _win32Dialog.getListDataItem( AP_RID_DIALOG_STYLES_TOP_LIST_STYLES, row); if (row!=LB_ERR) { getDoc()->enumStyles(nData, &name, &pcStyle); m_selectedStyle = name; m_nSelectedStyleIdx = nData; // refresh the previews _populatePreviews(false); } break; } return 1; case AP_RID_DIALOG_STYLES_TOP_BUTTON_DELETE: { if( m_selectedStyle != "" ) { if ( !getDoc()->removeStyle(m_selectedStyle.c_str()) ) // actually remove the style { const XAP_StringSet * pSS = m_pApp->getStringSet(); getFrame()->showMessageBox( pSS->getValue (AP_STRING_ID_DLG_Styles_ErrStyleCantDelete), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK ); return 1; } getFrame()->repopulateCombos(); _populateWindowData(); // force a refresh getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT); m_selectedStyle = ""; } } return 1; case AP_RID_DIALOG_STYLES_TOP_BUTTON_NEW: { m_bisNewStyle = true; //_win32Dialog.showWindow(SW_HIDE); XAP_Frame* pFrame = getFrame(); //_win32DialogNewModify.runModal(pFrame, AP_DIALOG_ID_STYLES, AP_RID_DIALOG_STYLES_NEWMODIFY, this); createModal(pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_STYLES_NEWMODIFY)); if(m_answer == AP_Dialog_Styles::a_OK) { createNewStyle((gchar *) m_newStyleName); _populateCList(); } destroyAbiPreview(); DELETEP(m_pAbiPreviewWidget); //_win32Dialog.showWindow(SW_SHOW); } return 1; case AP_RID_DIALOG_STYLES_TOP_BUTTON_MODIFY: { // Verify that a style is selected if( m_selectedStyle == "" ) { XAP_Frame * pFrame = getFrame(); const XAP_StringSet * pSS = m_pApp->getStringSet(); pFrame->showMessageBox( pSS->getValue(AP_STRING_ID_DLG_Styles_ErrNoStyle), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); m_answer = AP_Dialog_Styles::a_CANCEL; return 1; } else { PD_Style * pStyle = NULL; getDoc()->getStyle(m_selectedStyle.c_str(), &pStyle); m_bisNewStyle = false; XAP_Frame* pFrame = getFrame(); XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(getApp()); createModal (pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_STYLES_NEWMODIFY)); /*LPCWSTR lpTemplate = MAKEINTRESOURCEW(AP_RID_DIALOG_STYLES_NEWMODIFY); int result = DialogBoxParamW(pWin32App->getInstance(), lpTemplate, static_cast<XAP_Win32FrameImpl*>(pFrame->getFrameImpl())->getTopLevelWindow(), (DLGPROC)s_dlgProc, (LPARAM)this);*/ if(m_answer == AP_Dialog_Styles::a_OK) { applyModifiedStyleToDoc(); getDoc()->updateDocForStyleChange(getCurrentStyle(),true); getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT); } destroyAbiPreview(); DELETEP(m_pAbiPreviewWidget); } } return 1; case AP_RID_DIALOG_STYLES_NEWMODIFY_BTN_REMOVE: { char szTemp[128]; _win32DialogNewModify.getControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_REMOVE, szTemp, sizeof(szTemp) ); removeVecProp(szTemp); rebuildDeleteProps(); updateCurrentStyle(); } return 1; case AP_RID_DIALOG_STYLES_NEWMODIFY_BTN_TOGGLEITEMS: { RECT rect; HMENU hMenu; int x,y; HWND hWndButton; static int menu_items[]={AP_STRING_ID_DLG_Styles_ModifyParagraph, AP_STRING_ID_DLG_Styles_ModifyFont, AP_STRING_ID_DLG_Styles_ModifyTabs, AP_STRING_ID_DLG_Styles_ModifyNumbering, AP_STRING_ID_DLG_Styles_ModifyLanguage }; UT_Win32LocaleString str; hWndButton = GetDlgItem(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_BTN_TOGGLEITEMS); XAP_Win32App * app = static_cast<XAP_Win32App *> (m_pApp); const XAP_StringSet * pSS = m_pApp->getStringSet(); // Get button position GetWindowRect(hWndButton, &rect); x = rect.left; y = rect.bottom; // Menu creation hMenu = CreatePopupMenu(); str; for (int i=0; i<5; i++) { str.fromUTF8(pSS->getValue(menu_items[i])); AppendMenuW(hMenu, MF_ENABLED|MF_STRING, i+1, (LPCWSTR)str.c_str()); } // show and track the menu m_selectToggle = TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD, x,y,0, hWndButton, NULL); switch(m_selectToggle) { case 0: // user has cancelled break; case 1: ModifyParagraph(); break; case 2: ModifyFont(); break; case 3: ModifyTabs(); break; case 4: ModifyLists(); break; case 5: ModifyLang(); break; default: break; } rebuildDeleteProps(); updateCurrentStyle(); DestroyMenu(hMenu); return 1; } case AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON: if( wNotifyCode == CBN_SELCHANGE ) { eventBasedOn(); rebuildDeleteProps(); } return 1; case AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA: if( wNotifyCode == CBN_SELCHANGE ) { eventFollowedBy(); } return 1; case AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE: if( wNotifyCode == CBN_SELCHANGE ) { eventStyleType(); } return 1; default: // we did not handle this notification UT_DEBUGMSG(("WM_Command for id %ld\n",wId)); return 0; // return zero to let windows take care of it. } return 0; // return zero to let windows take care of it. }
STDMETHODIMP CDeskBand::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { TRACE_ENTER("CDeskBand::QueryContextMenu"); if ((!m_HasAppletMenu) || (CMF_DEFAULTONLY & uFlags) || !IsWindow( get_command_window() )) return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0)); int m = 0; HMENU popup = NULL; while (m < m_AppletMenu.num_items) { AppletMenuItemData *d = &m_AppletMenu.items[m]; wchar_t textw[APPLET_MENU_TEXT_MAX_LENGTH*2]; MultiByteToWideChar(CP_UTF8, 0, d->text, -1, textw, sizeof(textw)/sizeof(textw[0])); wchar_t *abbrev = wcschr(textw, '_'); UINT flags = MF_STRING | MF_BYPOSITION; if (d->flags & APPLET_MENU_FLAG_SELECTED) { flags |= MF_CHECKED; } if (abbrev != NULL) { *abbrev = '&'; } if (d->flags & APPLET_MENU_FLAG_POPUP) { if (popup == NULL) { popup = CreatePopupMenu(); } AppendMenuW(popup, flags, idCmdFirst + m, textw); } else { if (popup != NULL) { InsertMenuW(hMenu, indexMenu++, MF_POPUP | flags, (UINT) popup, textw); popup = NULL; } else { InsertMenuW(hMenu, indexMenu++, flags, idCmdFirst + m, textw); } } m++; } TRACE_EXIT(); return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(m_AppletMenu.num_items + 1)); }
void CreateCustomMenu(){ FreeMenuIfNecessary(); hMenu = CreatePopupMenu(); HMENU hFilterSubMenu = CreatePopupMenu(); HMENU hOptionsSubMenu = CreatePopupMenu(); char *currFilter = go_GetCurrentFilterName(); //Main Menu AppendMenu(hMenu, MF_STRING | MF_GRAYED, 0, VERSION); //AppendMenuW(hSubMenu, MF_SEPARATOR, 0, NULL); //AppendMenuW(hSubMenu, MF_STRING, CMD_ABOUT, L"About"); AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hFilterSubMenu, L"Filer"); AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hOptionsSubMenu, L"Options"); AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL); AppendMenuW(hMenu, MF_STRING, CMD_EXIT, L"Exit"); //Sub Menu of Filters AppendMenuW(hFilterSubMenu, MF_STRING, CMD_FILTER_RELOAD, L"Reload current filter"); AppendMenuW(hFilterSubMenu, MF_SEPARATOR, 0, NULL); int count = 0; char* name = go_GetNextFilterName(); while ((strlen(name) > 0) && (count < 50)){ if (strcmp(name , currFilter) == 0){ AppendMenu(hFilterSubMenu, MF_STRING | MF_CHECKED, (UINT_PTR)hFilterSubMenu, name); }else{ AppendMenu(hFilterSubMenu, MF_STRING, CMD_FILTERSELECT_START+count, name); } free(name); name = go_GetNextFilterName(); count++; } free(name); AppendMenuW(hFilterSubMenu, MF_SEPARATOR, 0, NULL); if (strlen(currFilter) > 0){ AppendMenuW(hFilterSubMenu, MF_STRING, CMD_FILTER_NONE, L"None"); }else{ AppendMenuW(hFilterSubMenu, MF_STRING | MF_CHECKED, CMD_FILTER_NONE, L"None"); } free(currFilter); //Sub Menu of Options if (UseDoubleclick){ AppendMenuW(hOptionsSubMenu, MF_STRING | MF_CHECKED, CMD_OPTIONS_USEDOUBLECLICK, L"Send Doubleclick"); }else{ AppendMenuW(hOptionsSubMenu, MF_STRING, CMD_OPTIONS_USEDOUBLECLICK, L"Send Doubleclick"); } if (CheckForUpdates){ AppendMenuW(hOptionsSubMenu, MF_STRING | MF_CHECKED, CMD_OPTIONS_CHECKUPDATES, L"Check for updates"); }else{ AppendMenuW(hOptionsSubMenu, MF_STRING, CMD_OPTIONS_CHECKUPDATES, L"Check for updates"); } if (LaunchPoE){ AppendMenuW(hOptionsSubMenu, MF_STRING | MF_CHECKED, CMD_OPTIONS_LAUNCHPOE, L"Launch PoE on start"); }else{ AppendMenuW(hOptionsSubMenu, MF_STRING, CMD_OPTIONS_LAUNCHPOE, L"Launch PoE on start"); } // SetForegroundWindow(hWnd); // Win32 bug work-around // TrackPopupMenu(hMenu, TPM_BOTTOMALIGN | TPM_LEFTALIGN, p.x, p.y, 0, hWnd, NULL); }
void winopen() { WNDCLASS wc; HMENU menu; RECT r; ATOM a; /* Create and register window frame class */ memset(&wc, 0, sizeof(wc)); wc.style = 0; wc.lpfnWndProc = frameproc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = GetModuleHandle(NULL); wc.hIcon = LoadIconA(wc.hInstance, "IDI_ICONAPP"); wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = L"FrameWindow"; a = RegisterClassW(&wc); if (!a) winerror(&gapp, "cannot register frame window class"); /* Create and register window view class */ memset(&wc, 0, sizeof(wc)); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = viewproc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = GetModuleHandle(NULL); wc.hIcon = NULL; wc.hCursor = NULL; wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = L"ViewWindow"; a = RegisterClassW(&wc); if (!a) winerror(&gapp, "cannot register view window class"); /* Get screen size */ SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); gapp.scrw = r.right - r.left; gapp.scrh = r.bottom - r.top; /* Create cursors */ arrowcurs = LoadCursor(NULL, IDC_ARROW); handcurs = LoadCursor(NULL, IDC_HAND); waitcurs = LoadCursor(NULL, IDC_WAIT); caretcurs = LoadCursor(NULL, IDC_IBEAM); /* And a background color */ bgbrush = CreateSolidBrush(RGB(0x70,0x70,0x70)); shbrush = CreateSolidBrush(RGB(0x40,0x40,0x40)); /* Init DIB info for buffer */ dibinf = malloc(sizeof(BITMAPINFO) + 12); assert(dibinf); dibinf->bmiHeader.biSize = sizeof(dibinf->bmiHeader); dibinf->bmiHeader.biPlanes = 1; dibinf->bmiHeader.biBitCount = 32; dibinf->bmiHeader.biCompression = BI_RGB; dibinf->bmiHeader.biXPelsPerMeter = 2834; dibinf->bmiHeader.biYPelsPerMeter = 2834; dibinf->bmiHeader.biClrUsed = 0; dibinf->bmiHeader.biClrImportant = 0; dibinf->bmiHeader.biClrUsed = 0; /* Create window */ hwndframe = CreateWindowW(L"FrameWindow", // window class name NULL, // window caption WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, // initial position 300, // initial x size 300, // initial y size 0, // parent window handle 0, // window menu handle 0, // program instance handle 0); // creation parameters if (!hwndframe) winerror(&gapp, "cannot create frame"); hwndview = CreateWindowW(L"ViewWindow", // window class name NULL, WS_VISIBLE | WS_CHILD, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndframe, 0, 0, 0); if (!hwndview) winerror(&gapp, "cannot create view"); hdc = NULL; SetWindowTextW(hwndframe, L"MuPDF"); menu = GetSystemMenu(hwndframe, 0); AppendMenuW(menu, MF_SEPARATOR, 0, NULL); AppendMenuW(menu, MF_STRING, ID_ABOUT, L"About MuPDF..."); AppendMenuW(menu, MF_STRING, ID_DOCINFO, L"Document Properties..."); SetCursor(arrowcurs); }
static void DoPopupMenu(void) { int idLayoutsBegin,idLayoutsEnd,idExit,cmd; POINT mpt; HMENU hMenu=CreatePopupMenu(); Layout *pFirstLayout=CreateLayoutsList(); SetForegroundWindow(g_hWnd); // Fill menu { int id=1; idLayoutsBegin=id; if(pFirstLayout) { Layout *pActiveLayout=FindActiveLayout(pFirstLayout),*pLayout; for(pLayout=pFirstLayout;pLayout;pLayout=pLayout->pNextLayout) { UINT flags=0; if(pLayout==pActiveLayout) flags|=MF_CHECKED; AppendMenuW(hMenu,flags,id++,pLayout->pDisplayName); } AppendMenuW(hMenu,MF_SEPARATOR,0,0); } idLayoutsEnd=id; idExit=id++; AppendMenuA(hMenu,0,idExit,"E&xit"); } // Popup menu GetCursorPos(&mpt); cmd=TrackPopupMenuEx(hMenu,TPM_RETURNCMD,mpt.x,mpt.y,g_hWnd,0); // Do what? if(cmd==idExit) { // Bye... PostQuitMessage(0); } else if(cmd>=idLayoutsBegin&&cmd<idLayoutsEnd) { // Set new layout int idx=cmd-idLayoutsBegin; Layout *pLayout=pFirstLayout; while(idx-->0) pLayout=pLayout->pNextLayout; SetLayoutByHandle(pLayout->hkl,FALSE); } DeleteLayoutList(pFirstLayout); pFirstLayout=NULL; }
BOOL CALLBACK on_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) { switch(msg) { case WM_INITDIALOG: { HWND wnd_fields = m_source_list.create_in_dialog_units(wnd, ui_helpers::window_position_t(20,44,276,80)); SetWindowPos(wnd_fields, HWND_TOP, 0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); refresh_me(wnd); ShowWindow(wnd_fields, SW_SHOWNORMAL); } break; case WM_DESTROY: { on_scripts_change(); } break; case WM_COMMAND: switch(wp) { #if 0 case (EN_CHANGE<<16)|IDC_FRONT: artwork_panel::cfg_front = string_utf8_from_window((HWND)lp); m_changed = true; break; case (EN_CHANGE<<16)|IDC_BACK: artwork_panel::cfg_back = string_utf8_from_window((HWND)lp); m_changed = true; break; case (EN_CHANGE<<16)|IDC_DISC: artwork_panel::cfg_disc = string_utf8_from_window((HWND)lp); m_changed = true; break; case (EN_KILLFOCUS<<16)|IDC_FRONT: case (EN_KILLFOCUS<<16)|IDC_BACK: case (EN_KILLFOCUS<<16)|IDC_DISC: on_scripts_change(); break; #endif /*case (EN_CHANGE<<16)|IDC_ICON: artwork_panel::cfg_icon = string_utf8_from_window((HWND)lp); m_changed = true; break;*/ case IDC_FB2KARTWORK|(CBN_SELCHANGE<<16): artwork_panel::cfg_fb2k_artwork_mode = ComboBox_GetCurSel((HWND)lp); break; case IDC_EDGESTYLE|(CBN_SELCHANGE<<16): artwork_panel::cfg_edge_style = ComboBox_GetCurSel((HWND)lp); artwork_panel::artwork_panel_t::g_on_edge_style_change(); break; case IDC_ADD: { RECT rc; GetWindowRect((HWND)lp, &rc); HMENU menu = CreatePopupMenu(); enum {IDM_FRONT = 1}; t_size index, indexcount = tabsize(g_artwork_sources); for (index = 0; index < indexcount; index++) { AppendMenuW(menu,(MF_STRING),index+1,pfc::stringcvt::string_wide_from_utf8(g_artwork_sources[index].m_name)); } int cmd = TrackPopupMenu(menu,TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,rc.left,rc.bottom,0,wnd,0); DestroyMenu(menu); if (cmd>0 && (t_size)cmd <= indexcount) { index = cmd-1; t_size subindex = g_artwork_sources[index].m_scripts->add_item("<enter script>"); t_size combined_index = get_combined_index(index, subindex); t_list_view::t_item_insert item; item.m_groups.add_item(g_artwork_sources[index].m_name); item.m_subitems.add_item("<enter script>"); m_source_list.insert_items(combined_index, 1, &item); SetFocus(m_source_list.get_wnd()); m_source_list.set_item_selected_single(combined_index); m_source_list.activate_inline_editing(); m_source_list.m_changed = true; } } break; case IDC_REMOVE: { if (m_source_list.get_selection_count(2) == 1) { bit_array_bittable mask(m_source_list.get_item_count()); m_source_list.get_selection_state(mask); //bool b_found = false; t_size combined_index=0, count=m_source_list.get_item_count(); while (combined_index < count) { if (mask[combined_index]) break; combined_index++; } t_size index, subindex; if (combined_index < count && get_separated_index(combined_index, index, subindex)) { g_artwork_sources[index].m_scripts->remove_by_idx(subindex); m_source_list.remove_item(combined_index); m_source_list.m_changed = true; t_size new_count = m_source_list.get_item_count(); if (new_count) { if (combined_index < new_count) m_source_list.set_item_selected_single(combined_index); else if (combined_index) m_source_list.set_item_selected_single(combined_index-1); } } } } break; case IDC_UP: { if (m_source_list.get_selection_count(2) == 1) { t_size combined_index = 0; { t_size count = m_source_list.get_item_count(); while (!m_source_list.get_item_selected(combined_index) && combined_index < count) combined_index++; } t_size index, subindex, combined_index_start, count; get_group_from_combined_index(combined_index, index, subindex, combined_index_start, count); if (subindex && count) { g_artwork_sources[index].m_scripts->swap_items(subindex, subindex-1); pfc::list_t<t_list_view::t_item_insert> items; items.set_count(2); items[0].m_groups.add_item(g_artwork_sources[index].m_name); items[1].m_groups.add_item(g_artwork_sources[index].m_name); items[0].m_subitems.add_item((*g_artwork_sources[index].m_scripts)[subindex-1]); items[1].m_subitems.add_item((*g_artwork_sources[index].m_scripts)[subindex]); m_source_list.replace_items(combined_index-1, items); m_source_list.set_item_selected_single(combined_index-1); m_source_list.m_changed = true; } } } break; case IDC_DOWN: { if (m_source_list.get_selection_count(2) == 1) { t_size combined_index = 0; { t_size count = m_source_list.get_item_count(); while (!m_source_list.get_item_selected(combined_index) && combined_index < count) combined_index++; } t_size index, subindex, combined_index_start, count; get_group_from_combined_index(combined_index, index, subindex, combined_index_start, count); if (subindex + 1 < count) { g_artwork_sources[index].m_scripts->swap_items(subindex, subindex+1); pfc::list_t<t_list_view::t_item_insert> items; items.set_count(2); items[0].m_groups.add_item(g_artwork_sources[index].m_name); items[1].m_groups.add_item(g_artwork_sources[index].m_name); items[0].m_subitems.add_item((*g_artwork_sources[index].m_scripts)[subindex]); items[1].m_subitems.add_item((*g_artwork_sources[index].m_scripts)[subindex+1]); m_source_list.replace_items(combined_index, items); m_source_list.set_item_selected_single(combined_index+1); m_source_list.m_changed = true; } } } break; } } return 0; }
static void TaskManager_OnTabWndSelChange(void) { int i; HMENU hMenu; HMENU hOptionsMenu; HMENU hViewMenu; HMENU hSubMenu; WCHAR wszLargeIcons[255]; WCHAR wszSmallIcons[255]; WCHAR wszDetails[255]; WCHAR wszWindows[255]; WCHAR wszSelectColumns[255]; WCHAR wszShow16bTasks[255]; WCHAR wszOneGraphAllCPU[255]; WCHAR wszOneGraphPerCPU[255]; WCHAR wszCPUHistory[255]; WCHAR wszShowKernelTimes[255]; LoadStringW(hInst, IDS_VIEW_LARGE, wszLargeIcons, sizeof(wszLargeIcons)/sizeof(WCHAR)); LoadStringW(hInst, IDS_VIEW_SMALL, wszSmallIcons, sizeof(wszSmallIcons)/sizeof(WCHAR)); LoadStringW(hInst, IDS_VIEW_DETAILS, wszDetails, sizeof(wszDetails)/sizeof(WCHAR)); LoadStringW(hInst, IDS_WINDOWS, wszWindows, sizeof(wszWindows)/sizeof(WCHAR)); LoadStringW(hInst, IDS_VIEW_SELECTCOLUMNS, wszSelectColumns, sizeof(wszSelectColumns)/sizeof(WCHAR)); LoadStringW(hInst, IDS_OPTIONS_SHOW16BITTASKS, wszShow16bTasks, sizeof(wszShow16bTasks)/sizeof(WCHAR)); LoadStringW(hInst, IDS_VIEW_CPUHISTORY_ONEGRAPHALL, wszOneGraphAllCPU, sizeof(wszOneGraphAllCPU)/sizeof(WCHAR)); LoadStringW(hInst, IDS_VIEW_CPUHISTORY_ONEGRAPHPERCPU, wszOneGraphPerCPU, sizeof(wszOneGraphPerCPU)/sizeof(WCHAR)); LoadStringW(hInst, IDS_VIEW_CPUHISTORY, wszCPUHistory, sizeof(wszCPUHistory)/sizeof(WCHAR)); LoadStringW(hInst, IDS_VIEW_SHOWKERNELTIMES, wszShowKernelTimes, sizeof(wszShowKernelTimes)/sizeof(WCHAR)); hMenu = GetMenu(hMainWnd); hViewMenu = GetSubMenu(hMenu, 2); hOptionsMenu = GetSubMenu(hMenu, 1); TaskManagerSettings.ActiveTabPage = SendMessageW(hTabWnd, TCM_GETCURSEL, 0, 0); for (i = GetMenuItemCount(hViewMenu) - 1; i > 2; i--) { hSubMenu = GetSubMenu(hViewMenu, i); if (hSubMenu) DestroyMenu(hSubMenu); RemoveMenu(hViewMenu, i, MF_BYPOSITION); } RemoveMenu(hOptionsMenu, 3, MF_BYPOSITION); switch (TaskManagerSettings.ActiveTabPage) { case 0: ShowWindow(hApplicationPage, SW_SHOW); ShowWindow(hProcessPage, SW_HIDE); ShowWindow(hPerformancePage, SW_HIDE); BringWindowToTop(hApplicationPage); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_LARGE, wszLargeIcons); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SMALL, wszSmallIcons); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_DETAILS, wszDetails); if (GetMenuItemCount(hMenu) <= 4) { hSubMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_WINDOWSMENU)); InsertMenuW(hMenu, 3, MF_BYPOSITION|MF_POPUP, (UINT_PTR)hSubMenu, wszWindows); DrawMenuBar(hMainWnd); } if (TaskManagerSettings.View_LargeIcons) CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, ID_VIEW_LARGE, MF_BYCOMMAND); else if (TaskManagerSettings.View_SmallIcons) CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, ID_VIEW_SMALL, MF_BYCOMMAND); else CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, ID_VIEW_DETAILS, MF_BYCOMMAND); /* * Give the application list control focus */ SetFocus(hApplicationPageListCtrl); break; case 1: ShowWindow(hApplicationPage, SW_HIDE); ShowWindow(hProcessPage, SW_SHOW); ShowWindow(hPerformancePage, SW_HIDE); BringWindowToTop(hProcessPage); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SELECTCOLUMNS, wszSelectColumns); AppendMenuW(hOptionsMenu, MF_STRING, ID_OPTIONS_SHOW16BITTASKS, wszShow16bTasks); if (TaskManagerSettings.Show16BitTasks) CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED); if (GetMenuItemCount(hMenu) > 4) { RemoveMenu(hMenu, 3, MF_BYPOSITION); DrawMenuBar(hMainWnd); } /* * Give the process list control focus */ SetFocus(hProcessPageListCtrl); break; case 2: ShowWindow(hApplicationPage, SW_HIDE); ShowWindow(hProcessPage, SW_HIDE); ShowWindow(hPerformancePage, SW_SHOW); BringWindowToTop(hPerformancePage); if (GetMenuItemCount(hMenu) > 4) { RemoveMenu(hMenu, 3, MF_BYPOSITION); DrawMenuBar(hMainWnd); } hSubMenu = CreatePopupMenu(); AppendMenuW(hSubMenu, MF_STRING, ID_VIEW_CPUHISTORY_ONEGRAPHALL, wszOneGraphAllCPU); AppendMenuW(hSubMenu, MF_STRING, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, wszOneGraphPerCPU); AppendMenuW(hViewMenu, MF_STRING|MF_POPUP, (UINT_PTR)hSubMenu, wszCPUHistory); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SHOWKERNELTIMES, wszShowKernelTimes); if (TaskManagerSettings.ShowKernelTimes) CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED); else CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED); if (TaskManagerSettings.CPUHistory_OneGraphPerCPU) CheckMenuRadioItem(hSubMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND); else CheckMenuRadioItem(hSubMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND); /* * Give the tab control focus */ SetFocus(hTabWnd); break; } }
void add_separator_item() { AppendMenuW(hSubMenu, MF_SEPARATOR, 0, NULL); }
void MusPlayer_WinAPI::initUI(HWND hWnd) { HGDIOBJ hFont = GetStockObject(DEFAULT_GUI_FONT); HFONT hFontBold = CreateFontW(-11, 0, 0, 0, FW_BOLD, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Tahoma"); int left = 5; int top = 10; HWND hText = CreateWindowExW(0, L"STATIC", L"Press \"Open\" or drag&&drop music file into this window", WS_CHILD | WS_VISIBLE | SS_LEFT, left, top, 400, 15, hWnd, NULL, m_hInstance, NULL); top += 25; m_labelTitle = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT, left, top, 400, 15, hWnd, NULL, m_hInstance, NULL); top += 15; m_labelArtist = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT, left, top, 400, 15, hWnd, NULL, m_hInstance, NULL); top += 15; m_labelAlboom = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT, left, top, 400, 15, hWnd, NULL, m_hInstance, NULL); top += 15; m_labelCopyright = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT, left, top, 400, 15, hWnd, NULL, m_hInstance, NULL); top += 15; m_buttonOpen = CreateWindowExW(0, L"BUTTON", L"Open", WS_TABSTOP|WS_VISIBLE|WS_CHILD, left, top, 60, 21, hWnd, (HMENU)CMD_Open, // Here is the ID of your button ( You may use your own ID ) m_hInstance, NULL); left += 60; m_buttonPlay = CreateWindowExW(0, L"BUTTON", L"Play/Pause", WS_TABSTOP|WS_VISIBLE|WS_CHILD, left, top, 60, 21, hWnd, (HMENU)CMD_Play, // Here is the ID of your button ( You may use your own ID ) m_hInstance, NULL); left += 60; m_buttonStop = CreateWindowExW(0, L"BUTTON", L"Stop", WS_TABSTOP|WS_VISIBLE|WS_CHILD, left, top, 60, 21, hWnd, (HMENU)CMD_Stop, // Here is the ID of your button ( You may use your own ID ) m_hInstance, NULL); left += 60; m_volume = CreateWindowExW(0, TRACKBAR_CLASS, L"Volume", WS_TABSTOP|WS_VISIBLE|WS_CHILD, left, top-2, 80, 25, hWnd, (HMENU)CMD_Volume, // Here is the ID of your button ( You may use your own ID ) m_hInstance, NULL); SendMessageW(m_volume, TBM_SETRANGE, (WPARAM)TRUE, //redraw flag (LPARAM)MAKELONG(0, 128)); //min. & max. positions SendMessageW(m_volume, TBM_SETPOS, (WPARAM)TRUE, //redraw flag (LPARAM)128); SendMessageW(m_volume, WM_SETFONT, (WPARAM)hFont, 0); left += 80; m_formatInfo = CreateWindowExW(0, L"STATIC", L"", WS_CHILD | WS_VISIBLE | SS_LEFT, left, top, 200, 15, hWnd, NULL, m_hInstance, NULL); SendMessageW(m_formatInfo, WM_SETFONT, (WPARAM)hFont, 0); left = 5; top += 21; m_recordWave = CreateWindowExW(0, L"BUTTON", L"Record wave", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX, left, top, 200, 15, hWnd, (HMENU)CMD_RecordWave, m_hInstance, NULL); SendMessageW(m_recordWave, WM_SETFONT, (WPARAM)hFont, 0); CheckDlgButton(m_groupADLMIDI, CMD_RecordWave, BST_UNCHECKED); top += 18; WNDPROC OldBtnProc; m_groupGME = CreateWindowExW(0, L"BUTTON", L"Game Music Emulators setup", WS_VISIBLE | WS_CHILD | BS_GROUPBOX, left, top, 330, 50, hWnd, (HMENU)GRP_GME, m_hInstance, NULL); SendMessageW(m_groupGME, WM_SETFONT, (WPARAM)hFont, 0); OldBtnProc = reinterpret_cast<WNDPROC>(static_cast<LONG_PTR>( SetWindowLongPtr(m_groupGME, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(MusPlayer_WinAPI::SubCtrlProc))) ); SetWindowLongPtr(m_groupGME, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(OldBtnProc)); m_gme.m_labelTrack = CreateWindowExW(0, L"STATIC", L"Track number:", WS_CHILD | WS_VISIBLE | SS_LEFT, 10, 20, 70, 15, m_groupGME, NULL, m_hInstance, NULL); SendMessageW(m_gme.m_labelTrack, WM_SETFONT, (WPARAM)hFont, 0); m_gme.m_trackNum = CreateWindowExW(0, L"EDIT", L"ED_RED", WS_TABSTOP|WS_CHILD|WS_VISIBLE|ES_LEFT|WS_BORDER, 80, 20, 240, 20, m_groupGME, (HMENU)(CMD_TrackID), m_hInstance, NULL); SendMessageW(m_gme.m_trackNum, WM_SETFONT, (WPARAM)hFont, 0); // with a spin control to its right side m_gme.m_trackNumUpDown = CreateWindowExW(0, UPDOWN_CLASS, L"SP_RED", WS_TABSTOP|WS_CHILD | WS_VISIBLE | UDS_ARROWKEYS | UDS_ALIGNRIGHT | UDS_SETBUDDYINT | WS_BORDER, 80, 20, 240, 20, m_groupGME, (HMENU)(CMD_TrackIDspin), m_hInstance, NULL); SendMessageW(m_gme.m_trackNumUpDown, WM_SETFONT, (WPARAM)hFont, 0); // Set the buddy control. SendMessage(m_gme.m_trackNumUpDown, UDM_SETBUDDY, (LONG)m_gme.m_trackNum, 0L); // Set the range. SendMessage(m_gme.m_trackNumUpDown, UDM_SETRANGE, 0L, MAKELONG(32000, 0) ); // Set the initial value SendMessage(m_gme.m_trackNumUpDown, UDM_SETPOS, 0L, MAKELONG((int)(0), 0)); //SendMessage(m_gme.m_trackNumUpDown, UDS_WRAP, 0L, FALSE); m_groupMIDI = CreateWindowExW(0, L"BUTTON", L"MIDI Setup", WS_VISIBLE|WS_CHILD|BS_GROUPBOX|WS_GROUP, left, top, 330, 50, hWnd, (HMENU)GRP_MIDI, m_hInstance, NULL); SendMessageW(m_groupMIDI, WM_SETFONT, (WPARAM)hFont, 0); OldBtnProc = reinterpret_cast<WNDPROC>(static_cast<LONG_PTR>( SetWindowLongPtr(m_groupMIDI, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(MusPlayer_WinAPI::SubCtrlProc))) ); SetWindowLongPtr(m_groupMIDI, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(OldBtnProc)); top += 50; m_midi.m_labelDevice = CreateWindowExW(0, L"STATIC", L"MIDI Device:", WS_CHILD | WS_VISIBLE | SS_LEFT, 10, 20, 70, 15, m_groupMIDI, NULL, m_hInstance, NULL); SendMessageW(m_midi.m_labelDevice, WM_SETFONT, (WPARAM)hFont, 0); const wchar_t* midiDevices[] = { L"ADL Midi (OPL Synth emulation)", L"Timidity (GUS-like wavetable MIDI Synth)", L"Native midi (Built-in MIDI of your OS)" }; m_midi.m_midiDevice = CreateWindowExW(0, L"COMBOBOX", L"MidiDevice", WS_TABSTOP|WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|WS_TABSTOP, 80, 17, 240, 210, m_groupMIDI, (HMENU)CMD_MidiDevice, m_hInstance, NULL); SendMessageW(m_midi.m_midiDevice, WM_SETFONT, (WPARAM)hFont, 0); SendMessageW(m_midi.m_midiDevice, CB_ADDSTRING, 0, (LPARAM)midiDevices[0]); SendMessageW(m_midi.m_midiDevice, CB_ADDSTRING, 0, (LPARAM)midiDevices[1]); SendMessageW(m_midi.m_midiDevice, CB_ADDSTRING, 0, (LPARAM)midiDevices[2]); SendMessageW(m_midi.m_midiDevice, CB_SETCURSEL, 0, 0); m_groupADLMIDI = CreateWindowExW(0, L"BUTTON", L"ADLMIDI Extra Setup", WS_VISIBLE|WS_CHILD|BS_GROUPBOX|WS_GROUP, left, top, 330, 125, hWnd, (HMENU)GRP_ADLMIDI, m_hInstance, NULL); SendMessageW(m_groupADLMIDI, WM_SETFONT, (WPARAM)hFont, 0); //top += 50; OldBtnProc=reinterpret_cast<WNDPROC>(static_cast<LONG_PTR>( SetWindowLongPtr(m_groupADLMIDI, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(MusPlayer_WinAPI::SubCtrlProc))) ); SetWindowLongPtr(m_groupADLMIDI, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(OldBtnProc)); m_adlmidi.m_labelBank = CreateWindowExW(0, L"STATIC", L"ADL Midi bank ID:", WS_CHILD|WS_VISIBLE | SS_LEFT, 10, 20, 70, 15, m_groupADLMIDI, NULL, m_hInstance, NULL); SendMessageW(m_adlmidi.m_labelBank, WM_SETFONT, (WPARAM)hFont, 0); m_adlmidi.m_bankID = CreateWindowExW(0, L"COMBOBOX", L"BankId", WS_TABSTOP|WS_VISIBLE|WS_CHILD|CBS_DROPDOWNLIST|CBS_DISABLENOSCROLL|WS_VSCROLL|CBS_NOINTEGRALHEIGHT|WS_TABSTOP, 80, 17, 240, 210, m_groupADLMIDI, (HMENU)CMD_Bank, m_hInstance, NULL); SendMessageW(m_adlmidi.m_bankID, WM_SETFONT, (WPARAM)hFont, 0); int insCount = MIX_ADLMIDI_getTotalBanks(); const char*const* names = MIX_ADLMIDI_getBankNames(); for(int i=0; i<insCount; i++) { SendMessageA(m_adlmidi.m_bankID, CB_ADDSTRING, 0, (LPARAM)names[i]); } SendMessageW(m_adlmidi.m_bankID, CB_SETCURSEL, 58, 0); m_adlmidi.m_tremolo = CreateWindowExW(0, L"BUTTON", L"Deep tremolo", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX, 10, 40, 200, 15, m_groupADLMIDI, (HMENU)CMD_Tremolo, m_hInstance, NULL); SendMessageW(m_adlmidi.m_tremolo, WM_SETFONT, (WPARAM)hFont, 0); CheckDlgButton(m_groupADLMIDI, CMD_Tremolo, BST_CHECKED); m_adlmidi.m_vibrato = CreateWindowExW(0, L"BUTTON", L"Deep vibrato", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX, 10, 60, 200, 15, m_groupADLMIDI, (HMENU)CMD_Vibrato, m_hInstance, NULL); SendMessageW(m_adlmidi.m_vibrato, WM_SETFONT, (WPARAM)hFont, 0); CheckDlgButton(m_groupADLMIDI, CMD_Vibrato, BST_CHECKED); m_adlmidi.m_scalableMod = CreateWindowExW(0, L"BUTTON", L"Scalable modulation", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX, 10, 80, 200, 15, m_groupADLMIDI, (HMENU)CMD_ScalableMod, m_hInstance, NULL); SendMessageW(m_adlmidi.m_scalableMod, WM_SETFONT, (WPARAM)hFont, 0); CheckDlgButton(m_groupADLMIDI, CMD_ScalableMod, BST_UNCHECKED); m_adlmidi.m_adlibDrums = CreateWindowExW(0, L"BUTTON", L"AdLib drums mode", WS_TABSTOP|WS_VISIBLE|WS_CHILD|SS_LEFT|BS_CHECKBOX, 10, 100, 200, 15, m_groupADLMIDI, (HMENU)CMD_AdLibDrums, m_hInstance, NULL); SendMessageW(m_adlmidi.m_adlibDrums, WM_SETFONT, (WPARAM)hFont, 0); CheckDlgButton(m_groupADLMIDI, CMD_AdLibDrums, BST_UNCHECKED); ShowWindow(m_groupGME, SW_HIDE); ShowWindow(m_groupMIDI, SW_HIDE); ShowWindow(m_groupADLMIDI, SW_HIDE); SendMessageW(hWnd, WM_SETFONT, (WPARAM)hFont, 0); SendMessageW(m_buttonOpen, WM_SETFONT, (WPARAM)hFont, 0); SendMessageW(m_buttonPlay, WM_SETFONT, (WPARAM)hFont, 0); SendMessageW(m_buttonStop, WM_SETFONT, (WPARAM)hFont, 0); SendMessageW(hText, WM_SETFONT, (WPARAM)hFontBold, 0); SendMessageW(m_labelTitle, WM_SETFONT, (WPARAM)hFont, 0); SendMessageW(m_labelArtist, WM_SETFONT, (WPARAM)hFont, 0); SendMessageW(m_labelAlboom, WM_SETFONT, (WPARAM)hFont, 0); SendMessageW(m_labelCopyright, WM_SETFONT, (WPARAM)hFont, 0); SetWindowTextW(hWnd, L"Simple SDL2 Mixer X Music player [WinAPI-based]"); HMENU hSubMenu; m_contextMenu = CreatePopupMenu(); AppendMenuW(m_contextMenu, MF_STRING, CMD_Open, L"Open"); AppendMenuW(m_contextMenu, MF_STRING, CMD_Play, L"Play/Pause"); AppendMenuW(m_contextMenu, MF_STRING, CMD_Stop, L"Stop"); AppendMenuW(m_contextMenu, MF_SEPARATOR, 0, 0); AppendMenuW(m_contextMenu, MF_STRING, CMD_Reverb, L"Reverb"); AppendMenuW(m_contextMenu, MF_STRING, CMD_AssocFiles, L"Associate files"); EnableMenuItem(m_contextMenu, CMD_AssocFiles, MF_GRAYED); AppendMenuW(m_contextMenu, MF_SEPARATOR, 0, 0); hSubMenu = CreatePopupMenu(); AppendMenuA(hSubMenu, MF_STRING, CMD_Version, "SDL Mixer X Music Player [WinAPI], v." _FILE_VERSION); EnableMenuItem(hSubMenu, CMD_Version, MF_GRAYED); AppendMenuW(hSubMenu, MF_STRING, CMD_ShowLicense, L"Licensed under GNU GPLv3 license"); AppendMenuW(hSubMenu, MF_SEPARATOR, 0, 0); AppendMenuW(hSubMenu, MF_STRING, CMD_ShowSource, L"Get source code"); AppendMenuW(m_contextMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, L"About"); }
void TaskManager_OnTabWndSelChange(void) { int i; HMENU hMenu; HMENU hOptionsMenu; HMENU hViewMenu; HMENU hSubMenu; WCHAR szTemp[256]; SYSTEM_INFO sysInfo; hMenu = GetMenu(hMainWnd); hViewMenu = GetSubMenu(hMenu, 2); hOptionsMenu = GetSubMenu(hMenu, 1); TaskManagerSettings.ActiveTabPage = TabCtrl_GetCurSel(hTabWnd); for (i = GetMenuItemCount(hViewMenu) - 1; i > 2; i--) { hSubMenu = GetSubMenu(hViewMenu, i); if (hSubMenu) DestroyMenu(hSubMenu); RemoveMenu(hViewMenu, i, MF_BYPOSITION); } RemoveMenu(hOptionsMenu, 3, MF_BYPOSITION); if (hWindowMenu) DestroyMenu(hWindowMenu); switch (TaskManagerSettings.ActiveTabPage) { case 0: ShowWindow(hApplicationPage, SW_SHOW); ShowWindow(hProcessPage, SW_HIDE); ShowWindow(hPerformancePage, SW_HIDE); BringWindowToTop(hApplicationPage); LoadStringW(hInst, IDS_MENU_LARGEICONS, szTemp, 256); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_LARGE, szTemp); LoadStringW(hInst, IDS_MENU_SMALLICONS, szTemp, 256); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SMALL, szTemp); LoadStringW(hInst, IDS_MENU_DETAILS, szTemp, 256); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_DETAILS, szTemp); if (GetMenuItemCount(hMenu) <= 5) { hWindowMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_WINDOWSMENU)); LoadStringW(hInst, IDS_MENU_WINDOWS, szTemp, 256); InsertMenuW(hMenu, 3, MF_BYPOSITION|MF_POPUP, (UINT_PTR) hWindowMenu, szTemp); DrawMenuBar(hMainWnd); } CheckMenuRadioItem(hViewMenu, ID_VIEW_LARGE, ID_VIEW_DETAILS, TaskManagerSettings.ViewMode, MF_BYCOMMAND); /* * Give the application list control focus */ if (!bWasKeyboardInput) SetFocus(hApplicationPageListCtrl); break; case 1: ShowWindow(hApplicationPage, SW_HIDE); ShowWindow(hProcessPage, SW_SHOW); ShowWindow(hPerformancePage, SW_HIDE); BringWindowToTop(hProcessPage); LoadStringW(hInst, IDS_MENU_SELECTCOLUMNS, szTemp, 256); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SELECTCOLUMNS, szTemp); LoadStringW(hInst, IDS_MENU_16BITTASK, szTemp, 256); AppendMenuW(hOptionsMenu, MF_STRING, ID_OPTIONS_SHOW16BITTASKS, szTemp); if (TaskManagerSettings.Show16BitTasks) CheckMenuItem(hOptionsMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED); if (GetMenuItemCount(hMenu) > 5) { DeleteMenu(hMenu, 3, MF_BYPOSITION); DrawMenuBar(hMainWnd); } /* * Give the process list control focus */ if (!bWasKeyboardInput) SetFocus(hProcessPageListCtrl); break; case 2: ShowWindow(hApplicationPage, SW_HIDE); ShowWindow(hProcessPage, SW_HIDE); ShowWindow(hPerformancePage, SW_SHOW); BringWindowToTop(hPerformancePage); if (GetMenuItemCount(hMenu) > 5) { DeleteMenu(hMenu, 3, MF_BYPOSITION); DrawMenuBar(hMainWnd); } GetSystemInfo(&sysInfo); /* Hide CPU graph options on single CPU systems */ if (sysInfo.dwNumberOfProcessors > 1) { hSubMenu = CreatePopupMenu(); LoadStringW(hInst, IDS_MENU_ONEGRAPHALLCPUS, szTemp, 256); AppendMenuW(hSubMenu, MF_STRING, ID_VIEW_CPUHISTORY_ONEGRAPHALL, szTemp); LoadStringW(hInst, IDS_MENU_ONEGRAPHPERCPU, szTemp, 256); AppendMenuW(hSubMenu, MF_STRING, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, szTemp); LoadStringW(hInst, IDS_MENU_CPUHISTORY, szTemp, 256); AppendMenuW(hViewMenu, MF_STRING|MF_POPUP, (UINT_PTR) hSubMenu, szTemp); if (TaskManagerSettings.CPUHistory_OneGraphPerCPU) CheckMenuRadioItem(hSubMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND); else CheckMenuRadioItem(hSubMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND); } LoadStringW(hInst, IDS_MENU_SHOWKERNELTIMES, szTemp, 256); AppendMenuW(hViewMenu, MF_STRING, ID_VIEW_SHOWKERNELTIMES, szTemp); if (TaskManagerSettings.ShowKernelTimes) CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED); else CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED); /* * Give the tab control focus */ if (!bWasKeyboardInput) SetFocus(hTabWnd); break; } }