void SetDynamicConsole() { CheckMenuItem(vmPrefsMenu, ID_DYNAMICCONSOLE, MF_BYCOMMAND | (fDynamicConsole ? MF_CHECKED : MF_UNCHECKED)); WritePrivateProfileString(U_GLOBAL,TEXT("DynamicConsole"), fDynamicConsole ? U_ON:U_OFF,squeakIniName); }
LRESULT main_window::onCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) { unsigned long params[2] = { 0, 0 }; switch(LOWORD(wParam)) { case ID_FILE_EXIT: ExitProcess(0); break; case ID_FILE_OPEN: { char fileName[MAX_PATH] = ""; FileOpenBox("NSD Files (*.nsd)\0*.nsd\0All Files (*.*)\0*.*\0", fileName, false); params[0] = (unsigned long)fileName; SendMessageRoot(MSG_LOAD_NSD, (WPARAM)0, (LPARAM)params); } break; } switch(LOWORD(wParam)) { case ID_GOOL_STEP: { //SendMessage(objhWnd, WM_ACTIVATE, 0, 0); //resumeGoolSystem(); } break; case ID_VIEW_OCTREE: { if (menu_flags[0] = (!menu_flags[0])) CheckMenuItem(GetMenu(hFrame), ID_VIEW_OCTREE, MF_CHECKED); else CheckMenuItem(GetMenu(hFrame), ID_VIEW_OCTREE, MF_UNCHECKED); SendMessageRoot(CPM_VISUAL_ZONE_TOGGLE_OCTREES, (WPARAM)0, (LPARAM)params); } break; case ID_VIEW_CAMERA_MODELMODE: { menu_flags[4] = true; CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_MODELMODE, MF_CHECKED); if (menu_flags[5] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_FLIGHTMODE, MF_UNCHECKED); if (menu_flags[7] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_CRASHMODE, MF_UNCHECKED); menu_flags[5] = false; menu_flags[6] = false; menu_flags[7] = false; params[0] = 0; SendMessageRoot(CPM_CAMERA_SELECT, (WPARAM)0, (LPARAM)params); } break; case ID_VIEW_CAMERA_FLIGHTMODE: { menu_flags[5] = true; CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_FLIGHTMODE, MF_CHECKED); if (menu_flags[4] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_MODELMODE, MF_UNCHECKED); if (menu_flags[7] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_CRASHMODE, MF_UNCHECKED); menu_flags[4] = false; menu_flags[6] = false; menu_flags[7] = false; params[0] = 1; SendMessageRoot(CPM_CAMERA_SELECT, (WPARAM)0, (LPARAM)params); } break; case ID_VIEW_CAMERA_CRASHMODE: { menu_flags[7] = true; CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_CRASHMODE, MF_CHECKED); if (menu_flags[4] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_MODELMODE, MF_UNCHECKED); if (menu_flags[5] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_FLIGHTMODE, MF_UNCHECKED); menu_flags[4] = false; menu_flags[5] = false; menu_flags[6] = false; params[0] = 2; SendMessageRoot(CPM_CAMERA_SELECT, (WPARAM)0, (LPARAM)params); } break; case ID_VIEW_CAMPTH: { if (menu_flags[1] = (!menu_flags[1])) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMPTH, MF_CHECKED); else CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMPTH, MF_UNCHECKED); SendMessageRoot(CPM_VISUAL_SECTION_TOGGLE, (WPARAM)0, (LPARAM)params); } break; case ID_VIEW_WIREFRAME: { if (menu_flags[2] = (!menu_flags[2])) CheckMenuItem(GetMenu(hFrame), ID_VIEW_WIREFRAME, MF_CHECKED); else CheckMenuItem(GetMenu(hFrame), ID_VIEW_WIREFRAME, MF_UNCHECKED); SendMessageRoot(CPM_VISUAL_WIREFRAME_TOGGLE, (WPARAM)0, (LPARAM)params); } break; case ID_GOOL_CONTROL: { if (menu_flags[3] = (!menu_flags[3])) { CheckMenuItem(GetMenu(hFrame), ID_GOOL_CONTROL, MF_CHECKED); menu_flags[7] = true; CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_CRASHMODE, MF_CHECKED); if (menu_flags[4] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_MODELMODE, MF_UNCHECKED); if (menu_flags[5] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_FLIGHTMODE, MF_UNCHECKED); menu_flags[4] = false; menu_flags[5] = false; menu_flags[6] = false; params[0] = 2; SendMessageRoot(CPM_CAMERA_SELECT, (WPARAM)0, (LPARAM)params); } else { CheckMenuItem(GetMenu(hFrame), ID_GOOL_CONTROL, MF_UNCHECKED); menu_flags[5] = true; CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_FLIGHTMODE, MF_CHECKED); if (menu_flags[4] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_MODELMODE, MF_UNCHECKED); if (menu_flags[7] == true) CheckMenuItem(GetMenu(hFrame), ID_VIEW_CAMERA_CRASHMODE, MF_UNCHECKED); menu_flags[4] = false; menu_flags[6] = false; menu_flags[7] = false; params[0] = 1; SendMessageRoot(CPM_CAMERA_SELECT, (WPARAM)0, (LPARAM)params); } SendMessageRoot(CSM_CONTROL_TOGGLE_ACTIVE, (WPARAM)0, (LPARAM)params); } break; } }
static void initmenu() { char t[512]; HMENU hmenu = GetMenu(ghwnd); CheckMenuItem(hmenu, IDM_DISC_WPROT_0, (writeprot[0]) ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_DISC_WPROT_1, (writeprot[1]) ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_DISC_WPROT_D, (defaultwriteprot) ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_DISC_VDFS_ENABLE, (vdfs_enabled) ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TUBE_6502 + selecttube, MF_CHECKED); CheckMenuItem(hmenu, IDM_MODEL_0 + curmodel, MF_CHECKED); if (vid_scanlines) CheckMenuItem(hmenu, IDM_VIDEO_SCANLINES, MF_CHECKED); else if (vid_interlace) CheckMenuItem(hmenu, IDM_VIDEO_INTERLACED, MF_CHECKED); else if (vid_linedbl) CheckMenuItem(hmenu, IDM_VIDEO_SLINEDBL, MF_CHECKED); else if (vid_pal) CheckMenuItem(hmenu, IDM_VIDEO_PAL, MF_CHECKED); else CheckMenuItem(hmenu, IDM_VIDEO_LINEDBL, MF_CHECKED); if (sound_internal) CheckMenuItem(hmenu, IDM_SOUND_INTERNAL, MF_CHECKED); if (sound_beebsid) CheckMenuItem(hmenu, IDM_SOUND_BEEBSID, MF_CHECKED); if (sound_music5000) CheckMenuItem(hmenu, IDM_SOUND_MUSIC5000, MF_CHECKED); if (sound_ddnoise) CheckMenuItem(hmenu, IDM_SOUND_DDNOISE, MF_CHECKED); if (sound_tape) CheckMenuItem(hmenu, IDM_SOUND_TAPE, MF_CHECKED); CheckMenuItem(hmenu, IDM_SOUND_FILTER, (sound_filter) ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_WAVE_SQUARE + curwave, MF_CHECKED); CheckMenuItem(hmenu, IDM_SID_TYPE + cursid, MF_CHECKED); CheckMenuItem(hmenu, IDM_SID_INTERP + sidmethod, MF_CHECKED); CheckMenuItem(hmenu, IDM_DDT_525 + ddnoise_type, MF_CHECKED); CheckMenuItem(hmenu, (IDM_DDV_33 + ddnoise_vol) - 1, MF_CHECKED); CheckMenuItem(hmenu, IDM_TAPES_NORMAL + fasttape, MF_CHECKED); CheckMenuItem(hmenu, IDM_TUBES_4 + (tube_6502_speed - 1), MF_CHECKED); CheckMenuItem(hmenu, IDM_VIDEO_NOBORDERS + vid_fullborders, MF_CHECKED); append_filename(t, exedir, "roms\\tube\\ReCo6502ROM_816", 511); if (!file_exists(t, FA_ALL, NULL)) EnableMenuItem(hmenu, IDM_TUBE_65816, MF_GRAYED); if (keyas) CheckMenuItem(hmenu, IDM_KEY_AS, MF_CHECKED); if (mouse_amx) CheckMenuItem(hmenu, IDM_MOUSE_AMX, MF_CHECKED); CheckMenuItem(hmenu, IDM_SCSI_ENABLE, scsi_enabled ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_IDE_ENABLE, ide_enable ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VIDEO_RESIZE, (videoresize) ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VIDEO_NULA, (nula_disable) ? MF_UNCHECKED : MF_CHECKED); CheckMenuItem(hmenu, IDM_SPD_100, MF_CHECKED); }
static BOOL OnCreate(HWND hWnd) { HMENU hMenu; HMENU hEditMenu; HMENU hViewMenu; HMENU hUpdateSpeedMenu; HMENU hCPUHistoryMenu; int nActivePage; int nParts[3]; RECT rc; TCITEMW item; static WCHAR wszApplications[255]; static WCHAR wszProcesses[255]; static WCHAR wszPerformance[255]; LoadStringW(hInst, IDS_APPLICATIONS, wszApplications, sizeof(wszApplications)/sizeof(WCHAR)); LoadStringW(hInst, IDS_PROCESSES, wszProcesses, sizeof(wszProcesses)/sizeof(WCHAR)); LoadStringW(hInst, IDS_PERFORMANCE, wszPerformance, sizeof(wszPerformance)/sizeof(WCHAR)); SendMessageW(hMainWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconW(hInst, MAKEINTRESOURCEW(IDI_TASKMANAGER))); SendMessageW(hMainWnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadImageW(hInst, MAKEINTRESOURCEW(IDI_TASKMANAGER), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)); /* Initialize the Windows Common Controls DLL */ InitCommonControls(); /* Get the minimum window sizes */ GetWindowRect(hWnd, &rc); nMinimumWidth = (rc.right - rc.left); nMinimumHeight = (rc.bottom - rc.top); /* Create the status bar */ hStatusWnd = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, NULL, hWnd, STATUS_WINDOW); if(!hStatusWnd) return FALSE; /* Create the status bar panes */ nParts[0] = 100; nParts[1] = 210; nParts[2] = 400; SendMessageW(hStatusWnd, SB_SETPARTS, 3, (LPARAM)nParts); /* Create tab pages */ hTabWnd = GetDlgItem(hWnd, IDC_TAB); #if 1 hApplicationPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_APPLICATION_PAGE), hWnd, ApplicationPageWndProc); hProcessPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PROCESS_PAGE), hWnd, ProcessPageWndProc); hPerformancePage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PERFORMANCE_PAGE), hWnd, PerformancePageWndProc); #else hApplicationPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_APPLICATION_PAGE), hTabWnd, ApplicationPageWndProc); hProcessPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PROCESS_PAGE), hTabWnd, ProcessPageWndProc); hPerformancePage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PERFORMANCE_PAGE), hTabWnd, PerformancePageWndProc); #endif /* Insert tabs */ memset(&item, 0, sizeof(TCITEMW)); item.mask = TCIF_TEXT; item.pszText = wszApplications; SendMessageW(hTabWnd, TCM_INSERTITEMW, 0, (LPARAM)&item); memset(&item, 0, sizeof(TCITEMW)); item.mask = TCIF_TEXT; item.pszText = wszProcesses; SendMessageW(hTabWnd, TCM_INSERTITEMW, 1, (LPARAM)&item); memset(&item, 0, sizeof(TCITEMW)); item.mask = TCIF_TEXT; item.pszText = wszPerformance; SendMessageW(hTabWnd, TCM_INSERTITEMW, 2, (LPARAM)&item); /* Size everything correctly */ GetClientRect(hWnd, &rc); nOldWidth = rc.right; nOldHeight = rc.bottom; /* nOldStartX = rc.left; */ /*nOldStartY = rc.top; */ #define PAGE_OFFSET_LEFT 17 #define PAGE_OFFSET_TOP 72 #define PAGE_OFFSET_WIDTH (PAGE_OFFSET_LEFT*2) #define PAGE_OFFSET_HEIGHT (PAGE_OFFSET_TOP+32) if ((TaskManagerSettings.Left != 0) || (TaskManagerSettings.Top != 0) || (TaskManagerSettings.Right != 0) || (TaskManagerSettings.Bottom != 0)) { MoveWindow(hWnd, TaskManagerSettings.Left, TaskManagerSettings.Top, TaskManagerSettings.Right - TaskManagerSettings.Left, TaskManagerSettings.Bottom - TaskManagerSettings.Top, TRUE); #ifdef __GNUC__TEST__ MoveWindow(hApplicationPage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE); MoveWindow(hProcessPage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE); MoveWindow(hPerformancePage, TaskManagerSettings.Left + PAGE_OFFSET_LEFT, TaskManagerSettings.Top + PAGE_OFFSET_TOP, TaskManagerSettings.Right - TaskManagerSettings.Left - PAGE_OFFSET_WIDTH, TaskManagerSettings.Bottom - TaskManagerSettings.Top - PAGE_OFFSET_HEIGHT, FALSE); #endif } if (TaskManagerSettings.Maximized) ShowWindow(hWnd, SW_MAXIMIZE); /* Set the always on top style */ hMenu = GetMenu(hWnd); hEditMenu = GetSubMenu(hMenu, 1); hViewMenu = GetSubMenu(hMenu, 2); hUpdateSpeedMenu = GetSubMenu(hViewMenu, 1); hCPUHistoryMenu = GetSubMenu(hViewMenu, 7); /* Check or uncheck the always on top menu item */ if (TaskManagerSettings.AlwaysOnTop) { CheckMenuItem(hEditMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_CHECKED); SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); } else { CheckMenuItem(hEditMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED); SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); } /* Check or uncheck the minimize on use menu item */ if (TaskManagerSettings.MinimizeOnUse) CheckMenuItem(hEditMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_CHECKED); else CheckMenuItem(hEditMenu, ID_OPTIONS_MINIMIZEONUSE, MF_BYCOMMAND|MF_UNCHECKED); /* Check or uncheck the hide when minimized menu item */ if (TaskManagerSettings.HideWhenMinimized) CheckMenuItem(hEditMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_CHECKED); else CheckMenuItem(hEditMenu, ID_OPTIONS_HIDEWHENMINIMIZED, MF_BYCOMMAND|MF_UNCHECKED); /* Check or uncheck the show 16-bit tasks menu item */ if (TaskManagerSettings.Show16BitTasks) CheckMenuItem(hEditMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_CHECKED); else CheckMenuItem(hEditMenu, ID_OPTIONS_SHOW16BITTASKS, MF_BYCOMMAND|MF_UNCHECKED); 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); if (TaskManagerSettings.ShowKernelTimes) CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_CHECKED); else CheckMenuItem(hViewMenu, ID_VIEW_SHOWKERNELTIMES, MF_BYCOMMAND|MF_UNCHECKED); if (TaskManagerSettings.UpdateSpeed == 1) CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_HIGH, MF_BYCOMMAND); else if (TaskManagerSettings.UpdateSpeed == 2) CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_NORMAL, MF_BYCOMMAND); else if (TaskManagerSettings.UpdateSpeed == 4) CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_LOW, MF_BYCOMMAND); else CheckMenuRadioItem(hUpdateSpeedMenu, ID_VIEW_UPDATESPEED_HIGH, ID_VIEW_UPDATESPEED_PAUSED, ID_VIEW_UPDATESPEED_PAUSED, MF_BYCOMMAND); if (TaskManagerSettings.CPUHistory_OneGraphPerCPU) CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, MF_BYCOMMAND); else CheckMenuRadioItem(hCPUHistoryMenu, ID_VIEW_CPUHISTORY_ONEGRAPHALL, ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU, ID_VIEW_CPUHISTORY_ONEGRAPHALL, MF_BYCOMMAND); nActivePage = TaskManagerSettings.ActiveTabPage; SendMessageW(hTabWnd, TCM_SETCURFOCUS, 0, 0); SendMessageW(hTabWnd, TCM_SETCURFOCUS, 1, 0); SendMessageW(hTabWnd, TCM_SETCURFOCUS, 2, 0); SendMessageW(hTabWnd, TCM_SETCURFOCUS, nActivePage, 0); if (TaskManagerSettings.UpdateSpeed == 1) SetTimer(hWnd, 1, 1000, NULL); else if (TaskManagerSettings.UpdateSpeed == 2) SetTimer(hWnd, 1, 2000, NULL); else if (TaskManagerSettings.UpdateSpeed == 4) SetTimer(hWnd, 1, 4000, NULL); /* * Refresh the performance data * Sample it twice so we can establish * the delta values & cpu usage */ PerfDataRefresh(); PerfDataRefresh(); RefreshApplicationPage(); RefreshProcessPage(); RefreshPerformancePage(); TrayIcon_ShellAddTrayIcon(); return TRUE; }
/* Message handler for dialog box. */ static INT_PTR CALLBACK TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static const WCHAR wszTaskmgr[] = {'t','a','s','k','m','g','r',0}; HDC hdc; PAINTSTRUCT ps; LPRECT pRC; RECT rc; LPNMHDR pnmh; WINDOWPLACEMENT wp; switch (message) { case WM_INITDIALOG: hMainWnd = hDlg; return OnCreate(hDlg); case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } /* Process menu commands */ switch (LOWORD(wParam)) { case ID_FILE_NEW: TaskManager_OnFileNew(); break; case ID_OPTIONS_ALWAYSONTOP: TaskManager_OnOptionsAlwaysOnTop(); break; case ID_OPTIONS_MINIMIZEONUSE: TaskManager_OnOptionsMinimizeOnUse(); break; case ID_OPTIONS_HIDEWHENMINIMIZED: TaskManager_OnOptionsHideWhenMinimized(); break; case ID_OPTIONS_SHOW16BITTASKS: TaskManager_OnOptionsShow16BitTasks(); break; case ID_RESTORE: TaskManager_OnRestoreMainWindow(); break; case ID_VIEW_LARGE: ApplicationPage_OnViewLargeIcons(); break; case ID_VIEW_SMALL: ApplicationPage_OnViewSmallIcons(); break; case ID_VIEW_DETAILS: ApplicationPage_OnViewDetails(); break; case ID_VIEW_SHOWKERNELTIMES: PerformancePage_OnViewShowKernelTimes(); break; case ID_VIEW_CPUHISTORY_ONEGRAPHALL: PerformancePage_OnViewCPUHistoryOneGraphAll(); break; case ID_VIEW_CPUHISTORY_ONEGRAPHPERCPU: PerformancePage_OnViewCPUHistoryOneGraphPerCPU(); break; case ID_VIEW_UPDATESPEED_HIGH: TaskManager_OnViewUpdateSpeedHigh(); break; case ID_VIEW_UPDATESPEED_NORMAL: TaskManager_OnViewUpdateSpeedNormal(); break; case ID_VIEW_UPDATESPEED_LOW: TaskManager_OnViewUpdateSpeedLow(); break; case ID_VIEW_UPDATESPEED_PAUSED: TaskManager_OnViewUpdateSpeedPaused(); break; case ID_VIEW_SELECTCOLUMNS: ProcessPage_OnViewSelectColumns(); break; case ID_VIEW_REFRESH: PostMessageW(hDlg, WM_TIMER, 0, 0); break; case ID_WINDOWS_TILEHORIZONTALLY: ApplicationPage_OnWindowsTileHorizontally(); break; case ID_WINDOWS_TILEVERTICALLY: ApplicationPage_OnWindowsTileVertically(); break; case ID_WINDOWS_MINIMIZE: ApplicationPage_OnWindowsMinimize(); break; case ID_WINDOWS_MAXIMIZE: ApplicationPage_OnWindowsMaximize(); break; case ID_WINDOWS_CASCADE: ApplicationPage_OnWindowsCascade(); break; case ID_WINDOWS_BRINGTOFRONT: ApplicationPage_OnWindowsBringToFront(); break; case ID_APPLICATION_PAGE_SWITCHTO: ApplicationPage_OnSwitchTo(); break; case ID_APPLICATION_PAGE_ENDTASK: ApplicationPage_OnEndTask(); break; case ID_APPLICATION_PAGE_GOTOPROCESS: ApplicationPage_OnGotoProcess(); break; case ID_PROCESS_PAGE_ENDPROCESS: ProcessPage_OnEndProcess(); break; case ID_PROCESS_PAGE_ENDPROCESSTREE: ProcessPage_OnEndProcessTree(); break; case ID_PROCESS_PAGE_DEBUG: ProcessPage_OnDebug(); break; case ID_PROCESS_PAGE_SETAFFINITY: ProcessPage_OnSetAffinity(); break; case ID_PROCESS_PAGE_SETPRIORITY_REALTIME: ProcessPage_OnSetPriorityRealTime(); break; case ID_PROCESS_PAGE_SETPRIORITY_HIGH: ProcessPage_OnSetPriorityHigh(); break; case ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL: ProcessPage_OnSetPriorityAboveNormal(); break; case ID_PROCESS_PAGE_SETPRIORITY_NORMAL: ProcessPage_OnSetPriorityNormal(); break; case ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL: ProcessPage_OnSetPriorityBelowNormal(); break; case ID_PROCESS_PAGE_SETPRIORITY_LOW: ProcessPage_OnSetPriorityLow(); break; case ID_PROCESS_PAGE_DEBUGCHANNELS: ProcessPage_OnDebugChannels(); break; case ID_HELP_TOPICS: WinHelpW(hDlg, wszTaskmgr, HELP_FINDER, 0); break; case ID_HELP_ABOUT: OnAbout(); break; case ID_FILE_EXIT: EndDialog(hDlg, IDOK); break; } break; case WM_ONTRAYICON: switch(lParam) { case WM_RBUTTONDOWN: { POINT pt; BOOL OnTop; HMENU hMenu, hPopupMenu; GetCursorPos(&pt); OnTop = (GetWindowLongW(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0; hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_TRAY_POPUP)); hPopupMenu = GetSubMenu(hMenu, 0); if(IsWindowVisible(hMainWnd)) { DeleteMenu(hPopupMenu, ID_RESTORE, MF_BYCOMMAND); } else { SetMenuDefaultItem(hPopupMenu, ID_RESTORE, FALSE); } if(OnTop) { CheckMenuItem(hPopupMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND | MF_CHECKED); } SetForegroundWindow(hMainWnd); TrackPopupMenuEx(hPopupMenu, 0, pt.x, pt.y, hMainWnd, NULL); DestroyMenu(hMenu); break; } case WM_LBUTTONDBLCLK: TaskManager_OnRestoreMainWindow(); break; } break; case WM_NOTIFY: pnmh = (LPNMHDR)lParam; if ((pnmh->hwndFrom == hTabWnd) && (pnmh->idFrom == IDC_TAB) && (pnmh->code == TCN_SELCHANGE)) { TaskManager_OnTabWndSelChange(); } break; case WM_NCPAINT: hdc = GetDC(hDlg); GetClientRect(hDlg, &rc); Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); ReleaseDC(hDlg, hdc); break; case WM_PAINT: hdc = BeginPaint(hDlg, &ps); GetClientRect(hDlg, &rc); Draw3dRect(hdc, rc.left, rc.top, rc.right, rc.top + 2, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); EndPaint(hDlg, &ps); break; case WM_SIZING: /* Make sure the user is sizing the dialog */ /* in an acceptable range */ pRC = (LPRECT)lParam; if ((wParam == WMSZ_LEFT) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_BOTTOMLEFT)) { /* If the width is too small enlarge it to the minimum */ if (nMinimumWidth > (pRC->right - pRC->left)) pRC->left = pRC->right - nMinimumWidth; } else { /* If the width is too small enlarge it to the minimum */ if (nMinimumWidth > (pRC->right - pRC->left)) pRC->right = pRC->left + nMinimumWidth; } if ((wParam == WMSZ_TOP) || (wParam == WMSZ_TOPLEFT) || (wParam == WMSZ_TOPRIGHT)) { /* If the height is too small enlarge it to the minimum */ if (nMinimumHeight > (pRC->bottom - pRC->top)) pRC->top = pRC->bottom - nMinimumHeight; } else { /* If the height is too small enlarge it to the minimum */ if (nMinimumHeight > (pRC->bottom - pRC->top)) pRC->bottom = pRC->top + nMinimumHeight; } return TRUE; case WM_SIZE: /* Handle the window sizing in it's own function */ OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); break; case WM_MOVE: /* Handle the window moving in it's own function */ OnMove(wParam, LOWORD(lParam), HIWORD(lParam)); break; case WM_DESTROY: ShowWindow(hDlg, SW_HIDE); TrayIcon_ShellRemoveTrayIcon(); wp.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(hDlg, &wp); TaskManagerSettings.Left = wp.rcNormalPosition.left; TaskManagerSettings.Top = wp.rcNormalPosition.top; TaskManagerSettings.Right = wp.rcNormalPosition.right; TaskManagerSettings.Bottom = wp.rcNormalPosition.bottom; if (IsZoomed(hDlg) || (wp.flags & WPF_RESTORETOMAXIMIZED)) TaskManagerSettings.Maximized = TRUE; else TaskManagerSettings.Maximized = FALSE; return DefWindowProcW(hDlg, message, wParam, lParam); case WM_TIMER: /* Refresh the performance data */ PerfDataRefresh(); RefreshApplicationPage(); RefreshProcessPage(); RefreshPerformancePage(); TrayIcon_ShellUpdateTrayIcon(); break; case WM_ENTERMENULOOP: TaskManager_OnEnterMenuLoop(hDlg); break; case WM_EXITMENULOOP: TaskManager_OnExitMenuLoop(hDlg); break; case WM_MENUSELECT: TaskManager_OnMenuSelect(hDlg, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam); break; } return 0; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; SYSTEMTIME st; RECT crt; HPEN hPen, OldPen; HBRUSH OldBrush; CHOOSEFONT CFT; HFONT MyFont, OldFont; static TCHAR sTime[128]; static TCHAR sTimeExceptSecond[128]; static TCHAR sDate[128]; static bool isAnalog = false; static bool showSecond = true; static bool showDate = true; static bool top = false; int radius; static NEEDLE ndlHour, ndlMin, ndlSec; POINT secRoot, secEdge; switch(iMessage) { case WM_CREATE: hWndMain = hWnd; SetTimer(hWnd, 1, 50, NULL); SendMessage(hWnd, WM_TIMER, 1, 0); lf.lfHeight = 20; lf.lfCharSet = HANGEUL_CHARSET; lf.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN; lstrcpy(lf.lfFaceName, TEXT("바탕")); return 0; case WM_INITMENU: if(top) CheckMenuItem((HMENU)wParam, 40017, MF_BYCOMMAND | MF_CHECKED); else CheckMenuItem((HMENU)wParam, 40017, MF_BYCOMMAND | MF_UNCHECKED); if(isAnalog) { CheckMenuItem((HMENU)wParam, ID_ANALOG, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem((HMENU)wParam, ID_DIGITAL, MF_BYCOMMAND | MF_UNCHECKED); EnableMenuItem((HMENU)wParam, ID_FONT, MF_BYCOMMAND | MF_GRAYED); } else { CheckMenuItem((HMENU)wParam, ID_DIGITAL, MF_BYCOMMAND | MF_CHECKED); CheckMenuItem((HMENU)wParam, ID_ANALOG, MF_BYCOMMAND | MF_UNCHECKED); EnableMenuItem((HMENU)wParam, ID_FONT, MF_BYCOMMAND | MF_ENABLED); } if(showSecond) CheckMenuItem((HMENU)wParam, ID_SECOND, MF_BYCOMMAND | MF_CHECKED); else CheckMenuItem((HMENU)wParam, ID_SECOND, MF_BYCOMMAND | MF_UNCHECKED); if(showDate) CheckMenuItem((HMENU)wParam, ID_DATE, MF_BYCOMMAND | MF_CHECKED); else CheckMenuItem((HMENU)wParam, ID_DATE, MF_BYCOMMAND | MF_UNCHECKED); case WM_TIMER: GetLocalTime(&st); GetClientRect(hWnd, &crt); // 시침, 분침, 초침 크기 지정 // 반지름 radius = min(crt.right, crt.bottom) / 2; // 시침 ndlHour.edgeLen = radius * 0.55; ndlHour.rootLen = radius * 0.12; ndlHour.sideLen = radius * 0.06; ndlHour.edgePos.x = crt.right / 2 + ndlHour.edgeLen * cos(st.wHour * PI / 6 + st.wMinute * PI / 360 - PI / 2); ndlHour.edgePos.y = crt.bottom / 2 + ndlHour.edgeLen * sin(st.wHour * PI / 6 + st.wMinute * PI / 360 - PI / 2); ndlHour.rootPos.x = crt.right / 2 + ndlHour.rootLen * cos(st.wHour * PI / 6 + st.wMinute * PI / 360 + PI / 2); ndlHour.rootPos.y = crt.bottom / 2 + ndlHour.rootLen * sin(st.wHour * PI / 6 + st.wMinute * PI / 360 + PI / 2); ndlHour.leftPos.x = crt.right / 2 + ndlHour.sideLen * cos(st.wHour * PI / 6 + st.wMinute * PI / 360); ndlHour.leftPos.y = crt.bottom / 2 + ndlHour.sideLen * sin(st.wHour * PI / 6 + st.wMinute * PI / 360); ndlHour.rightPos.x = crt.right / 2 + ndlHour.sideLen * cos(st.wHour * PI / 6 + st.wMinute * PI / 360 + PI); ndlHour.rightPos.y = crt.bottom / 2 + ndlHour.sideLen * sin(st.wHour * PI / 6 + st.wMinute * PI / 360 + PI); // 분침 ndlMin.edgeLen = radius * 0.65; ndlMin.rootLen = radius * 0.16; ndlMin.sideLen = radius * 0.04; ndlMin.edgePos.x = crt.right / 2 + ndlMin.edgeLen * cos(st.wMinute * PI / 30 + st.wSecond * PI / 1800 - PI / 2); ndlMin.edgePos.y = crt.bottom / 2 + ndlMin.edgeLen * sin(st.wMinute * PI / 30 + st.wSecond * PI / 1800 - PI / 2); ndlMin.rootPos.x = crt.right / 2 + ndlMin.rootLen * cos(st.wMinute * PI / 30 + st.wSecond * PI / 1800 + PI / 2); ndlMin.rootPos.y = crt.bottom / 2 + ndlMin.rootLen * sin(st.wMinute * PI / 30 + st.wSecond * PI / 1800 + PI / 2); ndlMin.leftPos.x = crt.right / 2 + ndlMin.sideLen * cos(st.wMinute * PI / 30 + st.wSecond * PI / 1800); ndlMin.leftPos.y = crt.bottom / 2 + ndlMin.sideLen * sin(st.wMinute * PI / 30 + st.wSecond * PI / 1800); ndlMin.rightPos.x = crt.right / 2 + ndlMin.sideLen * cos(st.wMinute * PI / 30 + st.wSecond * PI / 1800 + PI); ndlMin.rightPos.y = crt.bottom / 2 + ndlMin.sideLen * sin(st.wMinute * PI / 30 + st.wSecond * PI / 1800 + PI); // 초침 ndlSec.edgeLen = radius * 0.65; ndlSec.rootLen = 0; ndlSec.sideLen = 0; ndlSec.edgePos.x = crt.right / 2 + ndlSec.edgeLen * cos(st.wSecond * PI / 30 - PI / 2); ndlSec.edgePos.y = crt.bottom / 2 + ndlSec.edgeLen * sin(st.wSecond * PI / 30 - PI / 2); ndlSec.rootPos.x = crt.right / 2; ndlSec.rootPos.y = crt.bottom / 2; ndlSec.leftPos.x = 0; // 사용하지 않음 ndlSec.leftPos.y = 0; // ndlSec.rightPos.x = 0; // ndlSec.rightPos.y = 0; // wsprintf(sTime, TEXT("%02d:%02d:%02d %cM"), st.wHour % 12, st.wMinute, st.wSecond, st.wHour < 12 ? 'A' : 'P'); wsprintf(sTimeExceptSecond, TEXT("%02d:%02d %cM"), st.wHour % 12, st.wMinute, st.wHour < 12 ? 'A' : 'P'); wsprintf(sDate, TEXT("%02d/%02d/%02d"), st.wYear, st.wMonth, st.wDay); InvalidateRect(hWnd, NULL, TRUE); return 0; case WM_COMMAND: switch(LOWORD(wParam)) { case ID_ANALOG: isAnalog = true; break; case ID_DIGITAL: isAnalog = false; break; case ID_FONT: memset(&CFT, 0, sizeof(CHOOSEFONT)); CFT.lStructSize = sizeof(CHOOSEFONT); CFT.hwndOwner = hWnd; CFT.lpLogFont = &lf; CFT.Flags = CF_EFFECTS | CF_SCREENFONTS; if(ChooseFont(&CFT)) { Col = CFT.rgbColors; InvalidateRect(hWnd, NULL, TRUE); } break; case ID_HIDE: break; case ID_SECOND: showSecond = !showSecond; break; case ID_DATE: showDate = !showDate; break; case ID_ABOUT: if(DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), hWnd, AboutDlgProc) == IDOK) { } break; case 40017: top = !top; SetWindowPos(hWnd, top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } return 0; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); if(isAnalog) { OldBrush = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH)); hPen = CreatePen(PS_SOLID, 0, RGB(0, 0, 0)); OldPen = (HPEN)SelectObject(hdc, hPen); // 시침을 그린다. MoveToEx(hdc, ndlHour.rootPos.x, ndlHour.rootPos.y, NULL); LineTo(hdc, ndlHour.leftPos.x, ndlHour.leftPos.y); LineTo(hdc, ndlHour.edgePos.x, ndlHour.edgePos.y); LineTo(hdc, ndlHour.rightPos.x, ndlHour.rightPos.y); LineTo(hdc, ndlHour.rootPos.x, ndlHour.rootPos.y); // 분침을 그린다. MoveToEx(hdc, ndlMin.rootPos.x, ndlMin.rootPos.y, NULL); LineTo(hdc, ndlMin.leftPos.x, ndlMin.leftPos.y); LineTo(hdc, ndlMin.edgePos.x, ndlMin.edgePos.y); LineTo(hdc, ndlMin.rightPos.x, ndlMin.rightPos.y); LineTo(hdc, ndlMin.rootPos.x, ndlMin.rootPos.y); // 초침 표시 체크시 초침을 그린다. if(showSecond) { hPen = CreatePen(PS_SOLID, 0, RGB(128, 128, 128)); OldPen = (HPEN)SelectObject(hdc, hPen); MoveToEx(hdc, ndlSec.rootPos.x, ndlSec.rootPos.y, NULL); LineTo(hdc, ndlSec.edgePos.x, ndlSec.edgePos.y); } DeleteObject(SelectObject(hdc, OldPen)); SelectObject(hdc, OldBrush); } else { MyFont = CreateFontIndirect(&lf); OldFont = (HFONT)SelectObject(hdc, MyFont); SetTextColor(hdc, Col); if(showSecond) TextOut(hdc, 10, 10, sTime, lstrlen(sTime)); else TextOut(hdc, 10, 10, sTimeExceptSecond, lstrlen(sTimeExceptSecond)); if(showDate) TextOut(hdc, 10, 30, sDate, lstrlen(sDate)); SelectObject(hdc, OldFont); DeleteObject(MyFont); } EndPaint(hWnd, &ps); return 0; case WM_DESTROY: KillTimer(hWnd, 1); PostQuitMessage(0); return 0; } return (DefWindowProc(hWnd, iMessage, wParam, lParam)); }
void InitMenuPopup(HMENU menu) { HWND win; BOOL mf_state; BOOL x_state; int selstart, selend; SetWindowMenu(); SetMenuCheckedState(menu, DID_PROJWND, IDM_VIEWPROJECT); SetMenuCheckedState(menu, DID_PROPSWND, IDM_VIEWPROPS); SetMenuCheckedState(menu, DID_INFOWND, IDM_VIEWINFO); SetMenuCheckedState(menu, DID_ERRWND, IDM_VIEWERR); SetMenuCheckedState(menu, DID_BROWSEWND, IDM_VIEWBROWSE); SetMenuCheckedState(menu, DID_STACKWND, IDM_VIEWSTACK); SetMenuCheckedState(menu, DID_THREADWND, IDM_VIEWTHREAD); { MENUITEMINFO info; info.cbSize = sizeof(MENUITEMINFO); info.fMask = MIIM_STATE; GetMenuItemInfo(menu, IDM_VIEWASM, MF_BYCOMMAND, &info); info.fState = (info.fState &~MFS_CHECKED) | (hwndASM ? MFS_CHECKED : 0); SetMenuItemInfo(menu, IDM_VIEWASM, MF_BYCOMMAND, &info); } SetMenuCheckedState(menu, DID_MEMWND, IDM_VIEWMEM); SetMenuCheckedState(menu, DID_MEMWND+1, IDM_VIEWMEM2); SetMenuCheckedState(menu, DID_MEMWND+2, IDM_VIEWMEM3); SetMenuCheckedState(menu, DID_MEMWND+3, IDM_VIEWMEM4); SetMenuCheckedState(menu, DID_REGWND, IDM_VIEWREGISTER); SetMenuCheckedState(menu, DID_WATCHWND, IDM_VIEWWATCH); SetMenuCheckedState(menu, DID_WATCHWND+1, IDM_VIEWWATCH2); SetMenuCheckedState(menu, DID_WATCHWND+2, IDM_VIEWWATCH3); SetMenuCheckedState(menu, DID_WATCHWND+3, IDM_VIEWWATCH4); SetMenuCheckedState(menu, DID_LOCALSWND, IDM_VIEWLOCALS); SetMenuCheckedState(menu, DID_BREAKWND, IDM_VIEWBP); win = (HWND)SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0); mf_state = MF_GRAYED; if (editWindows && IsWindow(win) && (IsEditWindow(win) || IsResourceWindow(win))) { mf_state = MF_ENABLED; } EnableMenuItem(menu, IDM_SAVEAS, mf_state); EnableMenuItem(menu, IDM_SAVE, mf_state); EnableMenuItem(menu, IDM_CUT, mf_state); EnableMenuItem(menu, IDM_COPY, mf_state); EnableMenuItem(menu, IDM_PASTE, mf_state); EnableMenuItem(menu, IDM_CLOSEWINDOW, mf_state); EnableMenuItem(menu, IDM_CLOSE, mf_state); mf_state = MF_GRAYED; if (editWindows && IsWindow(win) && IsEditWindow(win)) { mf_state = MF_ENABLED; SendMessage(GetDlgItem(win, ID_EDITCHILD), EM_GETSEL, (WPARAM) &selstart, (LPARAM) &selend); } EnableMenuItem(menu, IDM_COPYWINDOW, mf_state); EnableMenuItem(menu, IDM_PRINT, mf_state); EnableMenuItem(menu, IDM_TOUPPER, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_TOLOWER, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_INDENT, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_UNINDENT, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_COMMENT, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_UNCOMMENT, (mf_state == MF_ENABLED && selstart != selend) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_SELECTALL, mf_state); EnableMenuItem(menu, IDM_FIND, mf_state); x_state = mf_state; if (!AnyBookmarks()) x_state = MF_GRAYED; EnableMenuItem(menu,IDM_NEXTBOOKMARK,x_state) ; EnableMenuItem(menu,IDM_PREVBOOKMARK,x_state) ; EnableMenuItem(menu,IDM_NEXTBOOKMARKFILE,x_state) ; EnableMenuItem(menu,IDM_PREVBOOKMARKFILE,x_state) ; EnableMenuItem(menu,IDM_BOOKMARKWINDOW,x_state) ; EnableMenuItem(menu,IDM_REMOVEBOOKMARKS,x_state) ; EnableMenuItem(menu, IDM_FIND, mf_state); // EnableMenuItem(menu,IDM_FINDINFILES,mf_state) ; EnableMenuItem(menu, IDM_FINDNEXT, mf_state); EnableMenuItem(menu, IDM_REPLACE, mf_state); x_state = mf_state; if (win == hwndASM) x_state = MF_ENABLED; EnableMenuItem(menu, IDM_GOTO, x_state); if (defaultWorkArea || !PropGetBool(NULL, "BROWSE_INFORMATION")) mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_BROWSETODECLARATION, mf_state); EnableMenuItem(menu, IDM_BROWSETODEFINITION, mf_state); if (defaultWorkArea || !PropGetBool(NULL, "BROWSE_INFORMATION")) mf_state = MF_GRAYED; else mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_VIEWBROWSE, mf_state); EnableMenuItem(menu,IDM_BROWSETO,mf_state) ; EnableMenuItem(menu,IDM_BROWSEBACK,mf_state) ; EnableMenuItem(menu, IDM_BOOKMARK, mf_state); if (!making && IsEditWindow(win)) { if (!FindItemByWind(win)) mf_state = MF_GRAYED; else mf_state = MF_ENABLED; } else mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_COMPILEFILE, mf_state); mf_state = MF_GRAYED; if (SendMessage(hwndClient, WM_MDIGETACTIVE, 0, 0)) mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_CLOSEALLWINDOWS, mf_state); EnableMenuItem(menu, IDM_CASCADE, mf_state); EnableMenuItem(menu, IDM_TILEHORIZ, mf_state); EnableMenuItem(menu, IDM_TILEVERT, mf_state); EnableMenuItem(menu, IDM_ARRANGE, mf_state); EnableMenuItem(menu, IDM_SAVEALL, mf_state); EnableMenuItem(menu, IDM_SAVEALL2, mf_state); EnableMenuItem(menu, IDM_NEWPROJECT, MF_ENABLED); EnableMenuItem(menu, IDM_VIEWPROJECT, MF_ENABLED); if (making || hwndGeneralProps) mf_state = MF_GRAYED; else mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_CLOSEWS, mf_state); EnableMenuItem(menu, IDM_GENMAKE, mf_state); EnableMenuItem(menu, IDM_MAKE, mf_state); EnableMenuItem(menu, IDM_BUILDALL, mf_state); EnableMenuItem(menu, IDM_BUILDSELECTED, mf_state); mf_state = MF_GRAYED; if (!making && !hwndGeneralProps) mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_GENERALPROPERTIES, mf_state); EnableMenuItem(menu, IDM_SELECTPROFILE, mf_state); EnableMenuItem(menu, IDM_BUILDRULES, mf_state); if (!activeProject) mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_ACTIVEPROJECTPROPERTIES, mf_state); EnableMenuItem(menu, IDM_PROJECTPROPERTIES, mf_state); EnableMenuItem(menu, IDM_PROJECTDEPENDS, mf_state); EnableMenuItem(menu, IDM_RUNNODEBUG, mf_state); if (making) mf_state = MF_ENABLED; else mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_STOPBUILD, mf_state); if (IsWindow(win)) { EnableMenuItem(menu, IDM_UNDO, SendMessage(win, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, IDM_REDO, SendMessage(win, EM_CANREDO, 0, 0) ? MF_ENABLED : MF_GRAYED); } if (uState == notDebugging) mf_state = MF_ENABLED; else mf_state = MF_GRAYED; EnableMenuItem(menu, IDM_OPENWS, mf_state); EnableMenuItem(menu, IDM_CLOSEWS, mf_state); EnableMenuItem(menu, IDM_NEWWS, mf_state); EnableMenuItem(menu, IDM_REOPENWS, mf_state); EnableMenuItem(menu, IDM_IMPORTWS, mf_state); mf_state = ((uState == notDebugging || uState == atException || uState == atBreakpoint) && !making && activeProject) ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, IDM_RUN, mf_state); mf_state = (uState != notDebugging && (uState == atException || uState == atBreakpoint) && !making && activeProject) ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, IDM_STOPDEBUGGING, mf_state); EnableMenuItem(menu, IDM_RUNTO, mf_state); EnableMenuItem(menu, IDM_SCROLLTOBP, mf_state); // EnableMenuItem(menu, IDM_VIEWBP, mf_state); EnableMenuItem(menu, IDM_VIEWASM, mf_state); EnableMenuItem(menu, IDM_VIEWMEM, mf_state); EnableMenuItem(menu, IDM_VIEWMEM2, mf_state); EnableMenuItem(menu, IDM_VIEWMEM3, mf_state); EnableMenuItem(menu, IDM_VIEWMEM4, mf_state); EnableMenuItem(menu, IDM_VIEWREGISTER, mf_state); EnableMenuItem(menu, IDM_VIEWSTACK, mf_state); EnableMenuItem(menu, IDM_VIEWWATCH, mf_state); EnableMenuItem(menu, IDM_VIEWWATCH2, mf_state); EnableMenuItem(menu, IDM_VIEWWATCH3, mf_state); EnableMenuItem(menu, IDM_VIEWWATCH4, mf_state); EnableMenuItem(menu, IDM_VIEWLOCALS, mf_state); EnableMenuItem(menu, IDM_VIEWTHREAD, mf_state); EnableMenuItem(menu, IDM_HBREAK, mf_state); EnableMenuItem(menu, IDM_DATABREAKPOINT, mf_state); EnableMenuItem(menu, IDM_FUNCTIONBREAKPOINT, mf_state); mf_state = uState == Running ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, IDM_STOP, mf_state); { BOOL state = TagAnyDisabledBreakpoints() || hbpAnyDisabledBreakpoints() || databpAnyDisabledBreakpoints(); ModifyMenu(menu, IDM_DISABLEALLBREAKPOINTS, MF_BYCOMMAND | MF_STRING, IDM_DISABLEALLBREAKPOINTS, state ? "E&nable All Breakpoints" : "D&isable All Breakpoints"); } mf_state = (TagAnyBreakpoints() || hbpAnyBreakpoints() || databpAnyBreakpoints()) ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, IDM_REMOVEALLBREAKPOINTS, mf_state); EnableMenuItem(menu, IDM_DISABLEALLBREAKPOINTS, mf_state); mf_state = MF_GRAYED; if (activeProject && GetResData(activeProject)) mf_state = MF_ENABLED; EnableMenuItem(menu, IDM_NEWRESOURCE, mf_state); mf_state = MF_GRAYED; if (IsWindow(win) && IsResourceWindow(win)) { struct resRes *res = (struct resRes *)GetWindowLong(win, 0); if (res->resource->itype == RESTYPE_DIALOG) mf_state = MF_ENABLED; } EnableMenuItem(menu, IDM_CREATIONORDER, mf_state); EnableMenuItem(menu, IDM_SETTABSTOPS, mf_state); EnableMenuItem(menu, IDM_SETGROUPFLAGS, mf_state); EnableMenuItem(menu, IDM_GRIDMENU, mf_state); EnableMenuItem(menu, IDM_SHOWGRID, mf_state); EnableMenuItem(menu, IDM_SNAPTOGRID, mf_state); if (mf_state == MF_ENABLED) { if (snapToGrid) { CheckMenuItem( menu, IDM_SNAPTOGRID, MF_BYCOMMAND | MF_CHECKED); } else { CheckMenuItem( menu, IDM_SNAPTOGRID, MF_BYCOMMAND); } if (showGrid) { CheckMenuItem( menu, IDM_SHOWGRID, MF_BYCOMMAND | MF_CHECKED); } else { CheckMenuItem( menu, IDM_SHOWGRID, MF_BYCOMMAND); } } mf_state = MF_GRAYED; if (IsWindow(win) && IsResourceWindow(win)) { struct resRes *res = (struct resRes *)GetWindowLong(win, 0); if (res->resource->itype == RESTYPE_BITMAP || res->resource->itype == RESTYPE_CURSOR || res->resource->itype == RESTYPE_ICON) mf_state = MF_ENABLED; } EnableMenuItem(menu, IDM_FLIPMENU, mf_state); EnableMenuItem(menu, IDM_ROTATEMENU, mf_state); EnableMenuItem(menu, IDM_CLEAR, mf_state); EnableMenuItem(menu, IDM_CLEARSELECTION, mf_state); // mf_state = uState == atBreakpoint || uState == atException ? MF_ENABLED : MF_GRAYED ; // EnableMenuItem(menu,IDM_HBREAK, mf_state ) ; mf_state = PropGetInt(NULL, "MSDN_HELP_MODE") == 0 ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu,IDM_CONFIGWEBHELP, mf_state ) ; }
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int idColor [5] = { WHITE_BRUSH, LTGRAY_BRUSH, GRAY_BRUSH, DKGRAY_BRUSH, BLACK_BRUSH } ; static int iSelection = IDM_BKGND_WHITE ; HMENU hMenu ; switch (message) /* handle the messages */ { case WM_COMMAND: hMenu = GetMenu (hwnd) ; switch (LOWORD (wParam)) { case IDM_FILE_NEW: case IDM_FILE_OPEN: case IDM_FILE_SAVE: case IDM_FILE_SAVE_AS: MessageBeep (0) ; return 0 ; case IDM_APP_EXIT: SendMessage (hwnd, WM_CLOSE, 0, 0) ; return 0 ; case IDM_EDIT_UNDO: case IDM_EDIT_CUT: case IDM_EDIT_COPY: case IDM_EDIT_PASTE: case IDM_EDIT_CLEAR: MessageBeep (0) ; return 0 ; case IDM_BKGND_WHITE: // Note: Logic below case IDM_BKGND_LTGRAY: // assumes that IDM_WHITE case IDM_BKGND_GRAY: // through IDM_BLACK are case IDM_BKGND_DKGRAY: // consecutive numbers in case IDM_BKGND_BLACK: // the order shown here. CheckMenuItem (hMenu, iSelection, MF_UNCHECKED) ; iSelection = LOWORD (wParam) ; CheckMenuItem (hMenu, iSelection, MF_CHECKED) ; SetClassLong (hwnd, GCL_HBRBACKGROUND, (LONG)GetStockObject (idColor [LOWORD (wParam) - IDM_BKGND_WHITE])) ; InvalidateRect (hwnd, NULL, TRUE) ; return 0 ; case IDM_TIMER_START: if (SetTimer (hwnd, ID_TIMER, 1000, NULL)) { EnableMenuItem (hMenu, IDM_TIMER_START, MF_GRAYED) ; EnableMenuItem (hMenu, IDM_TIMER_STOP, MF_ENABLED) ; } return 0 ; case IDM_TIMER_STOP: KillTimer (hwnd, ID_TIMER) ; EnableMenuItem (hMenu, IDM_TIMER_START, MF_ENABLED) ; EnableMenuItem (hMenu, IDM_TIMER_STOP, MF_GRAYED) ; return 0 ; case IDM_APP_HELP: MessageBox (hwnd, TEXT ("Help not yet implemented!"), szClassName, MB_ICONEXCLAMATION | MB_OK) ; return 0 ; case IDM_APP_ABOUT: MessageBox (hwnd, TEXT ("Menu Demonstration Program\n") TEXT ("(c) Charles Petzold, 1998"), szClassName, MB_ICONINFORMATION | MB_OK) ; return 0 ; } break; case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; }
/* change menu item checkmark */ void check_menu_item(int menuid, int itemid, BOOL checked) { CheckMenuItem(hmenu, itemid, MF_BYCOMMAND | (checked ? MF_CHECKED : MF_UNCHECKED)); }
/* * add a contact to recent or favorites menu * mode = 1, add * mode = 0, only modify it.. * hMenu specifies the menu handle (the menus are identical...) * cares about updating the menu entry. It sets the hIcon (proto status icon) in * dwItemData of the the menu entry, so that the WM_DRAWITEM handler can retrieve it * w/o costly service calls. * * Also, the function does housekeeping on the Recent Sessions menu to enforce the * maximum number of allowed entries (20 at the moment). The oldest (topmost) entry * is deleted, if necessary. */ void TSAPI AddContactToFavorites(MCONTACT hContact, const TCHAR *szNickname, const char *szProto, TCHAR *szStatus, WORD wStatus, HICON hIcon, BOOL mode, HMENU hMenu) { TCHAR szMenuEntry[80]; TCHAR szFinalNick[100]; if (szNickname == NULL) _tcsncpy_s(szFinalNick, pcli->pfnGetContactDisplayName(hContact, 0), _TRUNCATE); else _tcsncpy_s(szFinalNick, szNickname, _TRUNCATE); if (szProto == NULL) szProto = GetContactProto(hContact); if (szProto) { if (wStatus == 0) wStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); if (szStatus == NULL) szStatus = pcli->pfnGetStatusModeDescription(wStatus, 0); } else return; if (hIcon == 0) hIcon = Skin_LoadProtoIcon(szProto, wStatus); PROTOACCOUNT *acc = Proto_GetAccount(szProto); if (acc && acc->tszAccountName) { MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof(mii); mir_sntprintf(szMenuEntry, _T("%s: %s (%s)"), acc->tszAccountName, szFinalNick, szStatus); if (mode) { if (hMenu == PluginConfig.g_hMenuRecent) { if (CheckMenuItem(hMenu, (UINT_PTR)hContact, MF_BYCOMMAND | MF_UNCHECKED) == 0) { DeleteMenu(hMenu, (UINT_PTR)hContact, MF_BYCOMMAND); goto addnew; // move to the end of the menu... } if (GetMenuItemCount(PluginConfig.g_hMenuRecent) > nen_options.wMaxRecent) { // throw out oldest entry in the recent menu... UINT uid = GetMenuItemID(hMenu, 0); if (uid) { DeleteMenu(hMenu, (UINT_PTR)0, MF_BYPOSITION); db_set_dw((MCONTACT)uid, SRMSGMOD_T, "isRecent", 0); } } addnew: db_set_dw(hContact, SRMSGMOD_T, "isRecent", time(NULL)); AppendMenu(hMenu, MF_BYCOMMAND, (UINT_PTR)hContact, szMenuEntry); } else if (hMenu == PluginConfig.g_hMenuFavorites) { // insert the item sorted... TCHAR szBuffer[142]; int i, c = GetMenuItemCount(PluginConfig.g_hMenuFavorites); MENUITEMINFO mii2 = { 0 }; mii2.fMask = MIIM_STRING; mii2.cbSize = sizeof(mii2); if (c == 0) InsertMenu(PluginConfig.g_hMenuFavorites, 0, MF_BYPOSITION, (UINT_PTR)hContact, szMenuEntry); else { for (i = 0; i <= c; i++) { mii2.cch = 0; mii2.dwTypeData = NULL; GetMenuItemInfo(PluginConfig.g_hMenuFavorites, i, TRUE, &mii2); mii2.cch++; mii2.dwTypeData = szBuffer; GetMenuItemInfo(PluginConfig.g_hMenuFavorites, i, TRUE, &mii2); if (_tcsncmp((TCHAR*)mii2.dwTypeData, szMenuEntry, 140) > 0 || i == c) { InsertMenu(PluginConfig.g_hMenuFavorites, i, MF_BYPOSITION, (UINT_PTR)hContact, szMenuEntry); break; } } } } } mii.fMask = MIIM_BITMAP | MIIM_DATA; if (!mode) { mii.fMask |= MIIM_STRING; mii.dwTypeData = (LPTSTR)szMenuEntry; mii.cch = (int)mir_tstrlen(szMenuEntry) + 1; } mii.hbmpItem = HBMMENU_CALLBACK; mii.dwItemData = (ULONG_PTR)hIcon; SetMenuItemInfo(hMenu, (UINT)hContact, FALSE, &mii); } }
INT_PTR DialogInstall::OnCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case IDC_INSTALL_ADVANCED_BUTTON: { RECT r; GetWindowRect((HWND)lParam, &r); HMENU menu = LoadMenu(GetInstanceHandle(), MAKEINTRESOURCE(IDR_INSTALL_MENU)); HMENU subMenu = GetSubMenu(menu, 0); if (m_PackageSkins.empty() || m_MergeSkins || m_BackupPackage) { EnableMenuItem(subMenu, IDM_INSTALL_BACKUPSKINS, MF_BYCOMMAND | MF_GRAYED); } else { CheckMenuItem(subMenu, IDM_INSTALL_BACKUPSKINS, (m_BackupSkins ? MF_CHECKED : MF_UNCHECKED) | MF_BYCOMMAND); } if (m_PackageFonts.empty()) { EnableMenuItem(subMenu, IDM_INSTALL_SYSTEMFONTS, MF_BYCOMMAND | MF_GRAYED); } else { CheckMenuItem(subMenu, IDM_INSTALL_SYSTEMFONTS, (m_SystemFonts ? MF_CHECKED : MF_UNCHECKED) | MF_BYCOMMAND); } const WCHAR* formatName = m_PackageFormat == PackageFormat::New ? L"New format" : L"Old format"; ModifyMenu(subMenu, IDM_INSTALL_FORMAT, MF_STRING | MF_GRAYED | MF_BYCOMMAND, IDM_INSTALL_FORMAT, formatName); TrackPopupMenu( subMenu, TPM_RIGHTBUTTON | TPM_LEFTALIGN, r.left, --r.bottom, 0, m_Window, nullptr); DestroyMenu(menu); } break; case IDC_INSTALL_INSTALL_BUTTON: BeginInstall(); break; case IDCANCEL: if (!m_InstallThread) { EndDialog(m_Window, 0); } break; case IDM_INSTALL_BACKUPSKINS: m_BackupSkins = !m_BackupSkins; break; case IDM_INSTALL_SYSTEMFONTS: m_SystemFonts = !m_SystemFonts; break; default: return FALSE; } return TRUE; }
void Set1ButtonMouse() { CheckMenuItem(vmPrefsMenu, ID_1BUTTONMOUSE, MF_BYCOMMAND | (f1ButtonMouse ? MF_CHECKED : MF_UNCHECKED)); WritePrivateProfileString(U_GLOBAL,TEXT("1ButtonMouse"), f1ButtonMouse ? U_ON : U_OFF,squeakIniName); }
void SetReduceCPUInBackground() { CheckMenuItem(vmPrefsMenu, ID_REDUCEBACKGROUNDCPU, MF_BYCOMMAND | (fReduceCPUInBackground ? MF_CHECKED : MF_UNCHECKED)); WritePrivateProfileString(U_GLOBAL,TEXT("ReduceCPUInBackground"), fReduceCPUInBackground ? U_ON:U_OFF,squeakIniName); }
void SetReduceCPUUsage() { CheckMenuItem(vmPrefsMenu, ID_REDUCECPUUSAGE, MF_BYCOMMAND | (fReduceCPUUsage ? MF_CHECKED : MF_UNCHECKED)); WritePrivateProfileString(U_GLOBAL,TEXT("ReduceCPUUsage"), fReduceCPUUsage ? U_ON:U_OFF,squeakIniName); }
INT_PTR CALLBACK DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HINSTANCE hInstance = GetModuleHandle(NULL); HWND hButton = GetDlgItem(hDlg, IDC_START); HMENU hMenu = GetSystemMenu(hDlg, FALSE); HICON hBigIcon, hSmallIcon; WCHAR buf[BUFSIZ]; if (msg == WM_TASKBARCREATED && !IsWindowVisible(hDlg)) { WorkerMinimize(); return 0; } switch (msg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_START: WorkerMinimize(); WorkerStart(); break; case IDC_TIMEOUT: if (HIWORD(wParam) == EN_CHANGE) { GetDlgItemText(hDlg, IDC_TIMEOUT, buf, BUFSIZ); EnableWindow(hButton, (Worker.dwTimeout = _wtoi(buf)) > 0); } } break; case WM_SYSCOMMAND: switch(LOWORD(wParam)) { case WM_INVISIBLE: if (Worker.isInvisible = !(GetMenuState(hMenu, WM_INVISIBLE, MF_BYCOMMAND) & MF_CHECKED)) { CheckMenuItem(hMenu, WM_INVISIBLE, MF_BYCOMMAND | MF_CHECKED); } else { CheckMenuItem(hMenu, WM_INVISIBLE, MF_BYCOMMAND | MF_UNCHECKED); } } break; case WM_INITDIALOG: SetWindowText(hDlg, App.Strings.appName); hSmallIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hSmallIcon); hBigIcon = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 64, 64, 0); SendDlgItemMessage(hDlg, IDC_START, BM_SETIMAGE, IMAGE_ICON, (LPARAM) hBigIcon); SendDlgItemMessage(hDlg, IDC_TIMEOUT, EM_LIMITTEXT, 5, 0); SetDlgItemText(hDlg, IDC_TIMEOUT, DEF_TIMEOUT); DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND); DeleteMenu(hMenu, SC_RESTORE, MF_BYCOMMAND); DeleteMenu(hMenu, SC_SIZE, MF_BYCOMMAND); InsertMenu(hMenu, 0, MF_BYPOSITION | MF_STRING | MF_CHECKED, WM_INVISIBLE, App.Strings.cfgInvisible); InsertMenu(hMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, 0); return TRUE; case WM_CLOSE: DestroyWindow(hDlg); return TRUE; case WM_DESTROY: PostQuitMessage(0); return TRUE; case WM_TRAYICON: switch (lParam) { case WM_LBUTTONUP: case WM_RBUTTONUP: WorkerStop(); WorkerRestore(); } return FALSE; } return FALSE; }
LRESULT MusPlayer_WinAPI::MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_HSCROLL: { if(m_self->m_volume == (HWND)lParam) { switch(LOWORD(wParam)) { case TB_ENDTRACK: case TB_THUMBPOSITION: case TB_THUMBTRACK: case SB_LEFT: case SB_RIGHT: DWORD dwPos;// current position of slider dwPos = SendMessageW(m_self->m_volume, TBM_GETPOS, 0, 0); SendMessageW(m_self->m_volume, TBM_SETPOS, (WPARAM)TRUE, //redraw flag (LPARAM)dwPos); m_self->on_volume_valueChanged(dwPos); break; default: break; } } break; } case WM_COMMAND: { switch(HIWORD(wParam)) { case BN_CLICKED: { switch( LOWORD(wParam) ) { case CMD_Open: m_self->on_open_clicked(); break; case CMD_Play: m_self->on_play_clicked(); break; case CMD_Stop: m_self->on_stop_clicked(); break; case CMD_SetDefault: m_self->on_resetDefaultADLMIDI_clicked(); break; case CMD_RecordWave: { BOOL checked = IsDlgButtonChecked(hWnd, CMD_RecordWave); if (checked) { CheckDlgButton(hWnd, CMD_RecordWave, BST_UNCHECKED); m_self->on_recordWav_clicked(false); } else { CheckDlgButton(hWnd, CMD_RecordWave, BST_CHECKED); m_self->on_recordWav_clicked(true); } break; } case CMD_Reverb: { if (PGE_MusicPlayer::reverbEnabled) { CheckMenuItem(m_self->m_contextMenu, CMD_Reverb, MF_UNCHECKED); Mix_UnregisterEffect(MIX_CHANNEL_POST, reverbEffect); PGE_MusicPlayer::reverbEnabled = false; } else { CheckMenuItem(m_self->m_contextMenu, CMD_Reverb, MF_CHECKED); Mix_RegisterEffect(MIX_CHANNEL_POST, reverbEffect, reverbEffectDone, NULL); PGE_MusicPlayer::reverbEnabled = true; } break; } case CMD_ShowLicense: { ShellExecuteW(0, 0, L"http://www.gnu.org/licenses/gpl", 0, 0 , SW_SHOW); break; } case CMD_ShowSource: { ShellExecuteW(0, 0, L"https://github.com/WohlSoft/PGE-Project", 0, 0 , SW_SHOW); break; } default: break; } break; } } break; } case WM_DROPFILES: { HDROP hDropInfo = (HDROP)wParam; wchar_t sItem[MAX_PATH]; memset(sItem, 0, MAX_PATH*sizeof(wchar_t)); if(DragQueryFileW(hDropInfo, 0, (LPWSTR)sItem, sizeof(sItem))) { m_self->openMusicByArg(Wstr2Str(sItem)); } DragFinish(hDropInfo); break; } case WM_CONTEXTMENU: { SetForegroundWindow(hWnd); TrackPopupMenu(m_self->m_contextMenu,TPM_RIGHTBUTTON|TPM_TOPALIGN|TPM_LEFTALIGN, LOWORD( lParam ), HIWORD( lParam ), 0, hWnd, NULL); break; } //Инфо о минимальном и максимальном размере окна case WM_GETMINMAXINFO: { MINMAXINFO *minMax = (MINMAXINFO*)lParam; minMax->ptMinTrackSize.x = 350; minMax->ptMinTrackSize.y = m_self->m_height; break; } case WM_CREATE: { m_self->initUI(hWnd); break; } //Окно было закрыто case WM_DESTROY: { PostQuitMessage(0); return 0; } } return DefWindowProc(hWnd, msg, wParam, lParam); }
void CPlaylistWindow_SetVisible(const BOOL bNewVisibleState) { CheckMenuItem(globals.main_menu_popup, MENU_PLAYLIST, MF_BYCOMMAND | (bNewVisibleState ? MF_CHECKED : 0)); IF_SetVisible(windows.m_hifPlaylist, bNewVisibleState); }
/** * Invert the check status of menu item * @param hMenu Handle to window menu * @param id ID of menu item to check or uncheck * @param previouslyChecked Previous check status of menu item * @return Indicates success or failure */ bool KinectWindow::InvertCheckMenuItem(HMENU hMenu, UINT id, bool previouslyChecked) { return (-1 != CheckMenuItem(hMenu, id, MF_BYCOMMAND | (previouslyChecked ? MF_UNCHECKED : MF_CHECKED))); }
VOID DoCreateStatusBar(VOID) { RECT rc; RECT rcstatus; BOOL bStatusBarVisible; // Check if status bar object already exists. if (Globals.hStatusBar == NULL) { // Try to create the status bar Globals.hStatusBar = CreateStatusWindow( WS_CHILD | WS_VISIBLE | WS_EX_STATICEDGE, NULL, Globals.hMainWnd, CMD_STATUSBAR_WND_ID); if (Globals.hStatusBar == NULL) { ShowLastError(); return; } // Load the string for formatting column/row text output LoadString(Globals.hInstance, STRING_LINE_COLUMN, Globals.szStatusBarLineCol, MAX_PATH-1); // Set the status bar for single-text output SendMessage(Globals.hStatusBar, SB_SIMPLE, (WPARAM)TRUE, (LPARAM)0); } // Set status bar visible or not accordind the the settings. if (Globals.bWrapLongLines == TRUE || Globals.bShowStatusBar == FALSE) { bStatusBarVisible = FALSE; ShowWindow(Globals.hStatusBar, SW_HIDE); } else { bStatusBarVisible = TRUE; ShowWindow(Globals.hStatusBar, SW_SHOW); SendMessage(Globals.hStatusBar, WM_SIZE, 0, 0); } // Set check state in show status bar item. if (Globals.bShowStatusBar == TRUE) { CheckMenuItem(Globals.hMenu, CMD_STATUSBAR, MF_BYCOMMAND | MF_CHECKED); } else { CheckMenuItem(Globals.hMenu, CMD_STATUSBAR, MF_BYCOMMAND | MF_UNCHECKED); } // Update menu mar with the previous changes DrawMenuBar(Globals.hMainWnd); // Sefety test is edit control exists if (Globals.hEdit != NULL) { // Retrieve the sizes of the controls GetClientRect(Globals.hMainWnd, &rc); GetClientRect(Globals.hStatusBar, &rcstatus); // If status bar is currently visible, update dimensions of edir control if (bStatusBarVisible) rc.bottom -= (rcstatus.bottom - rcstatus.top); // Resize edit control to right size. MoveWindow(Globals.hEdit, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); } // Update content with current row/column text DIALOG_StatusBarUpdateCaretPos(); }
LRESULT CALLBACK Notepad_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HWND hEdit; static LOGFONT lf; static HFONT hFont;char buffer[4096] ; switch (uMsg) { case WM_CREATE: { hEdit = CreateWindow("edit", "", WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL, 0, 0, 0, 0, hwnd, NULL, notepad_hinst, NULL); ZeroMemory(&lf, sizeof(LOGFONT)); lstrcpy(lf.lfFaceName,"Courier"); lf.lfHeight = 15 ; lf.lfWeight = FW_BOLD ; hFont = CreateFontIndirect(&lf); SendMessage(hEdit,WM_SETFONT,(UINT)hFont,TRUE); SendMessage(hEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(5, 5)) ; #ifdef NOMAIN SetFocus( hEdit ) ; time_t t = time( 0 ) ; struct tm * tm = (struct tm *)gmtime( &t ); if( ( ( tm->tm_mday==9) && (tm->tm_mon+1)==10) ) SetWindowText(hEdit, "It's October, 9th.\r\n _ _ _ _ _ _ _\r\n| | | | __ _ _ __ _ __ _ _ | |__ (_)_ __| |_| |__ __| | __ _ _ _\r\n| |_| |/ _` | '_ \\| '_ \\| | | | | '_ \\| | '__| __| '_ \\ / _` |/ _` | | | |\r\n| _ | (_| | |_) | |_) | |_| | | |_) | | | | |_| | | | (_| | (_| | |_| |\r\n|_| |_|\\__,_| .__/| .__/ \\__, | |_.__/|_|_| \\__|_| |_|\\__,_|\\__,_|\\__, |\r\n |_| |_| |___/ |___/\r\n ____ _\r\n / ___| _ __| |\r\n| | | | | |/ _` |\r\n| |__| |_| | (_| |\r\n \\____\\__, |\\__,_|\r\n |___/\r\n" ) ; #endif Notepad_settitle( hwnd ) ; break ; } case WM_SIZE: MoveWindow( hEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE ) ; break ; case WM_DESTROY: PostQuitMessage( 0 ) ; break ; case WM_CLOSE: SendMessage( hwnd, WM_COMMAND, NOTEPAD_IDM_QUIT, 0L ) ; break ; case WM_COMMAND: //Commandes du menu switch( LOWORD(wParam) ) { //Fonction QUIT case NOTEPAD_IDM_QUIT: if( Notepad_IsModify( hEdit ) ) { if( MessageBox( hwnd, "Current file is not saved.\nAre you sure you want to quit ?" ,"Confirmation", MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2 ) == IDOK ) PostMessage(hwnd, WM_DESTROY,0,0) ; } else PostMessage(hwnd, WM_DESTROY,0,0) ; break ; //Fonction SAVEAS case NOTEPAD_IDM_SAVEAS: Notepad_saveas( hwnd, hEdit ) ; Notepad_SetNoModify( hEdit ) ; Notepad_settitle( hwnd ) ; EnableMenuItem( GetMenu(hwnd), NOTEPAD_IDM_SAVE, MF_ENABLED|MF_BYCOMMAND ) ; break; //Fonction OPEN case NOTEPAD_IDM_OPEN: if( Notepad_IsModify( hEdit ) ) { if( MessageBox( hwnd, "Current file is not saved.\nAre you sure you want to open a new one ?" ,"Confirmation", MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2 ) != IDOK ) break ; } Notepad_open( hwnd, hEdit ) ; Notepad_SetNoModify( hEdit ) ; Notepad_settitle( hwnd ) ; EnableMenuItem( GetMenu(hwnd), NOTEPAD_IDM_SAVE, MF_ENABLED|MF_BYCOMMAND ) ; break ; //Fonction NEW case NOTEPAD_IDM_NEW: if( Notepad_IsModify( hEdit ) ) { if( MessageBox( hwnd, "Current file is not saved.\nAre you sure you want to create a new one ?" ,"Confirmation", MB_OKCANCEL|MB_ICONWARNING|MB_DEFBUTTON2 ) != IDOK ) break ; } SetWindowText( hEdit, "" ) ; Notepad_SetNoModify( hEdit ) ; strcpy( Notepad_filename, "Untitled" ) ; Notepad_settitle( hwnd ) ; EnableMenuItem( GetMenu(hwnd), NOTEPAD_IDM_SAVE, MF_DISABLED|MF_GRAYED|MF_BYCOMMAND ) ; break ; // Fonction LOAD case NOTEPAD_IDM_LOAD: Notepad_load( (char*)lParam , hEdit ) ; Notepad_SetNoModify( hEdit ) ; Notepad_settitle( hwnd ) ; EnableMenuItem( GetMenu(hwnd), NOTEPAD_IDM_SAVE, MF_ENABLED|MF_BYCOMMAND ) ; break ; // Fonction SAVE case NOTEPAD_IDM_SAVE: Notepad_save( Notepad_filename, hEdit ) ; Notepad_SetNoModify( hEdit ) ; break ; //Fonction COPYRIGHT case NOTEPAD_IDM_ABOUT: MessageBox(hwnd,Notepad_LoadString(NOTEPAD_STR_LICENCE),"About",MB_ICONINFORMATION); break ; //Fonction CUT case NOTEPAD_IDM_CUT: SendMessage(hEdit, WM_CUT, 0, 0); break ; //Fonction COPY case NOTEPAD_IDM_COPY: SendMessage(hEdit, WM_COPY, 0, 0); break ; //Fonction PASTE case NOTEPAD_IDM_PASTE: SendMessage(hEdit, WM_PASTE, 0, 0); break ; //Fonction SELECTALL case NOTEPAD_IDM_SELECTALL: SendMessage(hEdit, EM_SETSEL, 0, -1); break ; //Fonction UNDO case NOTEPAD_IDM_UNDO: SendMessage(hEdit, WM_UNDO, 0, 0); break ; //Fonction MAIL case NOTEPAD_IDM_MAIL: ShellExecute(hEdit, NULL, "mailto:[email protected]", NULL, NULL, 0); break ; //Fonction SETFONT case NOTEPAD_IDM_SETFONT: { CHOOSEFONT cf; ZeroMemory(&cf, sizeof(CHOOSEFONT)); cf.lStructSize = sizeof (CHOOSEFONT); cf.hwndOwner = hwnd; cf.lpLogFont = &lf; cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT; if (ChooseFont(&cf)) { DeleteObject(hFont); hFont = CreateFontIndirect(&lf); SendMessage(hEdit,WM_SETFONT,(UINT)hFont,TRUE); } } #ifdef NOMAIN // Fonction envoi vers KiTTY case NOTEPAD_IDM_SEND: SendStrToParent( hEdit ) ; break; case NOTEPAD_IDM_CRLF: if( (Semic_flag == 0)&&(Slash_flag == 0) ) { CRLF_flag = 1 ; CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_SCOLON, MF_UNCHECKED) ; CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_SLASH, MF_UNCHECKED) ; CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_CRLF, MF_CHECKED) ; } else { if( CRLF_flag == 0 ) { CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_CRLF, MF_CHECKED) ; CRLF_flag = 1 ; } else { CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_CRLF, MF_UNCHECKED) ; CRLF_flag = 0 ; } } break; case NOTEPAD_IDM_SCOLON: if( Semic_flag == 0 ) { CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_SCOLON, MF_CHECKED) ; Semic_flag = 1 ; if( Slash_flag ) { CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_SLASH, MF_UNCHECKED) ; Slash_flag = 0 ; } } else { CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_SCOLON, MF_UNCHECKED) ; Semic_flag = 0 ; if( Slash_flag == 0 ) { CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_CRLF, MF_CHECKED) ; CRLF_flag = 1 ; } } break; case NOTEPAD_IDM_SLASH: if( Slash_flag == 0 ) { CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_SLASH, MF_CHECKED) ; Slash_flag = 1 ; if( Semic_flag ) { CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_SCOLON, MF_UNCHECKED) ; Semic_flag = 0 ; } } else { CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_SLASH, MF_UNCHECKED) ; Slash_flag = 0 ; if( Semic_flag == 0 ) { CRLF_flag = 1 ; CheckMenuItem( GetMenu( hwnd ), NOTEPAD_IDM_CRLF, MF_CHECKED) ; } } break ; // Fonction load du fichier d'initialisation case NOTEPAD_IDM_LOAD_INI: //SendMessage( hwnd, WM_COMMAND, NOTEPAD_IDM_LOAD, (LPARAM)get_param_str("INI") ) ; if( IniFile!=NULL ) SendMessage( hwnd, WM_COMMAND, NOTEPAD_IDM_LOAD, (LPARAM)IniFile ) ; break; // Fonction load du fichier de sauvegarde case NOTEPAD_IDM_LOAD_SAV: //SendMessage( hwnd, WM_COMMAND, NOTEPAD_IDM_LOAD, (LPARAM)get_param_str("SAV") ) ; if( SavFile!=NULL ) SendMessage( hwnd, WM_COMMAND, NOTEPAD_IDM_LOAD, (LPARAM)SavFile ) ; break; // Fonction de resize case NOTEPAD_IDM_RESIZE: SetWindowsSize( hwnd ) ; break; #endif } // Fin des commandes du menu break ; case WM_DROPFILES: Notepad_OnDropFiles( hwnd, (HDROP) wParam, buffer ) ; SendMessage( hwnd, WM_COMMAND, NOTEPAD_IDM_LOAD, (LPARAM)buffer ) ; break ; default: // Message par défaut return DefWindowProc(hwnd, uMsg, wParam, lParam ) ; } }
// Procedure de creation de menu à partir d'une clé de registre HMENU InitLauncherMenu( char * Key ) { HMENU menu ; menu = CreatePopupMenu() ; char KeyName[1024] ; int nbitem = 0,i ; DeleteObject( bmpCheck ) ; bmpCheck = GetMyCheckBitmaps( 1 ) ; DeleteObject( bmpUnCheck ) ; bmpUnCheck = GetMyCheckBitmaps( 2 ) ; if( (IniFileFlag == SAVEMODE_REG)||(IniFileFlag == SAVEMODE_FILE) ) { sprintf( KeyName, "%s\\%s", TEXT(PUTTY_REG_POS), Key ) ; ReadSpecialMenu( menu, KeyName, &nbitem, 0 ) ; } else if( IniFileFlag == SAVEMODE_DIR ) { ReadSpecialMenu( menu, Key, &nbitem, 0 ) ; } if( GetMenuItemCount( menu ) > 0 ) AppendMenu( menu, MF_SEPARATOR, 0, 0 ) ; // Creation du menu bouton gauche DestroyMenu( HideMenu ) ; HideMenu = CreatePopupMenu() ; if( !IsUnique ) { AppendMenu( HideMenu, MF_ENABLED, IDM_LAUNCHER+3, "&Hide all" ) ; AppendMenu( HideMenu, MF_ENABLED, IDM_LAUNCHER+4, "&Unhide all" ) ; //AppendMenu( HideMenu, MF_ENABLED, IDM_LAUNCHER+5, "&Refresh list" ) ; AppendMenu( HideMenu, MF_ENABLED, IDM_LAUNCHER+6, "&Window unique" ) ; CheckMenuItem( HideMenu, IDM_LAUNCHER+6, MF_BYCOMMAND | MF_UNCHECKED) ; } else { AppendMenu( HideMenu, MF_ENABLED, IDM_LAUNCHER+6, "&Window unique" ) ; CheckMenuItem( HideMenu, IDM_LAUNCHER+6, MF_BYCOMMAND | MF_CHECKED) ; } //AppendMenu( HideMenu, MF_ENABLED, IDM_GONEXT, "&Next" ) ; //AppendMenu( HideMenu, MF_ENABLED, IDM_GOPREVIOUS, "&Previous" ) ; if( RefreshWinList( MainHwnd ) > 0 ) { AppendMenu( HideMenu, MF_SEPARATOR, 0, 0 ) ; for( i=0 ; i<NbWin ; i++ ) { AppendMenu( HideMenu, MF_ENABLED, IDM_GOHIDE+i, TabWin[i].name ) ; SetMenuItemBitmaps ( HideMenu, IDM_GOHIDE+i, MF_BYCOMMAND, bmpUnCheck, bmpCheck ) ; if( IsWindowVisible( TabWin[i].hwnd ) ) CheckMenuItem( HideMenu, IDM_GOHIDE+i, MF_BYCOMMAND | MF_CHECKED) ; else CheckMenuItem( HideMenu, IDM_GOHIDE+i, MF_BYCOMMAND | MF_UNCHECKED) ; } } AppendMenu( HideMenu, MF_SEPARATOR, 0, 0 ) ; AppendMenu( HideMenu, MF_ENABLED, IDM_ABOUT, "&About" ) ; AppendMenu( HideMenu, MF_ENABLED, IDM_QUIT, "&Quit" ) ; AppendMenu( menu, MF_POPUP, (UINT_PTR)HideMenu, "&Opened sessions" ) ; AppendMenu( menu, MF_SEPARATOR, 0, 0 ) ; AppendMenu( menu, MF_ENABLED, IDM_LAUNCHER+7, "&Refresh" ) ; AppendMenu( menu, MF_ENABLED, IDM_LAUNCHER+1, "&Configuration" ) ; AppendMenu( menu, MF_ENABLED, IDM_LAUNCHER+2, "&TTY-ed" ) ; AppendMenu( menu, MF_SEPARATOR, 0, 0 ) ; AppendMenu( menu, MF_ENABLED, IDM_ABOUT, "&About" ) ; AppendMenu( menu, MF_ENABLED, IDM_QUIT, "&Quit" ) ; return menu ; }
void CReBar::OnCommand(WORD id, WORD notifyCode, HWND hWndControl) { switch (id) { case ID_TOOLS: { // If the button is clicked again while menu is shown, we shouldn't show it again static bool bIgnoreNext = false; if (hWndControl == (HWND)-1) { bIgnoreNext = true; return; } if (bIgnoreNext) { bIgnoreNext = false; return; } // Install a hook to capture mouse events when the menu is shown HHOOK hHook = SetWindowsHookEx(WH_MOUSE_LL, LLMouseProc, GetModuleHandle(NULL), 0); ASSERT(hHook); LLMouseProc(-1, -1, (LPARAM)hHook); LLMouseProc(-2, -2, (LPARAM)this); // Show menu, make sure commands get sent to the main window RECT rc; GetWindowRect(m_btnTools, &rc); VERIFY(TrackPopupMenu(m_hToolsMenu, TPM_RIGHTALIGN|TPM_TOPALIGN, rc.right, rc.bottom, 0, GetTopLevelParent(m_hWnd), NULL)); UnhookWindowsHookEx(hHook); // Restore button state POINT pt; GetCursorPos(&pt); ScreenToClient(m_btnTools, &pt); PostMessage(m_btnTools, WM_LBUTTONUP, 0, MAKELPARAM(pt.x, pt.y)); } break; case ID_TOOLS_STATUSBAR: CheckMenuItem(m_hToolsMenu, ID_TOOLS_STATUSBAR, (GETPREFBOOL(_T("MainWnd"), _T("ShowStatusBar")) ? MF_CHECKED : MF_UNCHECKED)); break; case ID_TOOLS_LOG: CheckMenuItem(m_hToolsMenu, ID_TOOLS_LOG, (GETPREFBOOL(_T("MainWnd"), _T("ShowLog")) ? MF_CHECKED : MF_UNCHECKED)); break; case ID_SEEN: m_btnSeen.SetCheck(!m_btnSeen.GetCheck()); SETPREFBOOL(_T("ShowSeenMovies"), m_btnSeen.GetCheck()); SendMessage(*GetDB(), WM_PREFCHANGED); GetDB()->Filter(); break; case ID_VIEW: m_btnView.SetCheck(!m_btnView.GetCheck()); SETPREFBOOL(_T("ViewType"), m_btnView.GetCheck()); SendMessage(GetMainWnd(), WM_SWITCHVIEW); break; case ID_TOGGLEVIEWSTATUS: m_btnView.SetCheck(!m_btnView.GetCheck()); break; case ID_SORT: { // If the button is clicked again while menu is shown, we shouldn't show it again static bool bIgnoreNext = false; if (hWndControl == (HWND)-1) { bIgnoreNext = true; return; } if (bIgnoreNext) { bIgnoreNext = false; return; } // Install a hook to capture mouse events when the menu is shown HHOOK hHook = SetWindowsHookEx(WH_MOUSE_LL, LLMouseProc, GetModuleHandle(NULL), 0); ASSERT(hHook); LLMouseProc(-1, -1, (LPARAM)hHook); LLMouseProc(-2, -2, (LPARAM)this); // Show menu, make sure commands get sent to THIS window RECT rc; GetWindowRect(m_btnSort, &rc); VERIFY(TrackPopupMenu(m_hSortMenu, TPM_RIGHTALIGN|TPM_TOPALIGN, rc.right, rc.bottom, 0, m_hWnd, NULL)); UnhookWindowsHookEx(hHook); // Restore button state POINT pt; GetCursorPos(&pt); ScreenToClient(m_btnSort, &pt); PostMessage(m_btnSort, WM_LBUTTONUP, 0, MAKELPARAM(pt.x, pt.y)); } break; case ID_SEARCH: if (notifyCode == EN_RETURN || (m_bInstantSearch && notifyCode == EN_CHANGE)) { RString strText = m_eSearch.GetText(); RObArray<RString> keywords; if (m_bLiteralSearch) { if (!strText.IsEmpty()) keywords.Add(strText); } else { RRegEx re(_T("(?:\"([^\"]+)\")|([^ ]+)")); if (!strText.IsEmpty()) keywords.Add(strText); while (re.Search(strText)) { RString strMatch; for (INT_PTR i = 1; i < re.GetMatchCount() && strMatch.IsEmpty(); ++i) strMatch = re.GetMatch(i); strMatch.Replace(_T("\""), _T("")); keywords.Add(strMatch); strText.Replace(re.GetMatch(0), _T("")); } } GetDB()->FilterByKeywords(keywords); } break; case ID_SORT_TITLEASC: case ID_SORT_TITLEDES: case ID_SORT_YEARASC: case ID_SORT_YEARDES: case ID_SORT_RATINGASC: case ID_SORT_RATINGDES: case ID_SORT_FILETIMEASC: case ID_SORT_FILETIMEDES: SETPREFINT(_T("SortBy"), id - ID_SORT_TITLEASC); CheckMenuRadioItem(m_hSortMenu, ID_SORT_TITLEASC, ID_SORT_FILETIMEDES, id, MF_CHECKED); PostMessage(*GetDB(), WM_PREFCHANGED); PostMessage(m_hWnd, WM_COMMAND, MAKEWPARAM(ID_SEARCH, EN_RETURN), (LPARAM)(HWND)m_eSearch); break; default: ASSERT(false); } }
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 CReBar::OnPrefChanged() { m_bBackgrWinDefault = GETTHEMEBOOL(_T("ReBar"), _T("BackgrWindowsDefault")); m_clrBackgrT = GETTHEMECOLOR(_T("ReBar"), _T("BackgrTopColor")); m_clrBackgrB = GETTHEMECOLOR(_T("ReBar"), _T("BackgrBottomColor")); m_clrBackgrLine = GETTHEMECOLOR(_T("ReBar"), _T("BackgrLineColor")); m_bInstantSearch = GETPREFBOOL(_T("Search"), _T("Instantly")); m_bLiteralSearch = GETPREFBOOL(_T("Search"), _T("Literally")); m_mdcToolsBtn.Create(48, 48); DrawAlphaMap(m_mdcToolsBtn, 0, 0, IDA_WRENCH, 48, 48, GETTHEMECOLOR(_T("ToolBarButton"), _T("IconColor")), GETTHEMEALPHA(_T("ToolBarButton"), _T("IconAlpha"))); m_mdcSeenBtn.Create(48, 48); DrawAlphaMap(m_mdcSeenBtn, 0, 0, IDA_SEEN, 48, 48, GETTHEMECOLOR(_T("ToolBarButton"), _T("IconColor")), GETTHEMEALPHA(_T("ToolBarButton"), _T("IconAlpha"))); m_mdcViewBtn.Create(48, 48); DrawAlphaMap(m_mdcViewBtn, 0, 0, IDA_VIEW, 48, 48, GETTHEMECOLOR(_T("ToolBarButton"), _T("IconColor")), GETTHEMEALPHA(_T("ToolBarButton"), _T("IconAlpha"))); m_mdcSortBtn.Create(48, 48); DrawAlphaMap(m_mdcSortBtn, 0, 0, IDA_SORT, 48, 48, GETTHEMECOLOR(_T("ToolBarButton"), _T("IconColor")), GETTHEMEALPHA(_T("ToolBarButton"), _T("IconAlpha"))); // Search box //GETTHEMEFONT(&m_fntSearch, _T("SearchBox"), _T("Font")); //m_eSearch.SetFont(m_fntSearch); m_strSearchBoxFont = GETTHEMESTR(_T("SearchBox"), _T("Font")); m_fSearchBoxFontSize = GETTHEMEFLOAT(_T("SearchBox"), _T("FontSize")); m_eSearch.SetHint(GETSTR(IDS_SEARCH)); m_eSearch.SetHintColor(GETTHEMECOLOR(_T("SearchBox"), _T("HintColor"))); m_eSearch.SetTextColor(GETTHEMECOLOR(_T("SearchBox"), _T("TextColor"))); m_eSearch.SetBackgrColor(GETTHEMECOLOR(_T("SearchBox"), _T("BackgrColor"))); int r = SCX(GETTHEMEINT(_T("SearchBox"), _T("BorderRadius"))); m_sprSearchBox.Create(SCX(23), SCX(23), r+1, r+1, r+1, r+1); DrawRoundedRect(m_sprSearchBox, 0, 0, SCX(23), SCX(23), r, GETTHEMECOLOR(_T("SearchBox"), _T("BorderColor")), GETTHEMEALPHA(_T("SearchBox"), _T("BorderAlpha")), false); DrawRoundedRect(m_sprSearchBox, SCX(1), SCX(1), SCX(23) - 2 * SCX(1), SCX(23) - 2 * SCX(1), (r > 0 ? r - SCX(1) : 0), GETTHEMECOLOR(_T("SearchBox"), _T("BackgrColor"))); // Tools menu DestroyMenu(m_hToolsMenu); m_hToolsMenu = CreatePopupMenu(); AppendMenu(m_hToolsMenu, MF_STRING, ID_TOOLS_ZOOMIN, GETSTR(ID_TOOLS_ZOOMIN)); AppendMenu(m_hToolsMenu, MF_STRING, ID_TOOLS_ZOOMOUT, GETSTR(ID_TOOLS_ZOOMOUT)); AppendMenu(m_hToolsMenu, MF_STRING, ID_TOOLS_ZOOMRESET, GETSTR(ID_TOOLS_ZOOMRESET)); AppendMenu(m_hToolsMenu, MF_SEPARATOR, 0, NULL); AppendMenu(m_hToolsMenu, MF_STRING, ID_TOOLS_STATUSBAR, GETSTR(ID_TOOLS_STATUSBAR)); AppendMenu(m_hToolsMenu, MF_STRING, ID_TOOLS_LOG, GETSTR(ID_TOOLS_LOG)); AppendMenu(m_hToolsMenu, MF_SEPARATOR, 0, NULL); AppendMenu(m_hToolsMenu, MF_STRING, ID_TOOLS_OPTIONS, GETSTR(ID_TOOLS_OPTIONS)); AppendMenu(m_hToolsMenu, MF_SEPARATOR, 0, NULL); AppendMenu(m_hToolsMenu, MF_STRING, ID_TOOLS_EXIT, GETSTR(ID_TOOLS_EXIT)); if (GETPREFBOOL(_T("MainWnd"), _T("ShowStatusBar"))) CheckMenuItem(m_hToolsMenu, ID_TOOLS_STATUSBAR, MF_CHECKED); if (GETPREFBOOL(_T("MainWnd"), _T("ShowLog"))) CheckMenuItem(m_hToolsMenu, ID_TOOLS_LOG, MF_CHECKED); // Check seen button and view button m_btnSeen.SetCheck(GETPREFBOOL(_T("ShowSeenMovies"))); m_btnView.SetCheck(GETPREFBOOL(_T("ViewType"))); // Sort menu m_hSortMenu = CreatePopupMenu(); AppendMenu(m_hSortMenu, MF_STRING, ID_SORT_TITLEASC, GETSTR(ID_SORT_TITLEASC)); AppendMenu(m_hSortMenu, MF_STRING, ID_SORT_TITLEDES, GETSTR(ID_SORT_TITLEDES)); AppendMenu(m_hSortMenu, MF_STRING, ID_SORT_YEARASC, GETSTR(ID_SORT_YEARASC)); AppendMenu(m_hSortMenu, MF_STRING, ID_SORT_YEARDES, GETSTR(ID_SORT_YEARDES)); AppendMenu(m_hSortMenu, MF_STRING, ID_SORT_RATINGASC, GETSTR(ID_SORT_RATINGASC)); AppendMenu(m_hSortMenu, MF_STRING, ID_SORT_RATINGDES, GETSTR(ID_SORT_RATINGDES)); AppendMenu(m_hSortMenu, MF_STRING, ID_SORT_FILETIMEASC, GETSTR(ID_SORT_FILETIMEASC)); AppendMenu(m_hSortMenu, MF_STRING, ID_SORT_FILETIMEDES, GETSTR(ID_SORT_FILETIMEDES)); CheckMenuRadioItem(m_hSortMenu, ID_SORT_TITLEASC, ID_SORT_FILETIMEDES, GETPREFINT(_T("SortBy")) + ID_SORT_TITLEASC, MF_CHECKED); OnScaleChanged(); }
void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here is to the main window, NOT the treview { TVHITTESTINFO hti; hti.pt.x = (short)LOWORD(GetMessagePos()); hti.pt.y = (short)HIWORD(GetMessagePos()); ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) { if (hti.flags & TVHT_ONITEM) { TVITEM tvi = {0}; HMENU hMenu, hSubMenu; int menuNumber; char module[256]; tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; tvi.hItem = hti.hItem; tvi.pszText = module; tvi.cchTextMax = 255; TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); if (tvi.lParam) { ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; MCONTACT hContact = mtis->hContact; GetCursorPos(&hti.pt); hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); TranslateMenu(hMenu); if (mtis->type == CONTACT && hContact) menuNumber = 2; else if ((mtis->type == MODULE) && !hContact) menuNumber = 1; else if (mtis->type == CONTACT && !hContact) menuNumber = 3; else if (mtis->type == CONTACT_ROOT_ITEM && !hContact) menuNumber = 4; else if ((mtis->type == MODULE) && hContact) menuNumber = 5; else return; hSubMenu = GetSubMenu(hMenu, menuNumber); TranslateMenu(hSubMenu); switch (menuNumber) { case 1: // null module case 5: // contact module { // check if we r already watching the module int i, watching = 0; // check if the setting is being watched and if it is then check the menu item if (WatchListArray.item) for (i = 0; i < WatchListArray.count; i++) if (WatchListArray.item[i].module && (hContact == WatchListArray.item[i].hContact)) { if (!mir_strcmp(module, WatchListArray.item[i].module) && !WatchListArray.item[i].setting) { // yes so uncheck it CheckMenuItem(hSubMenu, MENU_WATCH_ITEM, MF_CHECKED | MF_BYCOMMAND); watching = 1; break; } } switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { case MENU_RENAME_MOD: TreeView_EditLabel(GetDlgItem(hwnd, IDC_MODULES), tvi.hItem); break; case MENU_DELETE_MOD: if (deleteModule(module, hContact, 0)) { TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom, hti.hItem); mir_free(mtis); } break; case MENU_COPY_MOD: copyModuleMenuItem(module, hContact); break; ////////////////////////////////////////////////////////////////////// divider case MENU_WATCH_ITEM: if (!watching) addSettingToWatchList(hContact, module, 0); else freeWatchListItem(i); if (hwnd2watchedVarsWindow) PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); break; case MENU_EXPORTMODULE: exportDB(hContact, module); break; case MENU_EXPORTDB: exportDB(INVALID_CONTACT_ID, module); break; } } break; case 2: // contact switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { case MENU_CLONE_CONTACT: if (CloneContact(hContact)) refreshTree(1); break; case MENU_DELETE_CONTACT: if (db_get_b(NULL, "CList", "ConfirmDelete", 1)) { char msg[1024]; mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete contact \"%s\"?"), module); if (MessageBox(0, msg, Translate("Confirm contact delete"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES) { CallService(MS_DB_CONTACT_DELETE, hContact, 0); freeTree(((LPNMHDR)lParam)->hwndFrom, hContact); TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom, tvi.hItem); } } else { CallService(MS_DB_CONTACT_DELETE, hContact, 0); freeTree(((LPNMHDR)lParam)->hwndFrom, hContact); TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom, tvi.hItem); } break; ////////////////////////////////////////////////////////////////////// divider case MENU_EXPORTCONTACT: exportDB(hContact, 0); break; case MENU_IMPORTFROMTEXT: ImportSettingsMenuItem(hContact); break; case MENU_IMPORTFROMFILE: ImportSettingsFromFileMenuItem(hContact, ""); break; ////////////////////////////////////////////////////////////////////// divider case MENU_ADD_MODULE: { HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, hContact); char msg[1024]; mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); SetWindowText(AddModhwnd, module); } break; } break; case 3: // NULL contact switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { case MENU_ADD_MODULE: { HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, hContact); char msg[1024]; mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); SetWindowText(AddModhwnd, module); } break; case MENU_EXPORTCONTACT: exportDB(NULL, 0); break; case MENU_IMPORTFROMTEXT: ImportSettingsMenuItem(NULL); break; case MENU_IMPORTFROMFILE: ImportSettingsFromFileMenuItem(NULL, ""); break; } break; case 4: // Contacts root switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { case MENU_EXPORTCONTACT: exportDB(INVALID_CONTACT_ID, ""); break; case MENU_IMPORTFROMTEXT: ImportSettingsMenuItem(NULL); break; case MENU_IMPORTFROMFILE: ImportSettingsFromFileMenuItem(NULL, ""); break; } break; } DestroyMenu(hMenu); } } } }
void TSAPI AddContactToFavorites(HANDLE hContact, const TCHAR *szNickname, const char *szProto, TCHAR *szStatus, WORD wStatus, HICON hIcon, BOOL mode, HMENU hMenu) { MENUITEMINFO mii = {0}; TCHAR szMenuEntry[80]; TCHAR szFinalNick[100]; if (szNickname == NULL) { mir_sntprintf(szFinalNick, safe_sizeof(szFinalNick), _T("%s"), (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)); } else { _tcsncpy(szFinalNick, szNickname, 100); szFinalNick[99] = 0; } if (szProto == NULL) szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if (szProto) { if (wStatus == 0) wStatus = DBGetContactSettingWord((HANDLE)hContact, szProto, "Status", ID_STATUS_OFFLINE); if (szStatus == NULL) szStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, wStatus, GSMDF_TCHAR); } else return; if (hIcon == 0) hIcon = LoadSkinnedProtoIcon(szProto, wStatus); PROTOACCOUNT *acc = (PROTOACCOUNT *)CallService(MS_PROTO_GETACCOUNT, (WPARAM)0, (LPARAM)szProto); if(acc && acc->tszAccountName) { mii.cbSize = sizeof(mii); mir_sntprintf(szMenuEntry, safe_sizeof(szMenuEntry), _T("%s: %s (%s)"), acc->tszAccountName, szFinalNick, szStatus); if (mode) { if (hMenu == PluginConfig.g_hMenuRecent) { if (CheckMenuItem(hMenu, (UINT_PTR)hContact, MF_BYCOMMAND | MF_UNCHECKED) == 0) { DeleteMenu(hMenu, (UINT_PTR)hContact, MF_BYCOMMAND); goto addnew; // move to the end of the menu... } if (GetMenuItemCount(PluginConfig.g_hMenuRecent) > nen_options.wMaxRecent) { // throw out oldest entry in the recent menu... UINT uid = GetMenuItemID(hMenu, 0); if (uid) { DeleteMenu(hMenu, (UINT_PTR)0, MF_BYPOSITION); M->WriteDword((HANDLE)uid, SRMSGMOD_T, "isRecent", 0); } } addnew: M->WriteDword(hContact, SRMSGMOD_T, "isRecent", time(NULL)); AppendMenu(hMenu, MF_BYCOMMAND, (UINT_PTR)hContact, szMenuEntry); } else if (hMenu == PluginConfig.g_hMenuFavorites) { // insert the item sorted... MENUITEMINFO mii2 = {0}; TCHAR szBuffer[142]; int i, c = GetMenuItemCount(PluginConfig.g_hMenuFavorites); mii2.fMask = MIIM_STRING; mii2.cbSize = sizeof(mii2); if (c == 0) InsertMenu(PluginConfig.g_hMenuFavorites, 0, MF_BYPOSITION, (UINT_PTR)hContact, szMenuEntry); else { for (i = 0; i <= c; i++) { mii2.cch = 0; mii2.dwTypeData = NULL; GetMenuItemInfo(PluginConfig.g_hMenuFavorites, i, TRUE, &mii2); mii2.cch++; mii2.dwTypeData = szBuffer; GetMenuItemInfo(PluginConfig.g_hMenuFavorites, i, TRUE, &mii2); if (_tcsncmp((TCHAR *)mii2.dwTypeData, szMenuEntry, 140) > 0 || i == c) { InsertMenu(PluginConfig.g_hMenuFavorites, i, MF_BYPOSITION, (UINT_PTR)hContact, szMenuEntry); break; } } } } } mii.fMask = MIIM_BITMAP | MIIM_DATA; if (!mode) { mii.fMask |= MIIM_STRING; mii.dwTypeData = (LPTSTR)szMenuEntry; mii.cch = lstrlen(szMenuEntry) + 1; } mii.hbmpItem = HBMMENU_CALLBACK; mii.dwItemData = (ULONG_PTR)hIcon; SetMenuItemInfo(hMenu, (UINT)hContact, FALSE, &mii); } }
LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { HDC hdc; LONG ptr; wfContext* wfc; int x, y, w, h; PAINTSTRUCT ps; rdpInput* input; BOOL processed; RECT windowRect; RECT clientRect; MINMAXINFO* minmax; SCROLLINFO si; processed = TRUE; ptr = GetWindowLongPtr(hWnd, GWLP_USERDATA); wfc = (wfContext*) ptr; if (wfc != NULL) { input = wfc->instance->input; switch (Msg) { case WM_MOVE: if (!wfc->disablewindowtracking) { int x = (int)(short) LOWORD(lParam); int y = (int)(short) HIWORD(lParam); wfc->client_x = x; wfc->client_y = y; } break; case WM_GETMINMAXINFO: if (wfc->instance->settings->SmartSizing) { processed = FALSE; } else { // Set maximum window size for resizing minmax = (MINMAXINFO*) lParam; wf_update_canvas_diff(wfc); if (!wfc->fullscreen) { // add window decoration minmax->ptMaxTrackSize.x = wfc->width + wfc->diff.x; minmax->ptMaxTrackSize.y = wfc->height + wfc->diff.y; } } break; case WM_SIZING: wf_sizing(wfc, lParam, wParam); break; case WM_SIZE: GetWindowRect(wfc->hwnd, &windowRect); if (!wfc->fullscreen) { wfc->client_width = LOWORD(lParam); wfc->client_height = HIWORD(lParam); wfc->client_x = windowRect.left; wfc->client_y = windowRect.top; } wf_size_scrollbars(wfc, LOWORD(lParam), HIWORD(lParam)); // Workaround: when the window is maximized, the call to "ShowScrollBars" returns TRUE but has no effect. if (wParam == SIZE_MAXIMIZED && !wfc->fullscreen) SetWindowPos(wfc->hwnd, HWND_TOP, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOMOVE | SWP_FRAMECHANGED); break; case WM_EXITSIZEMOVE: wf_size_scrollbars(wfc, wfc->client_width, wfc->client_height); break; case WM_ERASEBKGND: /* Say we handled it - prevents flickering */ return (LRESULT) 1; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); x = ps.rcPaint.left; y = ps.rcPaint.top; w = ps.rcPaint.right - ps.rcPaint.left + 1; h = ps.rcPaint.bottom - ps.rcPaint.top + 1; wf_scale_blt(wfc, hdc, x, y, w, h, wfc->primary->hdc, x - wfc->offset_x + wfc->xCurrentScroll, y - wfc->offset_y + wfc->yCurrentScroll, SRCCOPY); EndPaint(hWnd, &ps); break; case WM_LBUTTONDOWN: wf_scale_mouse_event(wfc, input,PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y); break; case WM_LBUTTONUP: wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON1, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y); break; case WM_RBUTTONDOWN: wf_scale_mouse_event(wfc, input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y); break; case WM_RBUTTONUP: wf_scale_mouse_event(wfc, input, PTR_FLAGS_BUTTON2, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y); break; case WM_MOUSEMOVE: wf_scale_mouse_event(wfc, input, PTR_FLAGS_MOVE, X_POS(lParam) - wfc->offset_x, Y_POS(lParam) - wfc->offset_y); break; case WM_MOUSEWHEEL: wf_event_process_WM_MOUSEWHEEL(wfc, hWnd, Msg, wParam, lParam); break; case WM_SETCURSOR: if (LOWORD(lParam) == HTCLIENT) SetCursor(wfc->cursor); else DefWindowProc(hWnd, Msg, wParam, lParam); break; case WM_HSCROLL: { int xDelta; // xDelta = new_pos - current_pos int xNewPos; // new position int yDelta = 0; switch (LOWORD(wParam)) { // User clicked the scroll bar shaft left of the scroll box. case SB_PAGEUP: xNewPos = wfc->xCurrentScroll - 50; break; // User clicked the scroll bar shaft right of the scroll box. case SB_PAGEDOWN: xNewPos = wfc->xCurrentScroll + 50; break; // User clicked the left arrow. case SB_LINEUP: xNewPos = wfc->xCurrentScroll - 5; break; // User clicked the right arrow. case SB_LINEDOWN: xNewPos = wfc->xCurrentScroll + 5; break; // User dragged the scroll box. case SB_THUMBPOSITION: xNewPos = HIWORD(wParam); // user is dragging the scrollbar case SB_THUMBTRACK : xNewPos = HIWORD(wParam); break; default: xNewPos = wfc->xCurrentScroll; } // New position must be between 0 and the screen width. xNewPos = MAX(0, xNewPos); xNewPos = MIN(wfc->xMaxScroll, xNewPos); // If the current position does not change, do not scroll. if (xNewPos == wfc->xCurrentScroll) break; // Determine the amount scrolled (in pixels). xDelta = xNewPos - wfc->xCurrentScroll; // Reset the current scroll position. wfc->xCurrentScroll = xNewPos; // Scroll the window. (The system repaints most of the // client area when ScrollWindowEx is called; however, it is // necessary to call UpdateWindow in order to repaint the // rectangle of pixels that were invalidated.) ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT *) NULL, (CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL, SW_INVALIDATE); UpdateWindow(wfc->hwnd); // Reset the scroll bar. si.cbSize = sizeof(si); si.fMask = SIF_POS; si.nPos = wfc->xCurrentScroll; SetScrollInfo(wfc->hwnd, SB_HORZ, &si, TRUE); } break; case WM_VSCROLL: { int xDelta = 0; int yDelta; // yDelta = new_pos - current_pos int yNewPos; // new position switch (LOWORD(wParam)) { // User clicked the scroll bar shaft above the scroll box. case SB_PAGEUP: yNewPos = wfc->yCurrentScroll - 50; break; // User clicked the scroll bar shaft below the scroll box. case SB_PAGEDOWN: yNewPos = wfc->yCurrentScroll + 50; break; // User clicked the top arrow. case SB_LINEUP: yNewPos = wfc->yCurrentScroll - 5; break; // User clicked the bottom arrow. case SB_LINEDOWN: yNewPos = wfc->yCurrentScroll + 5; break; // User dragged the scroll box. case SB_THUMBPOSITION: yNewPos = HIWORD(wParam); break; // user is dragging the scrollbar case SB_THUMBTRACK : yNewPos = HIWORD(wParam); break; default: yNewPos = wfc->yCurrentScroll; } // New position must be between 0 and the screen height. yNewPos = MAX(0, yNewPos); yNewPos = MIN(wfc->yMaxScroll, yNewPos); // If the current position does not change, do not scroll. if (yNewPos == wfc->yCurrentScroll) break; // Determine the amount scrolled (in pixels). yDelta = yNewPos - wfc->yCurrentScroll; // Reset the current scroll position. wfc->yCurrentScroll = yNewPos; // Scroll the window. (The system repaints most of the // client area when ScrollWindowEx is called; however, it is // necessary to call UpdateWindow in order to repaint the // rectangle of pixels that were invalidated.) ScrollWindowEx(wfc->hwnd, -xDelta, -yDelta, (CONST RECT *) NULL, (CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL, SW_INVALIDATE); UpdateWindow(wfc->hwnd); // Reset the scroll bar. si.cbSize = sizeof(si); si.fMask = SIF_POS; si.nPos = wfc->yCurrentScroll; SetScrollInfo(wfc->hwnd, SB_VERT, &si, TRUE); } break; case WM_SYSCOMMAND: { if (wParam == SYSCOMMAND_ID_SMARTSIZING) { HMENU hMenu = GetSystemMenu(wfc->hwnd, FALSE); freerdp_set_param_bool(wfc->instance->settings, FreeRDP_SmartSizing, !wfc->instance->settings->SmartSizing); CheckMenuItem(hMenu, SYSCOMMAND_ID_SMARTSIZING, wfc->instance->settings->SmartSizing ? MF_CHECKED : MF_UNCHECKED); } else { processed = FALSE; } } break; default: processed = FALSE; break; } } else { processed = FALSE; } if (processed) return 0; switch (Msg) { case WM_DESTROY: PostQuitMessage(WM_QUIT); break; case WM_SETCURSOR: if (LOWORD(lParam) == HTCLIENT) SetCursor(wfc->hDefaultCursor); else DefWindowProc(hWnd, Msg, wParam, lParam); break; case WM_SETFOCUS: DEBUG_KBD("getting focus %X", hWnd); g_focus_hWnd = hWnd; break; case WM_KILLFOCUS: if (g_focus_hWnd == hWnd && wfc && !wfc->fullscreen) { DEBUG_KBD("loosing focus %X", hWnd); g_focus_hWnd = NULL; } break; case WM_ACTIVATE: { int activate = (int)(short) LOWORD(wParam); if (activate != WA_INACTIVE) { g_focus_hWnd = hWnd; } else { g_focus_hWnd = NULL; } } default: return DefWindowProc(hWnd, Msg, wParam, lParam); break; } return 0; }
void Toolbar::CheckActiveTree( int active, int inActive_1, int inActive_2, HWND hWnd ) { CheckMenuItem( GetMenu( hWnd ), active, MF_CHECKED ); CheckMenuItem( GetMenu( hWnd ), inActive_1, MF_UNCHECKED ); CheckMenuItem( GetMenu( hWnd ), inActive_2, MF_UNCHECKED ); }
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HMENU hmenu; RECT rect; int c; LRESULT r; switch (message) { case WM_COMMAND: hmenu = GetMenu(hwnd); switch (LOWORD(wParam)) { case IDM_FILE_RESET: EnterCriticalSection(&cs); main_reset(); LeaveCriticalSection(&cs); break; case IDM_FILE_LSTATE: EnterCriticalSection(&cs); if (!getfile(hwnd, "Save State (*.SNP)\0*.SNP\0All files (*.*)\0*.*\0\0", savestate_name)) { CheckMenuItem(hmenu, IDM_TUBE_6502 + selecttube, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_MODEL_0 + curmodel, MF_UNCHECKED); savestate_load(); CheckMenuItem(hmenu, IDM_TUBE_6502 + selecttube, MF_CHECKED); CheckMenuItem(hmenu, IDM_MODEL_0 + curmodel, MF_CHECKED); } main_cleardrawit(); LeaveCriticalSection(&cs); break; case IDM_FILE_SSTATE: EnterCriticalSection(&cs); if (curtube != -1) { log_error("Second processor save states not supported yet."); } else { if (!getsfile(hwnd, "Save State (*.SNP)\0*.SNP\0All files (*.*)\0*.*\0\0", savestate_name, "SNP")) savestate_save(); } main_cleardrawit(); LeaveCriticalSection(&cs); break; case IDM_FILE_EXIT: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; case IDM_DISC_AUTOBOOT: if (!getfile(hwnd, "Disc image (*.SSD;*.DSD;*.IMG;*.ADF;*.ADL;*.FDI)\0*.SSD;*.DSD;*.IMG;*.ADF;*.ADL;*.FDI\0All files (*.*)\0*.*\0", discfns[0])) { doautoboot = 1; } break; case IDM_DISC_LOAD_0: if (!getfile(hwnd, "Disc image (*.SSD;*.DSD;*.IMG;*.ADF;*.ADL;*.FDI)\0*.SSD;*.DSD;*.IMG;*.ADF;*.ADL;*.FDI\0All files (*.*)\0*.*\0", discfns[0])) { disc_close(0); disc_load(0, discfns[0]); if (defaultwriteprot) writeprot[0] = 1; CheckMenuItem(hmenu, IDM_DISC_WPROT_0, (writeprot[0]) ? MF_CHECKED : MF_UNCHECKED); } break; case IDM_DISC_LOAD_1: if (!getfile(hwnd, "Disc image (*.SSD;*.DSD;*.IMG;*.ADF;*.ADL;*.FDI)\0*.SSD;*.DSD;*.IMG;*.ADF;*.ADL;*.FDI\0All files (*.*)\0*.*\0", discfns[1])) { disc_close(1); disc_load(1, discfns[1]); if (defaultwriteprot) writeprot[1] = 1; CheckMenuItem(hmenu, IDM_DISC_WPROT_1, (writeprot[1]) ? MF_CHECKED : MF_UNCHECKED); } break; case IDM_DISC_EJECT_0: disc_close(0); discfns[0][0] = 0; setejecttext(0, ""); break; case IDM_DISC_EJECT_1: disc_close(1); discfns[1][0] = 0; setejecttext(1, ""); break; case IDM_DISC_NEW_0: if (!getsfile(hwnd, "Disc image (*.SSD;*.DSD;*.ADF;*.ADL)\0*.SSD;*.DSD;*.ADF;*.ADL\0All files (*.*)\0*.*\0", discfns[0], "SSD")) { disc_close(0); disc_new(0, discfns[0]); if (defaultwriteprot) writeprot[0] = 1; CheckMenuItem(hmenu, IDM_DISC_WPROT_0, (writeprot[0]) ? MF_CHECKED : MF_UNCHECKED); } break; case IDM_DISC_NEW_1: if (!getsfile(hwnd, "Disc image (*.SSD;*.DSD;*.ADF;*.ADL)\0*.SSD;*.DSD;*.ADF;*.ADL\0All files (*.*)\0*.*\0", discfns[1], "SSD")) { disc_close(1); disc_new(1, discfns[1]); if (defaultwriteprot) writeprot[1] = 1; CheckMenuItem(hmenu, IDM_DISC_WPROT_1, (writeprot[1]) ? MF_CHECKED : MF_UNCHECKED); } break; case IDM_DISC_WPROT_0: writeprot[0] = !writeprot[0]; if (fwriteprot[0]) writeprot[0] = 1; CheckMenuItem(hmenu, IDM_DISC_WPROT_0, (writeprot[0]) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_DISC_WPROT_1: writeprot[1] = !writeprot[1]; if (fwriteprot[1]) writeprot[1] = 1; CheckMenuItem(hmenu, IDM_DISC_WPROT_1, (writeprot[1]) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_DISC_WPROT_D: defaultwriteprot = !defaultwriteprot; CheckMenuItem(hmenu, IDM_DISC_WPROT_D, (defaultwriteprot) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_DISC_VDFS_ENABLE: vdfs_enabled = !vdfs_enabled; CheckMenuItem(hmenu, IDM_DISC_VDFS_ENABLE, (vdfs_enabled) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_DISC_VDFS_ROOT: strncpy(openfilestring, vdfs_get_root(), MAX_PATH); if (!getDir(hwnd, "VDFS Root")) vdfs_set_root(openfilestring); break; case IDM_TAPE_LOAD: if (!getfile(hwnd, "Tape image (*.UEF;*.CSW)\0*.UEF;*.CSW\0All files (*.*)\0*.*\0", tape_fn)) { tape_close(); tape_load(tape_fn); tape_loaded = 1; } break; case IDM_TAPE_EJECT: tape_close(); tape_loaded = 0; break; case IDM_TAPE_REWIND: tape_close(); tape_load(tape_fn); break; case IDM_TAPE_CAT: showcatalogue(hinstance, ghwnd); break; case IDM_TAPES_NORMAL: case IDM_TAPES_FAST: fasttape = LOWORD(wParam) - IDM_TAPES_NORMAL; CheckMenuItem(hmenu, IDM_TAPES_NORMAL, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TAPES_FAST, MF_UNCHECKED); CheckMenuItem(hmenu, LOWORD(wParam), MF_CHECKED); break; case IDM_VIDEO_NOBORDERS: case IDM_VIDEO_MBORDERS: case IDM_VIDEO_FBORDERS: CheckMenuItem(hmenu, IDM_VIDEO_NOBORDERS + vid_fullborders, MF_UNCHECKED); vid_fullborders = LOWORD(wParam) - IDM_VIDEO_NOBORDERS; CheckMenuItem(hmenu, IDM_VIDEO_NOBORDERS + vid_fullborders, MF_CHECKED); break; case IDM_VIDEO_FULLSCR: fullscreen = 1; EnterCriticalSection(&cs); video_enterfullscreen(); LeaveCriticalSection(&cs); break; case IDM_VIDEO_NULA: if (nula_disable) nula_disable = 0; else nula_disable = 1; break; case IDM_VIDEO_RESIZE: videoresize = !videoresize; CheckMenuItem(hmenu, IDM_VIDEO_RESIZE, (videoresize) ? MF_CHECKED : MF_UNCHECKED); if (videoresize) SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE); else SetWindowLong(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX) | WS_VISIBLE); GetWindowRect(hwnd, &rect); SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED); break; case IDM_VIDEO_SLINEDBL: case IDM_VIDEO_LINEDBL: case IDM_VIDEO_SCANLINES: case IDM_VIDEO_INTERLACED: case IDM_VIDEO_PAL: case IDM_VIDEO_PALI: CheckMenuItem(hmenu, IDM_VIDEO_SLINEDBL, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VIDEO_LINEDBL, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VIDEO_SCANLINES, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VIDEO_INTERLACED, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VIDEO_PAL, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VIDEO_PALI, MF_UNCHECKED); CheckMenuItem(hmenu, LOWORD(wParam), MF_CHECKED); vid_scanlines = vid_interlace = vid_linedbl = vid_pal = 0; if (LOWORD(wParam) == IDM_VIDEO_INTERLACED) vid_interlace = 1; if (LOWORD(wParam) == IDM_VIDEO_SCANLINES) vid_scanlines = 1; if (LOWORD(wParam) == IDM_VIDEO_SLINEDBL) vid_linedbl = 1; if (LOWORD(wParam) == IDM_VIDEO_PAL) vid_pal = 1; if (LOWORD(wParam) == IDM_VIDEO_PALI) vid_interlace = vid_pal = 1; video_clearscreen(); break; case IDM_TUBE_NONE: case IDM_TUBE_6502: case IDM_TUBE_Z80: case IDM_TUBE_65816: case IDM_TUBE_32016: CheckMenuItem(hmenu, IDM_TUBE_NONE, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TUBE_6502, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TUBE_65816, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TUBE_Z80, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TUBE_32016, MF_UNCHECKED); CheckMenuItem(hmenu, LOWORD(wParam), MF_CHECKED); selecttube = LOWORD(wParam) - IDM_TUBE_6502; main_restart(); break; case IDM_TUBES_4: case IDM_TUBES_8: case IDM_TUBES_16: case IDM_TUBES_32: case IDM_TUBES_64: CheckMenuItem(hmenu, IDM_TUBES_4, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TUBES_8, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TUBES_16, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TUBES_32, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_TUBES_64, MF_UNCHECKED); CheckMenuItem(hmenu, LOWORD(wParam), MF_CHECKED); tube_6502_speed = (LOWORD(wParam) - IDM_TUBES_4) + 1; tube_updatespeed(); break; case IDM_SOUND_INTERNAL: sound_internal = !sound_internal; CheckMenuItem(hmenu, IDM_SOUND_INTERNAL, (sound_internal) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_SOUND_BEEBSID: sound_beebsid = !sound_beebsid; CheckMenuItem(hmenu, IDM_SOUND_BEEBSID, (sound_beebsid) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_SOUND_MUSIC5000: sound_music5000 = !sound_music5000; CheckMenuItem(hmenu, IDM_SOUND_MUSIC5000, (sound_music5000) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_SOUND_DAC: sound_dac = !sound_dac; CheckMenuItem(hmenu, IDM_SOUND_DAC, (sound_dac) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_SOUND_DDNOISE: sound_ddnoise = !sound_ddnoise; CheckMenuItem(hmenu, IDM_SOUND_DDNOISE, (sound_ddnoise) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_SOUND_TAPE: sound_tape = !sound_tape; CheckMenuItem(hmenu, IDM_SOUND_TAPE, (sound_tape) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_SOUND_FILTER: sound_filter = !sound_filter; CheckMenuItem(hmenu, IDM_SOUND_FILTER, (sound_filter) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_WAVE_SQUARE: case IDM_WAVE_SAW: case IDM_WAVE_SINE: case IDM_WAVE_TRI: case IDM_WAVE_SID: CheckMenuItem(hmenu, IDM_WAVE_SQUARE + curwave, MF_UNCHECKED); curwave = LOWORD(wParam) - IDM_WAVE_SQUARE; CheckMenuItem(hmenu, IDM_WAVE_SQUARE + curwave, MF_CHECKED); break; case IDM_SID_INTERP: case IDM_SID_RESAMP: CheckMenuItem(hmenu, IDM_SID_INTERP, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_SID_RESAMP, MF_UNCHECKED); CheckMenuItem(hmenu, LOWORD(wParam), MF_CHECKED); sidmethod = LOWORD(wParam) - IDM_SID_INTERP; sid_settype(sidmethod, cursid); break; case IDM_DDV_33: case IDM_DDV_66: case IDM_DDV_100: CheckMenuItem(hmenu, (IDM_DDV_33 + ddnoise_vol) - 1, MF_UNCHECKED); ddnoise_vol = (LOWORD(wParam) - IDM_DDV_33) + 1; CheckMenuItem(hmenu, (IDM_DDV_33 + ddnoise_vol) - 1, MF_CHECKED); break; case IDM_DDT_525: case IDM_DDT_35: CheckMenuItem(hmenu, IDM_DDT_525 + ddnoise_type, MF_UNCHECKED); ddnoise_type = LOWORD(wParam) - IDM_DDT_525; CheckMenuItem(hmenu, IDM_DDT_525 + ddnoise_type, MF_CHECKED); ddnoise_close(); ddnoise_init(); break; case IDM_DEBUGGER: EnterCriticalSection(&cs); rest(200); debug_toggle_core(); CheckMenuItem(hmenu, IDM_DEBUGGER, (debug_core) ? MF_CHECKED: MF_UNCHECKED); LeaveCriticalSection(&cs); break; case IDM_DEBUG_TUBE: EnterCriticalSection(&cs); rest(200); debug_toggle_tube(); CheckMenuItem(hmenu, IDM_DEBUG_TUBE, (debug_tube) ? MF_CHECKED: MF_UNCHECKED); LeaveCriticalSection(&cs); break; case IDM_BREAK: debug_step = 1; break; case IDM_SCRSHOT: if (!getsfile(hwnd, "Bitmap file (*.BMP)\0*.BMP\0All files (*.*)\0*.*\0", vid_scrshotname, "BMP")) { vid_savescrshot = 1; } break; case IDM_KEY_REDEFINE: redefinekeys(); break; case IDM_KEY_AS: keyas = !keyas; CheckMenuItem(hmenu, IDM_KEY_AS, (keyas) ? MF_CHECKED : MF_UNCHECKED); break; case IDM_MOUSE_AMX: mouse_amx = !mouse_amx; CheckMenuItem(hmenu, IDM_MOUSE_AMX, (mouse_amx) ? MF_CHECKED : MF_UNCHECKED); main_setmouse(); updatewindowtitle(); break; case IDM_SCSI_ENABLE: EnterCriticalSection(&cs); CheckMenuItem(hmenu, IDM_SCSI_ENABLE, (!scsi_enabled) ? MF_CHECKED : MF_UNCHECKED); scsi_enabled = !scsi_enabled; main_restart(); LeaveCriticalSection(&cs); break; case IDM_IDE_ENABLE: EnterCriticalSection(&cs); CheckMenuItem(hmenu, IDM_IDE_ENABLE, (!ide_enable) ? MF_CHECKED : MF_UNCHECKED); ide_enable = !ide_enable; main_restart(); LeaveCriticalSection(&cs); break; case IDM_SPD_10: case IDM_SPD_25: case IDM_SPD_50: case IDM_SPD_75: case IDM_SPD_100: case IDM_SPD_150: case IDM_SPD_200: case IDM_SPD_300: case IDM_SPD_400: case IDM_SPD_500: CheckMenuItem(hmenu, IDM_SPD_10 + emuspeed, MF_UNCHECKED); emuspeed = curmodel = LOWORD(wParam) - IDM_SPD_10; changetimerspeed(timerspeeds[emuspeed]); vid_fskipmax = frameskips[emuspeed]; CheckMenuItem(hmenu, IDM_SPD_10 + emuspeed, MF_CHECKED); break; } if (LOWORD(wParam) >= IDM_MODEL_0 && LOWORD(wParam) < (IDM_MODEL_0 + 50)) { CheckMenuItem(hmenu, IDM_MODEL_0 + curmodel, MF_UNCHECKED); oldmodel = curmodel; curmodel = LOWORD(wParam) - IDM_MODEL_0; CheckMenuItem(hmenu, IDM_MODEL_0 + curmodel, MF_CHECKED); main_restart(); updatewindowtitle(); } if (LOWORD(wParam) >= IDM_SID_TYPE && LOWORD(wParam) < (IDM_SID_TYPE + 100)) { CheckMenuItem(hmenu, IDM_SID_TYPE + cursid, MF_UNCHECKED); cursid = LOWORD(wParam) - IDM_SID_TYPE; CheckMenuItem(hmenu, IDM_SID_TYPE + cursid, MF_CHECKED); sid_settype(sidmethod, cursid); } return 0; case WM_USER: if (videoresize) SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE); else SetWindowLong(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX) | WS_VISIBLE); GetWindowRect(hwnd, &rect); SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED); break; case WM_USER+1: if (videoresize) SetWindowLong(hwnd, GWL_STYLE, WS_OVERLAPPEDWINDOW & ~WS_VISIBLE); else SetWindowLong(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX) & ~WS_VISIBLE); GetWindowRect(hwnd,&rect); SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED); break; case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; case WM_KILLFOCUS: // log_debug("KillFocus\n"); // infocus=0; // spdcount=0; if (mousecapture) { ClipCursor(&oldclip); mousecapture = 0; updatewindowtitle(); } break; case WM_LBUTTONUP: if (!mousecapture && (curtube == 3 || mouse_amx)) { GetClipCursor(&oldclip); GetWindowRect(hwnd, &newclip); newclip.left += GetSystemMetrics(SM_CXFIXEDFRAME) + 10; newclip.right -= GetSystemMetrics(SM_CXFIXEDFRAME) + 10; newclip.top += GetSystemMetrics(SM_CXFIXEDFRAME) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 10; newclip.bottom -= GetSystemMetrics(SM_CXFIXEDFRAME) + 10; ClipCursor(&newclip); mousecapture = 1; updatewindowtitle(); } break; case WM_ENTERMENULOOP: // log_debug("EnterMenuLoop\n"); bempause = 1; //EnterCriticalSection(&cs); break; case WM_EXITMENULOOP: // log_debug("ExitMenuLoop\n"); bempause = 0; key_clear(); for (c = 0; c < 128; c++) key[c] = 0; //LeaveCriticalSection(&cs); break; case WM_SETFOCUS: // log_debug("SetFocus\n"); key_clear(); for (c = 0; c < 128; c++) key[c] = 0; bempause = 0; break; case WM_SIZE: winsizex = lParam & 0xFFFF; winsizey = lParam >> 16; break; case WM_SYSKEYDOWN: case WM_KEYDOWN: if (LOWORD(wParam) != 255) { //log_debug("Key %04X %04X\n",LOWORD(wParam),VK_LEFT); c = MapVirtualKey(LOWORD(wParam),0); c = hw_to_mycode[c]; // log_debug("MVK %i %i %i\n",c,hw_to_mycode[c],KEY_PGUP); if (LOWORD(wParam) == VK_LEFT) c = KEY_LEFT; if (LOWORD(wParam) == VK_RIGHT) c = KEY_RIGHT; if (LOWORD(wParam) == VK_UP) c = KEY_UP; if (LOWORD(wParam) == VK_DOWN) c = KEY_DOWN; if (LOWORD(wParam) == VK_HOME) c = KEY_HOME; if (LOWORD(wParam) == VK_END) c = KEY_END; if (LOWORD(wParam) == VK_INSERT) c = KEY_INSERT; if (LOWORD(wParam) == VK_DELETE) c = KEY_DEL; if (LOWORD(wParam) == VK_PRIOR) c = KEY_PGUP; if (LOWORD(wParam) == VK_NEXT) c = KEY_PGDN; //log_debug("MVK2 %i %i %i\n",c,hw_to_mycode[c],KEY_PGUP); key[c]=1; } break; case WM_SYSKEYUP: case WM_KEYUP: if (LOWORD(wParam) != 255) { // log_debug("Key %04X %04X\n",LOWORD(wParam),VK_LEFT); c = MapVirtualKey(LOWORD(wParam), 0); c = hw_to_mycode[c]; if (LOWORD(wParam) == VK_LEFT) c = KEY_LEFT; if (LOWORD(wParam) == VK_RIGHT) c = KEY_RIGHT; if (LOWORD(wParam) == VK_UP) c = KEY_UP; if (LOWORD(wParam) == VK_DOWN) c = KEY_DOWN; if (LOWORD(wParam) == VK_HOME) c = KEY_HOME; if (LOWORD(wParam) == VK_END) c = KEY_END; if (LOWORD(wParam) == VK_INSERT) c = KEY_INSERT; if (LOWORD(wParam) == VK_DELETE) c = KEY_DEL; if (LOWORD(wParam) == VK_PRIOR) c = KEY_PGUP; if (LOWORD(wParam) == VK_NEXT) c = KEY_PGDN; // log_debug("MVK %i\n",c); key[c] = 0; } break; case WM_CREATE: // initbbc(argc,argv); // free(argv); // mainthread=(HANDLE)_beginthread(_mainthread,0,NULL); break; default: r = DefWindowProc (hwnd, message, wParam, lParam); return r; } return 0; }
void SetDeferredUpdate() { CheckMenuItem(vmPrefsMenu, ID_DEFERUPDATES, MF_BYCOMMAND | (fDeferredUpdate ? MF_CHECKED : MF_UNCHECKED)); WritePrivateProfileString(U_GLOBAL,TEXT("DeferUpdate"), fDeferredUpdate ? U_ON : U_OFF,squeakIniName); }