void MainDialog::showMenu() { POINT pt; GetCursorPos(&pt); HMENU hMenu = CreatePopupMenu(); if(hMenu) { InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_MAIN, "打开"); InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_SETTING, "设置"); InsertMenu(hMenu, -1, MF_BYPOSITION|MF_SEPARATOR, 0, ""); InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_ABOUT, "关于"); InsertMenu(hMenu, -1, MF_BYPOSITION, SWM_EXIT, "退出"); // note: must set window to the foreground or the // menu won't disappear when it should SetForegroundWindow(_hWnd); TrackPopupMenu(hMenu, TPM_BOTTOMALIGN, pt.x, pt.y, 0, _hWnd, NULL ); DestroyMenu(hMenu); } }
LRESULT OnContextMenu(HWND hWnd,WPARAM wParam,LPARAM lParam) { HMENU hMenu, hPopup; int TempSel; POINT pt; pt.x=LOWORD(lParam); pt.y=HIWORD(lParam); ScreenToClient(hWnd,&pt); TempSel=FindObject(pt.x,pt.y); if (NowSel != TempSel) { NowSel=TempSel; InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); } hMenu=LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_POPUP)); hPopup=GetSubMenu(hMenu, 0); if (NowSel == -1) { EnableMenuItem(hPopup, IDM_POPUP_DELETE, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(hPopup, IDM_POPUP_PROPERTY, MF_BYCOMMAND | MF_GRAYED); } if (NowSel == -1 || NowSel >= arNum-1) { EnableMenuItem(hPopup, IDM_POPUP_FRONT, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(hPopup, IDM_POPUP_MOSTFRONT, MF_BYCOMMAND | MF_GRAYED); } if (NowSel == -1 || NowSel <= 0) { EnableMenuItem(hPopup, IDM_POPUP_BACK, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(hPopup, IDM_POPUP_MOSTBACK, MF_BYCOMMAND | MF_GRAYED); } TrackPopupMenu(hPopup, TPM_LEFTALIGN, LOWORD(lParam), HIWORD(lParam), 0, hWnd, NULL); DestroyMenu(hMenu); return 0; }
//------------------------------------------------------------------------ static void _OnMenuOpen( HWND hwnd ) { HMENU menu = NULL; WORD command; POINT curpos; // set focus SetForegroundWindow( hwnd ); // get position for popup menu GetCursorPos(&curpos); // show popup menu command = TrackPopupMenu( _menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY | TPM_BOTTOMALIGN, curpos.x, curpos.y, 0, hwnd, NULL ); // forward return command SendMessage( hwnd, WM_COMMAND, command, 0 ); }
wyBool TabMessage::OnContextMenu(LPARAM lparam) { HMENU hmenu, htrackmenu; POINT pnt; wyInt32 pos; RECT rect; if(lparam == -1) { pos = SendMessage(m_hwnd, SCI_GETCURRENTPOS, 0, 0); pnt.x = SendMessage(m_hwnd, SCI_POINTXFROMPOSITION, 0, pos) ; pnt.y = SendMessage(m_hwnd, SCI_POINTYFROMPOSITION, 0, pos); ClientToScreen(m_hwnd, &pnt); } else { pnt.x = (LONG)LOWORD(lparam); pnt.y = (LONG)HIWORD(lparam); } GetClientRect(m_hwnd, &rect); MapWindowPoints(m_hwnd, NULL, (LPPOINT)&rect, 2); if(!PtInRect(&rect, pnt)) { return wyFalse; } hmenu = LoadMenu(pGlobals->m_hinstance, MAKEINTRESOURCE(IDR_MESSAGETAB_MENU)); LocalizeMenu(hmenu); htrackmenu = GetSubMenu(hmenu, 0); TrackPopupMenu(htrackmenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pnt.x, pnt.y, 0, m_hwnd, NULL); DestroyMenu(hmenu); return wyTrue; }
INT_PTR CDialogManage::CTabSkins::OnCommand(WPARAM wParam, LPARAM lParam) { if (!m_HandleCommands) { // Values are being changed/reset, no need to apply changes return FALSE; } switch (LOWORD(wParam)) { case IDC_MANAGESKINS_ACTIVESKINS_BUTTON: { HMENU menu = CreatePopupMenu(); // Add active skins to menu std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin(); int index = 0; for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter) { std::wstring name = ((*iter).second)->GetFolderPath() + L'\\'; name += ((*iter).second)->GetFileName(); InsertMenu(menu, index, MF_BYPOSITION, ID_CONFIG_FIRST + index, name.c_str()); ++index; } if (index > 0) { RECT r; GetWindowRect((HWND)lParam, &r); // Show context menu TrackPopupMenu( menu, TPM_RIGHTBUTTON | TPM_LEFTALIGN, (*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left, --r.bottom, 0, m_Window, NULL ); } DestroyMenu(menu); } break; case IDC_MANAGESKINS_CREATEPACKAGE_BUTTON: { std::wstring file = Rainmeter->GetPath() + L"SkinInstaller.exe"; RunFile(file.c_str(), L"/Packager"); } break; case IDC_MANAGESKINS_LOAD_BUTTON: { if (!m_SkinWindow) { // Skin not active, load std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(m_SkinFolderPath, m_SkinFileName); if (indexes.first != -1 && indexes.second != -1) { Rainmeter->ActivateSkin(indexes.first, indexes.second); // Fake selection change to update controls NMHDR nm; nm.code = TVN_SELCHANGED; nm.idFrom = IDC_MANAGESKINS_SKINS_TREEVIEW; nm.hwndFrom = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW); OnNotify(0, (LPARAM)&nm); } } else { m_HandleCommands = false; Rainmeter->DeactivateSkin(m_SkinWindow, -1); } } break; case IDC_MANAGESKINS_REFRESH_BUTTON: if (m_SkinWindow) { m_SkinWindow->Refresh(false); } break; case IDC_MANAGESKINS_EDIT_BUTTON: Rainmeter->EditSkinFile(m_SkinFolderPath, m_SkinFileName); break; case IDC_MANAGESKINS_X_TEXT: if (HIWORD(wParam) == EN_CHANGE) { WCHAR buffer[32]; m_IgnoreUpdate = true; int x = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0; m_SkinWindow->MoveWindow(x, m_SkinWindow->GetY()); if (x > m_SkinWindow->GetX()) { _itow_s(m_SkinWindow->GetX(), buffer, 10); Edit_SetText((HWND)lParam, buffer); } } break; case IDC_MANAGESKINS_Y_TEXT: if (HIWORD(wParam) == EN_CHANGE) { WCHAR buffer[32]; m_IgnoreUpdate = true; int y = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0; m_SkinWindow->MoveWindow(m_SkinWindow->GetX(), y); if (y > m_SkinWindow->GetY()) { _itow_s(m_SkinWindow->GetY(), buffer, 10); Edit_SetText((HWND)lParam, buffer); } } break; case IDC_MANAGESKINS_LOADORDER_TEXT: if (HIWORD(wParam) == EN_CHANGE) { if (m_IgnoreUpdate) { // To avoid infinite loop after setting value below m_IgnoreUpdate = false; } else { // Convert text to number and set it to get rid of extra chars WCHAR buffer[32]; int len = GetWindowText((HWND)lParam, buffer, 32); if ((len == 0) || (len == 1 && buffer[0] == L'-')) { // Ignore if empty or if - is only char break; } // Get selection DWORD sel = Edit_GetSel((HWND)lParam); // Reset value (to get rid of invalid chars) m_IgnoreUpdate = true; int value = _wtoi(buffer); _itow_s(value, buffer, 10); SetWindowText((HWND)lParam, buffer); // Reset selection Edit_SetSel((HWND)lParam, LOWORD(sel), HIWORD(sel)); WritePrivateProfileString(m_SkinFolderPath.c_str(), L"LoadOrder", buffer, Rainmeter->GetIniFile().c_str()); std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(m_SkinWindow); if (indexes.first != -1) { Rainmeter->SetLoadOrder(indexes.first, value); std::multimap<int, CMeterWindow*> windows; Rainmeter->GetMeterWindowsByLoadOrder(windows); CSystem::PrepareHelperWindow(); // Reorder window z-position to reflect load order std::multimap<int, CMeterWindow*>::const_iterator iter = windows.begin(); for ( ; iter != windows.end(); ++iter) { CMeterWindow* mw = (*iter).second; mw->ChangeZPos(mw->GetWindowZPosition(), true); } } } } break; case IDC_MANAGESKINS_DISPLAYMONITOR_BUTTON: { HMENU menu = LoadMenu(Rainmeter->GetResourceInstance(), MAKEINTRESOURCE(IDR_SKIN_MENU)); if (menu) { HMENU subMenu = GetSubMenu(menu, 0); // Skin menu subMenu = GetSubMenu(subMenu, 4); // Settings menu subMenu = GetSubMenu(subMenu, 0); // Position menu subMenu = GetSubMenu(subMenu, 0); // Display monitor menu Rainmeter->CreateMonitorMenu(subMenu, m_SkinWindow); RECT r; GetWindowRect((HWND)lParam, &r); // Show context menu TrackPopupMenu( subMenu, TPM_RIGHTBUTTON | TPM_LEFTALIGN, (*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left, --r.bottom, 0, m_Window, NULL ); DestroyMenu(menu); } } break; case IDC_MANAGESKINS_DRAGGABLE_CHECKBOX: m_IgnoreUpdate = true; m_SkinWindow->SetWindowDraggable(!m_SkinWindow->GetWindowDraggable()); break; case IDC_MANAGESKINS_CLICKTHROUGH_CHECKBOX: m_IgnoreUpdate = true; m_SkinWindow->SetClickThrough(!m_SkinWindow->GetClickThrough()); break; case IDC_MANAGESKINS_KEEPONSCREEN_CHECKBOX: m_IgnoreUpdate = true; m_SkinWindow->SetKeepOnScreen(!m_SkinWindow->GetKeepOnScreen()); break; case IDC_MANAGESKINS_SAVEPOSITION_CHECKBOX: m_IgnoreUpdate = true; m_SkinWindow->SetSavePosition(!m_SkinWindow->GetSavePosition()); break; case IDC_MANAGESKINS_SNAPTOEDGES_CHECKBOX: m_IgnoreUpdate = true; m_SkinWindow->SetSnapEdges(!m_SkinWindow->GetSnapEdges()); break; case IDC_MANAGESKINS_ZPOSITION_COMBOBOX: if (HIWORD(wParam) == CBN_SELCHANGE) { m_IgnoreUpdate = true; ZPOSITION zpos = (ZPOSITION)(ComboBox_GetCurSel((HWND)lParam) - 2); m_SkinWindow->SetWindowZPosition(zpos); } break; case IDC_MANAGESKINS_TRANSPARENCY_COMBOBOX: if (HIWORD(wParam) == CBN_SELCHANGE) { m_IgnoreUpdate = true; int sel = ComboBox_GetCurSel((HWND)lParam) + IDM_SKIN_TRANSPARENCY_0; SendMessage(m_SkinWindow->GetWindow(), WM_COMMAND, sel, 0); } break; case IDC_MANAGESKINS_ONHOVER_COMBOBOX: if (HIWORD(wParam) == CBN_SELCHANGE) { m_IgnoreUpdate = true; HIDEMODE hide = (HIDEMODE)ComboBox_GetCurSel((HWND)lParam); m_SkinWindow->SetWindowHide(hide); } break; case IDM_MANAGESKINSMENU_EXPAND: { HWND tree = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW); HTREEITEM item = TreeView_GetSelection(tree); TreeView_Expand(tree, item, TVE_TOGGLE); } break; case IDM_MANAGESKINSMENU_OPENFOLDER: { HWND tree = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW); Rainmeter->OpenSkinFolder(GetTreeSelectionPath(tree)); } break; default: if (wParam >= ID_CONFIG_FIRST && wParam <= ID_CONFIG_LAST) { std::map<std::wstring, CMeterWindow*>::const_iterator iter = Rainmeter->GetAllMeterWindows().begin(); int index = (int)wParam - ID_CONFIG_FIRST; int i = 0; for ( ; iter != Rainmeter->GetAllMeterWindows().end(); ++iter) { if (i == index) { std::wstring name = ((*iter).second)->GetFolderPath() + L'\\'; name += ((*iter).second)->GetFileName(); HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW); SelectTreeItem(item, TreeView_GetRoot(item), name.c_str()); break; } ++i; } } else if (wParam == IDM_SKIN_MONITOR_AUTOSELECT || wParam == IDM_SKIN_MONITOR_PRIMARY || wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST) { if (m_SkinWindow) { SendMessage(m_SkinWindow->GetWindow(), WM_COMMAND, wParam, 0); } break; } return 1; } return 0; }
BOOL CALLBACK WndProc (HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { static HBRUSH hBrush = NULL; switch (umsg) { case WM_CREATE: if (!render_init (hwnd, g_gui_prefs.default_skin)) { MessageBox(hwnd, "Failed to find the skin bitmap", "Error", 0); break; } stop_button_disable(); if (OPT_FLAG_ISSET(g_rmo.flags, OPT_MAKE_RELAY)) { render_relay_button_enable (); } else { render_relay_button_disable (); } SetTimer (hwnd, 1, 500, (TIMERPROC)UpdateDisplay); dock_init (hwnd); return 0; case WM_PAINT: { PAINTSTRUCT pt; HDC hdc = BeginPaint(hwnd, &pt); render_do_paint(hdc); EndPaint(hwnd, &pt); } return 0; case WM_MOUSEMOVE: render_do_mousemove (hwnd, wParam, lParam); dock_do_mousemove (hwnd, wParam, lParam); break; case WM_COMMAND: switch(wParam) { case ID_MENU_STARTRIPPING: start_button_pressed(); break; case ID_MENU_STOPRIPPING: stop_button_pressed(); break; case ID_MENU_OPTIONS: options_button_pressed(); break; case ID_MENU_OPEN: PostMessage(hwnd, WM_MY_TRAY_NOTIFICATION, (WPARAM)NULL, WM_LBUTTONDBLCLK); break; case ID_MENU_RESET_URL: strcpy(g_rmo.url, ""); set_ripping_url (0); break; case ID_MENU_LOAD_URL: debug_printf ("Load URL dialog box\n"); open_load_url_dialog (); break; case ID_MENU_EXIT: debug_printf ("User requested exit\n"); quit (); PostQuitMessage( 0 ); break; default: if (wParam >= ID_MENU_HISTORY_LIST && wParam < ID_MENU_HISTORY_LIST + RIPLIST_LEN) { int i = wParam - ID_MENU_HISTORY_LIST; char* url = g_gui_prefs.riplist[i]; debug_printf ("Setting URL through history list\n"); strcpy(g_rmo.url, url); set_ripping_url (url); } break; } break; case WM_MY_TRAY_NOTIFICATION: switch(lParam) { case WM_LBUTTONDBLCLK: dock_show_window(m_hwnd, SW_NORMAL); SetForegroundWindow(hwnd); g_gui_prefs.m_start_minimized = FALSE; break; case WM_RBUTTONDOWN: { int item; POINT pt; GetCursorPos(&pt); SetForegroundWindow(hwnd); item = TrackPopupMenu(m_hmenu_systray_sub, 0, pt.x, pt.y, (int)NULL, hwnd, NULL); } break; } break; case WM_LBUTTONDOWN: dock_do_lbuttondown(hwnd, wParam, lParam); render_do_lbuttondown(hwnd, wParam, lParam); break; case WM_LBUTTONUP: dock_do_lbuttonup(hwnd, wParam, lParam); render_do_lbuttonup(hwnd, wParam, lParam); { BOOL rc; RECT rt; rc = GetWindowRect(hwnd, &rt); if (rc) { g_gui_prefs.oldpos_x = rt.left; g_gui_prefs.oldpos_y = rt.top; } } break; case WM_RBUTTONDOWN: { int item; POINT pt; if (!m_bRipping) { GetCursorPos (&pt); SetForegroundWindow (hwnd); item = TrackPopupMenu (m_hmenu_context_sub, 0, pt.x, pt.y, (int)NULL, hwnd, NULL); } } break; case WM_APP+0: handle_wm_app (hwnd, wParam, lParam); break; case WM_APP+1: /* Exit request from thread */ quit (); PostQuitMessage( 0 ); break; case WM_DESTROY: debug_printf ("Got WM_DESTROY\n"); PostQuitMessage( 0 ); break; case WM_QUIT: debug_printf ("Got WM_QUIT\n"); break; } return DefWindowProc (hwnd, umsg, wParam, lParam); }
/********************************************************************** * Functions *********************************************************************/ BOOL CALLBACK IH_DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { g_HWND=hwndDlg; EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_INLINE), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_COPY), FALSE); } return TRUE; case WM_HELP: { char id[10]=""; sprintf(id, "%d", IDS_HELPINLINE); SetEnvironmentVariableA("HELPID", id); SetEnvironmentVariableA("HELPTITLE", "Inline Help"); DialogBox(hInst, MAKEINTRESOURCE(DLG_HELP), hwndDlg, DlgHelp); } return TRUE; case WM_BROWSE: { strcpy(g_szFileName, (const char*)wParam); //Retrieve the directory of the file. int i=strlen(g_szFileName)-1; int j=0; while(g_szFileName[i]!='\\') { i--; j++; } strncpy(g_szTargetDir, g_szFileName, strlen(g_szFileName)-j-1); //Retrieve stuff. EnableWindow(GetDlgItem(g_HWND, IDC_BTN_INLINE), FALSE); EnableWindow(GetDlgItem(g_HWND, IDC_BTN_COPY), FALSE); SendDlgItemMessageA(g_HWND, IDC_EDT_OEP, EM_SETREADONLY, 0, 0); //Enable change of OEP... DragAcceptFiles(g_HWND, FALSE); g_FileIsDll=IH_Debugger(g_szFileName, &g_TargetData, IH_DebugEnd_Callback, IH_ErrorMessageCallback); } return TRUE; case WM_DROPFILES: { //Get the dropped file name. DragQueryFileA((HDROP)wParam, 0, g_szFileName, 256); //Retrieve the directory of the file. int i=strlen(g_szFileName)-1; int j=0; while(g_szFileName[i]!='\\') { i--; j++; } strncpy(g_szTargetDir, g_szFileName, strlen(g_szFileName)-j-1); //Retrieve stuff. EnableWindow(GetDlgItem(g_HWND, IDC_BTN_INLINE), FALSE); EnableWindow(GetDlgItem(g_HWND, IDC_BTN_COPY), FALSE); SendDlgItemMessageA(g_HWND, IDC_EDT_OEP, EM_SETREADONLY, 0, 0); //Enable change of OEP... DragAcceptFiles(g_HWND, FALSE); g_FileIsDll=IH_Debugger(g_szFileName, &g_TargetData, IH_DebugEnd_Callback, IH_ErrorMessageCallback); } return TRUE; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_BTN_INLINE: { NoFocus(); if(!(g_TargetData.EmptyEntry)) { MessageBoxA(hwndDlg, "You need to specify the place to start the inline...", "N00B!", MB_ICONERROR); return TRUE; } char patch_filename[256]=""; patch_filename[0]=0; OPENFILENAME ofstruct; memset(&ofstruct, 0, sizeof(ofstruct)); ofstruct.lStructSize=sizeof(ofstruct); ofstruct.hwndOwner=hwndDlg; ofstruct.hInstance=hInst; if(!g_FileIsDll) ofstruct.lpstrFilter="Executable files (*.exe)\0*.exe\0\0"; else ofstruct.lpstrFilter="Executable files (*.dll)\0*.dll\0\0"; ofstruct.lpstrFile=patch_filename; ofstruct.nMaxFile=256; ofstruct.lpstrInitialDir=g_szTargetDir; ofstruct.lpstrTitle="Save file"; if(!g_FileIsDll) ofstruct.lpstrDefExt="exe"; else ofstruct.lpstrDefExt="dll"; ofstruct.Flags=OFN_EXTENSIONDIFFERENT|OFN_HIDEREADONLY|OFN_NONETWORKBUTTON|OFN_OVERWRITEPROMPT; GetSaveFileName(&ofstruct); if(!patch_filename[0]) { MessageBoxA(hwndDlg, "You must select a file...", "Warning", MB_ICONWARNING); return TRUE; } CopyFileA(g_szFileName, patch_filename, FALSE); SetPE32Data(patch_filename, 0, UE_OEP, g_TargetData.EmptyEntry-g_TargetData.ImageBase); long newflags=(long)GetPE32Data(patch_filename, g_TargetData.EntrySectionNumber, UE_SECTIONFLAGS); SetPE32Data(patch_filename, g_TargetData.EntrySectionNumber, UE_SECTIONFLAGS, (newflags|0x80000000)); IH_GenerateAsmCode(g_codeText, g_TargetData); CopyToClipboard(g_codeText); MessageBoxA(hwndDlg, "1) Open the file you just saved with OllyDbg\n2) Open Multimate Assembler v1.5+\n3) Paste the code\n4) Modify the code to do something with the Security DLL\n5) Save the patched file with OllyDbg\n6) Enjoy!", "Instructions", MB_ICONINFORMATION); } return TRUE; case IDC_EDT_FREESPACE: { char free_temp[10]=""; GetDlgItemTextA(hwndDlg, IDC_EDT_FREESPACE, free_temp, 10); sscanf(FormatTextHex(free_temp), "%X", &(g_TargetData.EmptyEntry)); } return TRUE; case IDC_BTN_COPY: { NoFocus(); if(g_codeText[0]) { IH_GenerateAsmCode(g_codeText, g_TargetData); CopyToClipboard(g_codeText); MessageBoxA(hwndDlg, "Code copied to clipboard!", "Yay!", MB_ICONINFORMATION); } else MessageBoxA(hwndDlg, "There is no code to copy, please load a file first...", "Error!", MB_ICONERROR); } return TRUE; case IDC_BTN_PLUGINS: { NoFocus(); PLUGFUNC PluginFunction; HINSTANCE PLUGIN_INST; char total_found_s[5]=""; char plugin_name[100]=""; char plugin_dll[100]=""; char dll_to_load[256]=""; char temp_str[5]=""; int total_found=0; GetPrivateProfileStringA("Plugins", "total_found", "", total_found_s, 4, sg_szPluginIniFilePath); sscanf(total_found_s, "%d", &total_found); if(total_found) { HMENU myMenu=0; myMenu=CreatePopupMenu(); for(int i=1; i!=(total_found+1); i++) { sprintf(temp_str, "%d", i); GetPrivateProfileStringA(temp_str, "plugin_name", "", plugin_name, 100, sg_szPluginIniFilePath); AppendMenuA(myMenu, MF_STRING, i, plugin_name); } POINT cursorPos; GetCursorPos(&cursorPos); SetForegroundWindow(hwndDlg); UINT MenuItemClicked=TrackPopupMenu(myMenu, TPM_RETURNCMD|TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0); SendMessage(hwndDlg, WM_NULL, 0, 0); if(!MenuItemClicked) return TRUE; sprintf(temp_str, "%d", (int)MenuItemClicked); GetPrivateProfileStringA(temp_str, "plugin_dll", "", plugin_dll, 100, sg_szPluginIniFilePath); sprintf(dll_to_load, "plugins\\%s", plugin_dll); PLUGIN_INST=LoadLibraryA(dll_to_load); if(!PLUGIN_INST) MessageBoxA(hwndDlg, "There was an error loading the plugin", plugin_dll, MB_ICONERROR); else { PluginFunction=(PLUGFUNC)GetProcAddress(PLUGIN_INST, "PluginFunction"); if(!PluginFunction) MessageBoxA(hwndDlg, "The export \"PluginFunction\" could not be found, please contact the plugin supplier", plugin_dll, MB_ICONERROR); else { if(!g_TargetData.ImageBase) g_TargetData.ImageBase=0x400000; ShowWindow(GetParent(hwndDlg), 0); PluginFunction(PLUGIN_INST, hwndDlg, g_TargetData.SecurityAddrRegister, sg_szAKTDirectory, g_TargetData.ImageBase); ShowWindow(GetParent(hwndDlg), 1); FreeLibrary(PLUGIN_INST); SetForegroundWindow(hwndDlg); } } } else { HMENU myMenu=0; myMenu=CreatePopupMenu(); AppendMenuA(myMenu, MF_STRING|MF_GRAYED, 1, "No plugins found :("); POINT cursorPos; GetCursorPos(&cursorPos); SetForegroundWindow(hwndDlg); TrackPopupMenu(myMenu, TPM_RETURNCMD|TPM_NONOTIFY, cursorPos.x, cursorPos.y, 0, hwndDlg, 0); } } return TRUE; case IDC_EDT_OEP: { char temp_oep[10]=""; GetDlgItemTextA(hwndDlg, IDC_EDT_OEP, temp_oep, 10); sscanf(temp_oep, "%X", &(g_TargetData.OEP)); } return TRUE; } } return TRUE; } return FALSE; }
void ShowOTRMenu(MCONTACT hContact, POINT pt){ HMENU menu = (HMENU) CallService(MS_MIROTR_MENUBUILDMIROTR, hContact, 0); SetWindowLongPtr(hDummyPaintWin, GWLP_USERDATA, (LONG_PTR)hContact); TrackPopupMenu(menu, 0, pt.x, pt.y, 0, hDummyPaintWin, 0); DestroyMenu(menu); }
LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static POINT ptLast; static int iMousedown; if (msg == WM_TASKBARCREATED) { CreateSystrayIcon(FALSE); if (nen_options.bTraySupport) CreateSystrayIcon(TRUE); return 0; } switch (msg) { case WM_CREATE: int i; for(i = 0; i < safe_sizeof(_hotkeydescs); i++) { _hotkeydescs[i].cbSize = sizeof(HOTKEYDESC); CallService(MS_HOTKEY_REGISTER, 0, (LPARAM)&_hotkeydescs[i]); } WM_TASKBARCREATED = RegisterWindowMessageA("TaskbarCreated"); ShowWindow(hwndDlg, SW_HIDE); hSvcHotkeyProcessor = CreateServiceFunction(MS_TABMSG_HOTKEYPROCESS, HotkeyProcessor); SetTimer(hwndDlg, TIMERID_SENDLATER, TIMEOUT_SENDLATER, NULL); break; case WM_HOTKEY: { CLISTEVENT *cli = 0; cli = (CLISTEVENT *)CallService(MS_CLIST_GETEVENT, (WPARAM)INVALID_HANDLE_VALUE, (LPARAM)0); if (cli != NULL) { if (strncmp(cli->pszService, "SRMsg/TypingMessage", strlen(cli->pszService))) { CallService(cli->pszService, 0, (LPARAM)cli); break; } } if (wParam == 0xc001) SendMessage(hwndDlg, DM_TRAYICONNOTIFY, 101, WM_MBUTTONDOWN); break; } /* * handle the popup menus (session list, favorites, recents... * just draw some icons, nothing more :) */ case WM_MEASUREITEM: { LPMEASUREITEMSTRUCT lpmi = (LPMEASUREITEMSTRUCT) lParam; lpmi->itemHeight = 0; lpmi->itemWidth = 6; return TRUE; } case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam; struct TWindowData *dat = 0; if (dis->CtlType == ODT_MENU && (dis->hwndItem == (HWND)PluginConfig.g_hMenuFavorites || dis->hwndItem == (HWND)PluginConfig.g_hMenuRecent)) { HICON hIcon = (HICON)dis->itemData; DrawMenuItem(dis, hIcon, 0); return TRUE; } else if (dis->CtlType == ODT_MENU) { HWND hWnd = M->FindWindow((HANDLE)dis->itemID); DWORD idle = 0; if (hWnd == NULL) { SESSION_INFO *si = SM_FindSessionByHCONTACT((HANDLE)dis->itemID); hWnd = si ? si->hWnd : 0; } if (hWnd) dat = (struct TWindowData *)GetWindowLongPtr(hWnd, GWLP_USERDATA); if (dis->itemData >= 0) { HICON hIcon; BOOL fNeedFree = FALSE; if (dis->itemData > 0) hIcon = dis->itemData & 0x10000000 ? hIcons[ICON_HIGHLIGHT] : PluginConfig.g_IconMsgEvent; else if (dat != NULL) { hIcon = MY_GetContactIcon(dat); idle = dat->idle; } else hIcon = PluginConfig.g_iconContainer; DrawMenuItem(dis, hIcon, idle); if (fNeedFree) DestroyIcon(hIcon); return TRUE; } } } break; case DM_TRAYICONNOTIFY: { int iSelection; if (wParam == 100 || wParam == 101) { switch (lParam) { case WM_LBUTTONUP: { POINT pt; GetCursorPos(&pt); if (wParam == 100) SetForegroundWindow(hwndDlg); if (GetMenuItemCount(PluginConfig.g_hMenuTrayUnread) > 0) { iSelection = TrackPopupMenu(PluginConfig.g_hMenuTrayUnread, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); HandleMenuEntryFromhContact(iSelection); } else TrackPopupMenu(GetSubMenu(PluginConfig.g_hMenuContext, 8), TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); if (wParam == 100) PostMessage(hwndDlg, WM_NULL, 0, 0); break; } case WM_MBUTTONDOWN: { MENUITEMINFOA mii = {0}; int i, iCount = GetMenuItemCount(PluginConfig.g_hMenuTrayUnread); if (wParam == 100) SetForegroundWindow(hwndDlg); if (iCount > 0) { UINT uid = 0; mii.fMask = MIIM_DATA; mii.cbSize = sizeof(mii); i = iCount - 1; do { GetMenuItemInfoA(PluginConfig.g_hMenuTrayUnread, i, TRUE, &mii); if (mii.dwItemData > 0) { uid = GetMenuItemID(PluginConfig.g_hMenuTrayUnread, i); HandleMenuEntryFromhContact(uid); break; } } while (--i >= 0); if (uid == 0 && pLastActiveContainer != NULL) { // no session found, restore last active container if (IsIconic(pLastActiveContainer->hwnd) || !IsWindowVisible(pLastActiveContainer->hwnd)) { SendMessage(pLastActiveContainer->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); SetForegroundWindow(pLastActiveContainer->hwnd); } else { if(PluginConfig.m_HideOnClose) ShowWindow(pLastActiveContainer->hwnd, SW_HIDE); else SendMessage(pLastActiveContainer->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); } } } if (wParam == 100) PostMessage(hwndDlg, WM_NULL, 0, 0); break; } case WM_RBUTTONUP: { HMENU submenu = PluginConfig.g_hMenuTrayContext; POINT pt; if (wParam == 100) SetForegroundWindow(hwndDlg); GetCursorPos(&pt); CheckMenuItem(submenu, ID_TRAYCONTEXT_DISABLEALLPOPUPS, MF_BYCOMMAND | (nen_options.iDisable ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(submenu, ID_TRAYCONTEXT_DON40223, MF_BYCOMMAND | (nen_options.iNoSounds ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(submenu, ID_TRAYCONTEXT_DON, MF_BYCOMMAND | (nen_options.iNoAutoPopup ? MF_CHECKED : MF_UNCHECKED)); EnableMenuItem(submenu, ID_TRAYCONTEXT_HIDEALLMESSAGECONTAINERS, MF_BYCOMMAND | (nen_options.bTraySupport) ? MF_ENABLED : MF_GRAYED); CheckMenuItem(submenu, ID_TRAYCONTEXT_SHOWTHETRAYICON, MF_BYCOMMAND | (nen_options.bTraySupport ? MF_CHECKED : MF_UNCHECKED)); iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); if (iSelection) { MENUITEMINFO mii = {0}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA | MIIM_ID; GetMenuItemInfo(submenu, (UINT_PTR)iSelection, FALSE, &mii); if (mii.dwItemData != 0) { // this must be an itm of the fav or recent menu HandleMenuEntryFromhContact(iSelection); } else { switch (iSelection) { case ID_TRAYCONTEXT_SHOWTHETRAYICON: nen_options.bTraySupport = !nen_options.bTraySupport; CreateSystrayIcon(nen_options.bTraySupport ? TRUE : FALSE); break; case ID_TRAYCONTEXT_DISABLEALLPOPUPS: nen_options.iDisable ^= 1; break; case ID_TRAYCONTEXT_DON40223: nen_options.iNoSounds ^= 1; break; case ID_TRAYCONTEXT_DON: nen_options.iNoAutoPopup ^= 1; break; case ID_TRAYCONTEXT_HIDEALLMESSAGECONTAINERS: { struct TContainerData *pContainer = pFirstContainer; while (pContainer) { ShowWindow(pContainer->hwnd, SW_HIDE); pContainer = pContainer->pNextContainer; } break; } case ID_TRAYCONTEXT_RESTOREALLMESSAGECONTAINERS: { struct TContainerData *pContainer = pFirstContainer; while (pContainer) { ShowWindow(pContainer->hwnd, SW_SHOW); pContainer = pContainer->pNextContainer; } break; } case ID_TRAYCONTEXT_BE: { struct TContainerData *pContainer = pFirstContainer; nen_options.iDisable = 1; nen_options.iNoSounds = 1; nen_options.iNoAutoPopup = 1; while (pContainer) { SendMessage(pContainer->hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 1); pContainer = pContainer->pNextContainer; } break; } } } } if (wParam == 100) PostMessage(hwndDlg, WM_NULL, 0, 0); break; } default: break; } } break; } /* * handle an event from the popup module (mostly window activation). Since popups may run in different threads, the message * is posted to our invisible hotkey handler which does always run within the main thread. * wParam is the hContact * lParam the event handle */ case DM_HANDLECLISTEVENT: { CLISTEVENT *cle = (CLISTEVENT *)CallService(MS_CLIST_GETEVENT, wParam, 0); /* * if lParam == NULL, don't consider clist events, just open the message tab */ if(lParam == 0) { HandleMenuEntryFromhContact((int)wParam); break; } /* * first try, if the clist returned an event... */ if (cle) { if (ServiceExists(cle->pszService)) { CallService(cle->pszService, (WPARAM)NULL, (LPARAM)cle); CallService(MS_CLIST_REMOVEEVENT, (WPARAM)cle->hContact, (LPARAM)cle->hDbEvent); } } else { // still, we got that message posted.. the event may be waiting in tabSRMMs tray... HandleMenuEntryFromhContact((int)wParam); } break; } case DM_DOCREATETAB: { HWND hWnd = M->FindWindow((HANDLE)lParam); if (hWnd && IsWindow(hWnd)) { struct TContainerData *pContainer = 0; SendMessage(hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { int iTabs = TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, IDC_MSGTABS)); if (iTabs == 1) SendMessage(pContainer->hwnd, WM_CLOSE, 0, 1); else SendMessage(hWnd, WM_CLOSE, 0, 1); CreateNewTabForContact((struct TContainerData *)wParam, (HANDLE)lParam, 0, NULL, TRUE, TRUE, FALSE, 0); } } break; } case DM_DOCREATETAB_CHAT: { SESSION_INFO *si = SM_FindSessionByHWND((HWND)lParam); if (si && IsWindow(si->hWnd)) { struct TContainerData *pContainer = 0; SendMessage(si->hWnd, DM_QUERYCONTAINER, 0, (LPARAM)&pContainer); if (pContainer) { int iTabs = TabCtrl_GetItemCount(GetDlgItem(pContainer->hwnd, 1159)); if (iTabs == 1) SendMessage(pContainer->hwnd, WM_CLOSE, 0, 1); else SendMessage(si->hWnd, WM_CLOSE, 0, 1); si->hWnd = CreateNewRoom((struct TContainerData *)wParam, si, TRUE, 0, 0); } } break; } case DM_SENDMESSAGECOMMANDW: SendMessageCommand_W(wParam, lParam); if (lParam) free((void *)lParam); return(0); case DM_SENDMESSAGECOMMAND: SendMessageCommand(wParam, lParam); if (lParam) free((void *)lParam); return(0); /* * sent from the popup to "dismiss" the event. we should do this in the main thread */ case DM_REMOVECLISTEVENT: CallService(MS_CLIST_REMOVEEVENT, wParam, lParam); CallService(MS_DB_EVENT_MARKREAD, wParam, lParam); return(0); case DM_SETLOCALE: { HKL hkl = (HKL)lParam; HANDLE hContact = (HANDLE)wParam; HWND hWnd = M->FindWindow(hContact); if(hWnd) { TWindowData *dat = (TWindowData *)GetWindowLongPtr(hWnd, GWLP_USERDATA); if(dat) { DBVARIANT dbv; if(hkl) { dat->hkl = hkl; PostMessage(dat->hwnd, DM_SETLOCALE, 0, 0); } if(0 == M->GetTString(hContact, SRMSGMOD_T, "locale", &dbv)) { GetLocaleID(dat, dbv.ptszVal); DBFreeVariant(&dbv); UpdateReadChars(dat); } } } return(0); } /* * react to changes in the desktop composition state * (enable/disable DWM, change to a non-aero visual style * or classic Windows theme */ case WM_DWMCOMPOSITIONCHANGED: { bool fNewAero = M->getAeroState(); // refresh dwm state SendMessage(hwndDlg, WM_THEMECHANGED, 0, 0); TContainerData *pContainer = pFirstContainer; while (pContainer) { if(fNewAero) SetAeroMargins(pContainer); else { MARGINS m = {0}; if(M->m_pfnDwmExtendFrameIntoClientArea) M->m_pfnDwmExtendFrameIntoClientArea(pContainer->hwnd, &m); } if(pContainer->SideBar->isActive()) RedrawWindow(GetDlgItem(pContainer->hwnd, 5000), NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW); // the container for the sidebar buttons RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN); pContainer = pContainer->pNextContainer; } M->BroadcastMessage(WM_DWMCOMPOSITIONCHANGED, 0, 0); break; } /* * this message is fired when the user changes desktop color * settings (Desktop->personalize) * the handler reconfigures the aero-related skin images for * tabs and buttons to match the new desktop color theme. */ case WM_DWMCOLORIZATIONCOLORCHANGED: { M->getAeroState(); Skin->setupAeroSkins(); CSkin::initAeroEffect(); break; } /* * user has changed the visual style or switched to/from * classic Windows theme */ case WM_THEMECHANGED: { struct TContainerData *pContainer = pFirstContainer; M->getAeroState(); Skin->setupTabCloseBitmap(); CSkin::initAeroEffect(); PluginConfig.m_ncm.cbSize = sizeof(NONCLIENTMETRICS); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &PluginConfig.m_ncm, 0); FreeTabConfig(); ReloadTabConfig(); while (pContainer) { SendMessage(GetDlgItem(pContainer->hwnd, IDC_MSGTABS), EM_THEMECHANGED, 0, 0); BroadCastContainer(pContainer, EM_THEMECHANGED, 0, 0); pContainer = pContainer->pNextContainer; } break; } case DM_SPLITSENDACK: { ACKDATA ack = {0}; struct SendJob *job = sendQueue->getJobByIndex((int)wParam); ack.hContact = job->hOwner; ack.hProcess = job->hSendId; ack.type = ACKTYPE_MESSAGE; ack.result = ACKRESULT_SUCCESS; if (job->hOwner && job->iAcksNeeded && job->hOwner && job->iStatus == SendQueue::SQ_INPROGRESS) { if (IsWindow(job->hwndOwner)) ::SendMessage(job->hwndOwner, HM_EVENTSENT, (WPARAM)MAKELONG(wParam, 0), (LPARAM)&ack); else sendQueue->ackMessage(0, (WPARAM)MAKELONG(wParam, 0), (LPARAM)&ack); } return 0; } case DM_LOGSTATUSCHANGE: CGlobals::logStatusChange(wParam, reinterpret_cast<CContactCache *>(lParam)); return(0); case DM_MUCFLASHWORKER: { FLASH_PARAMS *p = reinterpret_cast<FLASH_PARAMS*>(lParam); if(1 == wParam) { CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)p->hContact, 1); p->bActiveTab = TRUE; p->bInactive = FALSE; p->bMustAutoswitch = p->bMustFlash = FALSE; } if(2 == wParam) { p->bActiveTab = TRUE; p->bInactive = FALSE; p->bMustAutoswitch = p->bMustFlash = FALSE; SendMessage(p->hWnd, DM_ACTIVATEME, 0, 0); } DoFlashAndSoundWorker(p); return(0); } case WM_POWERBROADCAST: case WM_DISPLAYCHANGE: { struct TContainerData *pContainer = pFirstContainer; while (pContainer) { if (CSkin::m_skinEnabled) { // invalidate cached background DCs for skinned containers pContainer->oldDCSize.cx = pContainer->oldDCSize.cy = 0; SelectObject(pContainer->cachedDC, pContainer->oldHBM); DeleteObject(pContainer->cachedHBM); DeleteDC(pContainer->cachedDC); pContainer->cachedDC = 0; RedrawWindow(pContainer->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME); } pContainer = pContainer->pNextContainer; } break; } case WM_ACTIVATE: if (LOWORD(wParam) != WA_ACTIVE) SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE); return 0; case WM_CLOSE: return 0; case WM_TIMER: if(wParam == TIMERID_SENDLATER) { /* * send heartbeat to each open container (to manage autoclose * feature) */ TContainerData *pContainer = pFirstContainer; /* * send heartbeat to each container, they use this to update * dynamic content (i.e. local time in the info panel). */ while(pContainer) { SendMessage(pContainer->hwnd, WM_TIMER, TIMERID_HEARTBEAT, 0); pContainer = pContainer->pNextContainer; } /* * process send later contacts and jobs, if enough time has elapsed */ if(sendLater->isAvail() && !sendLater->isInteractive() && (time(0) - sendLater->lastProcessed()) > CSendLater::SENDLATER_PROCESS_INTERVAL) { sendLater->setLastProcessed(time(0)); /* * check the list of contacts that may have new send later jobs * (added on user's request) */ sendLater->processContacts(); /* * start processing the job list */ if(!sendLater->isJobListEmpty()) { KillTimer(hwndDlg, wParam); sendLater->startJobListProcess(); SetTimer(hwndDlg, TIMERID_SENDLATER_TICK, TIMEOUT_SENDLATER_TICK, 0); } } } /* * process one entry per tick (default: 200ms) * TODO better timings, possibly slow down when many jobs are in the * queue. */ else if(wParam == TIMERID_SENDLATER_TICK) { if(!sendLater->haveJobs()) { KillTimer(hwndDlg, wParam); SetTimer(hwndDlg, TIMERID_SENDLATER, TIMEOUT_SENDLATER, 0); sendLater->qMgrUpdate(true); } else sendLater->processCurrentJob(); } break; case WM_DESTROY: { KillTimer(hwndDlg, TIMERID_SENDLATER_TICK); KillTimer(hwndDlg, TIMERID_SENDLATER); DestroyServiceFunction(hSvcHotkeyProcessor); break; } } return(DefWindowProc(hwndDlg, msg, wParam, lParam)); }
static void hb_gt_wvw_TBMouseEvent( PWVW_WIN wvw_win, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { POINT xy, colrow; SHORT keyCode = 0; SHORT keyState = 0; PWVW_GLO wvw = hb_gt_wvw(); HB_SYMBOL_UNUSED( hWnd ); HB_SYMBOL_UNUSED( wParam ); if( message == WM_MOUSEMOVE || message == WM_NCMOUSEMOVE ) { if( ! wvw_win->MouseMove ) return; } xy.x = LOWORD( lParam ); xy.y = HIWORD( lParam ); colrow = hb_gt_wvw_TBGetColRowFromXY( wvw_win, xy.x, xy.y ); hb_gt_wvw_SetMouseX( wvw_win, colrow.x ); hb_gt_wvw_SetMouseY( wvw_win, colrow.y ); switch( message ) { case WM_LBUTTONDBLCLK: keyCode = K_LDBLCLK; break; case WM_RBUTTONDBLCLK: keyCode = K_RDBLCLK; break; case WM_LBUTTONDOWN: { HWND hWndFocus = GetFocus(); if( hb_gt_wvw_GetControlClass( wvw_win, hWndFocus ) > 0 ) SetFocus( hWnd ); keyCode = K_LBUTTONDOWN; break; } case WM_RBUTTONDOWN: keyCode = K_RBUTTONDOWN; break; case WM_LBUTTONUP: keyCode = K_LBUTTONUP; break; case WM_RBUTTONUP: if( wvw_win->hPopup ) { int nPopupRet; GetCursorPos( &xy ); nPopupRet = ( int ) TrackPopupMenu( wvw_win->hPopup, TPM_CENTERALIGN + TPM_RETURNCMD, xy.x, xy.y, 0, hWnd, NULL ); if( nPopupRet ) hb_gt_wvw_AddCharToInputQueue( nPopupRet ); return; } else { keyCode = K_RBUTTONUP; break; } case WM_MBUTTONDOWN: keyCode = K_MBUTTONDOWN; break; case WM_MBUTTONUP: keyCode = K_MBUTTONUP; break; case WM_MBUTTONDBLCLK: keyCode = K_MDBLCLK; break; case WM_MOUSEMOVE: keyState = ( SHORT ) wParam; if( keyState == MK_LBUTTON ) keyCode = K_MMLEFTDOWN; else if( keyState == MK_RBUTTON ) keyCode = K_MMRIGHTDOWN; else if( keyState == MK_MBUTTON ) keyCode = K_MMMIDDLEDOWN; else keyCode = K_MOUSEMOVE; break; case WM_MOUSEWHEEL: keyState = HIWORD( wParam ); if( keyState > 0 ) keyCode = K_MWFORWARD; else keyCode = K_MWBACKWARD; break; case WM_NCMOUSEMOVE: keyCode = K_NCMOUSEMOVE; break; } if( wvw->a.pSymWVW_TBMOUSE && keyCode != 0 && hb_vmRequestReenter() ) { hb_vmPushDynSym( wvw->a.pSymWVW_TBMOUSE ); hb_vmPushNil(); hb_vmPushInteger( wvw_win->nWinId ); hb_vmPushInteger( keyCode ); hb_vmPushInteger( colrow.y ); hb_vmPushInteger( colrow.x ); hb_vmPushInteger( keyState ); hb_vmDo( 5 ); hb_vmRequestRestore(); } hb_gt_wvw_AddCharToInputQueue( keyCode ); }
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { MWinDataType *data = (MWinDataType*)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch(msg) { case WM_CREATE: data = (MWinDataType*)mir_calloc(sizeof(MWinDataType)); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); data->hContact = (HANDLE)((LPCREATESTRUCT)lParam)->lpCreateParams; data->hAvt = CreateWindow(AVATAR_CONTROL_CLASS, TEXT(""), WS_CHILD, 0, 0, opt.AvatarSize, opt.AvatarSize, hwnd, NULL, hInst, 0); if (data->hAvt) SendMessage(data->hAvt, AVATAR_SETCONTACT, 0, (LPARAM)data->hContact); break; case WM_DESTROY: mir_free(data); break; case WM_CONTEXTMENU: { POINT pt; HMENU hMenu; hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)data->hContact, 0); GetCursorPos(&pt); TrackPopupMenu(hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hwnd, NULL); DestroyMenu(hMenu); } break; case WM_MOUSEMOVE: if (f_TrackMouseEvent) { TRACKMOUSEEVENT tme = {0}; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.hwndTrack = hwnd; tme.dwFlags = TME_QUERY; f_TrackMouseEvent(&tme); if (tme.dwFlags == 0) { tme.dwFlags = TME_HOVER | TME_LEAVE; tme.hwndTrack = hwnd; tme.dwHoverTime = CallService(MS_CLC_GETINFOTIPHOVERTIME, 0, 0); f_TrackMouseEvent(&tme); } } break; case WM_MOUSEHOVER: { POINT pt; CLCINFOTIP ti = {0}; GetCursorPos(&pt); GetWindowRect(hwnd, &ti.rcItem); ti.cbSize = sizeof(ti); ti.hItem = data->hContact; ti.ptCursor = pt; ti.isTreeFocused = 1; CallService(MS_TOOLTIP_SHOWTIP, 0, (LPARAM)&ti); } break; case WM_LBUTTONDBLCLK: BriefInfo((WPARAM)data->hContact, 0); break; case WM_COMMAND: //Needed by the contact's context menu if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)data->hContact)) break; return FALSE; case WM_MEASUREITEM: //Needed by the contact's context menu return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: //Needed by the contact's context menu return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); case WM_NOTIFY: if (((LPNMHDR)lParam)->code == NM_AVATAR_CHANGED) { BOOL newava = CallService(MS_AV_GETAVATARBITMAP, (WPARAM)data->hContact, 0) != 0; if (newava != data->haveAvatar) { LONG_PTR style = GetWindowLongPtr(data->hAvt, GWL_STYLE); data->haveAvatar = newava; SetWindowLongPtr(data->hAvt, GWL_STYLE, newava ? (style | WS_VISIBLE) : (style & ~WS_VISIBLE)); RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE); } } break; case WM_REDRAWWIN: if (data->hAvt != NULL) MoveWindow(data->hAvt, 0, 0, opt.AvatarSize, opt.AvatarSize, TRUE); RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); break; case WM_PAINT: { RECT r, rc; if(GetUpdateRect(hwnd, &r, FALSE)) { DBVARIANT dbv = {0}; PAINTSTRUCT ps; HDC hdc; LOGFONT lfnt, lfnt1; COLORREF fntc, fntc1; COLORREF clr; int picSize = opt.AvatarSize; HICON hIcon = NULL; if (!data->haveAvatar) { int statusIcon = DBGetContactSettingWord(data->hContact, WEATHERPROTONAME, "Status", 0); picSize = GetSystemMetrics(SM_CXICON); hIcon = LoadSkinnedProtoIconBig(WEATHERPROTONAME, statusIcon); if ((INT_PTR)hIcon == CALLSERVICE_NOTFOUND) { picSize = GetSystemMetrics(SM_CXSMICON); hIcon = LoadSkinnedProtoIcon(WEATHERPROTONAME, statusIcon); } } clr = DBGetContactSettingDword(NULL, WEATHERPROTONAME, "ColorMwinFrame", GetSysColor(COLOR_3DFACE)); { FontID fntid = {0}; strcpy(fntid.group, WEATHERPROTONAME); strcpy(fntid.name, "Frame Font"); fntc = CallService(MS_FONT_GET, (WPARAM)&fntid, (LPARAM)&lfnt); strcpy(fntid.name, "Frame Title Font"); fntc1 = CallService(MS_FONT_GET, (WPARAM)&fntid, (LPARAM)&lfnt1); } DBGetContactSettingString(data->hContact, WEATHERCONDITION, "WeatherInfo", &dbv); GetClientRect(hwnd, &rc); hdc = BeginPaint(hwnd, &ps); if (ServiceExists(MS_SKIN_DRAWGLYPH)) { SKINDRAWREQUEST rq; memset(&rq, 0, sizeof(rq)); rq.hDC = hdc; rq.rcDestRect = rc; rq.rcClipRect = rc; strcpy(rq.szObjectID, "Main,ID=WeatherFrame"); CallService(MS_SKIN_DRAWGLYPH, (WPARAM)&rq, 0); } if (clr != 0xFFFFFFFF) { HBRUSH hBkgBrush = CreateSolidBrush(clr); FillRect(hdc, &rc, hBkgBrush); DeleteObject(hBkgBrush); } if (!data->haveAvatar) DrawIconEx(hdc, 1, 1, hIcon, 0, 0, 0, NULL, DI_NORMAL); SetBkMode(hdc, TRANSPARENT); { HFONT hfnt = CreateFontIndirect(&lfnt1); HFONT hfntold = SelectObject(hdc, hfnt); SIZE fontSize; char *nick = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)data->hContact, 0); GetTextExtentPoint32(hdc, _T("|"), 1, &fontSize); rc.top += 1; rc.left += picSize + fontSize.cx; SetTextColor(hdc, fntc1); DrawText(hdc, nick, -1, &rc, DT_LEFT | DT_EXPANDTABS); rc.top += fontSize.cy; SelectObject(hdc, hfntold); DeleteObject(hfnt); } if (dbv.pszVal) { HFONT hfnt = CreateFontIndirect(&lfnt); HFONT hfntold = SelectObject(hdc, hfnt); SetTextColor(hdc, fntc); DrawText(hdc, dbv.pszVal, -1, &rc, DT_LEFT | DT_EXPANDTABS); SelectObject(hdc, hfntold); DeleteObject(hfnt); } EndPaint(hwnd, &ps); CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); DBFreeVariant(&dbv); } break; } default: return DefWindowProc(hwnd, msg, wParam, lParam); } return(TRUE); }
INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_AUDIO_CONFIGURE: configureAudioDriver(hDlg); break; case IDC_AUDIO_TEST: if(!PlaySound(MAKEINTRESOURCE(IDW_TESTSOUND), NULL, SND_RESOURCE | SND_SYNC)) MessageBox(NULL, "Audio test failed!", "Error", MB_OK | MB_ICONERROR); break; case IDC_AUDIO_CONTROL_PANEL: MessageBox(NULL, "Launching audio control panel not implemented yet!", "Fixme", MB_OK | MB_ICONERROR); break; case IDC_DSOUND_HW_ACCEL: if (HIWORD(wParam) == CBN_SELCHANGE) { int selected_dsound_accel; int i, j = 0; SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); selected_dsound_accel = SendDlgItemMessage(hDlg, IDC_DSOUND_HW_ACCEL, CB_GETCURSEL, 0, 0); for (i = 0; DSound_HW_Accels[i].settingStr; ++i) { if (DSound_HW_Accels[i].visible) { if (j == selected_dsound_accel) { set_reg_key(config_key, keypath("DirectSound"), "HardwareAcceleration", DSound_HW_Accels[i].settingStr); break; } j++; } } } break; case IDC_DSOUND_RATES: if (HIWORD(wParam) == CBN_SELCHANGE) { int selected_dsound_rate; SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); selected_dsound_rate = SendDlgItemMessage(hDlg, IDC_DSOUND_RATES, CB_GETCURSEL, 0, 0); set_reg_key(config_key, keypath("DirectSound"), "DefaultSampleRate", DSound_Rates[selected_dsound_rate]); } break; case IDC_DSOUND_BITS: if (HIWORD(wParam) == CBN_SELCHANGE) { int selected_dsound_bits; SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); selected_dsound_bits = SendDlgItemMessage(hDlg, IDC_DSOUND_BITS, CB_GETCURSEL, 0, 0); set_reg_key(config_key, keypath("DirectSound"), "DefaultBitsPerSample", DSound_Bits[selected_dsound_bits]); } break; } break; case WM_SHOWWINDOW: set_window_title(hDlg); break; case WM_NOTIFY: switch(((LPNMHDR)lParam)->code) { case PSN_KILLACTIVE: SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE); break; case PSN_APPLY: set_reg_key(config_key, "Drivers", "Audio", curAudioDriver); apply(); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR); break; case PSN_SETACTIVE: break; case NM_CLICK: if (((LPNMHDR)lParam)->idFrom == IDC_AUDIO_TREE) { TVHITTESTINFO ht; DWORD dwPos = GetMessagePos(); HWND tree = ((LPNMHDR)lParam)->hwndFrom; ZeroMemory(&ht, sizeof(ht)); ht.pt.x = (short)LOWORD(dwPos); ht.pt.y = (short)HIWORD(dwPos); MapWindowPoints(HWND_DESKTOP, tree, &ht.pt, 1); SendMessageW( tree, TVM_HITTEST, 0, (LPARAM)&ht ); if (TVHT_ONITEMSTATEICON & ht.flags) { TVITEM tvItem; int index; ZeroMemory(&tvItem, sizeof(tvItem)); tvItem.hItem = ht.hItem; SendMessageW( tree, TVM_GETITEMW, 0, (LPARAM) &tvItem ); index = TreeView_GetItemState(tree, ht.hItem, TVIS_STATEIMAGEMASK); if (index == INDEXTOSTATEIMAGEMASK(1)) { TreeView_SetItemState(tree, ht.hItem, INDEXTOSTATEIMAGEMASK(2), TVIS_STATEIMAGEMASK); addDriver(loadedAudioDrv[tvItem.lParam & 0xff].szDriver); SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM) hDlg, 0); /* enable apply button */ } else if (index == INDEXTOSTATEIMAGEMASK(2)) { TreeView_SetItemState(tree, ht.hItem, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); removeDriver(loadedAudioDrv[tvItem.lParam & 0xff].szDriver); SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM) hDlg, 0); /* enable apply button */ } } } break; case NM_RCLICK: if (((LPNMHDR)lParam)->idFrom == IDC_AUDIO_TREE) { TVHITTESTINFO ht; DWORD dwPos = GetMessagePos(); HWND tree = ((LPNMHDR)lParam)->hwndFrom; POINT pt; ZeroMemory(&ht, sizeof(ht)); pt.x = (short)LOWORD(dwPos); pt.y = (short)HIWORD(dwPos); ht.pt = pt; MapWindowPoints(HWND_DESKTOP, tree, &ht.pt, 1); SendMessageW( tree, TVM_HITTEST, 0, (LPARAM)&ht ); if (TVHT_ONITEMLABEL & ht.flags) { TVITEM tvItem; ZeroMemory(&tvItem, sizeof(tvItem)); tvItem.hItem = ht.hItem; tvItem.mask = TVIF_PARAM; tvItem.lParam = -1; if (TreeView_GetItem(tree, &tvItem)) { if (tvItem.lParam & DRIVER_MASK) { if (hPopupMenus) { TrackPopupMenu(GetSubMenu(hPopupMenus, 0), TPM_RIGHTBUTTON, pt.x, pt.y, 0, tree, NULL); toConfigure = tvItem.lParam & ~DRIVER_MASK; } } else if (tvItem.lParam & DEVICE_MASK) { /* FIXME TBD */ } } } } } break; case WM_INITDIALOG: initAudioDlg(hDlg); break; } return FALSE; }
static BOOL CALLBACK ConfigProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_INITDIALOG: { uTCITEM tabs; memset(&tabs, 0, sizeof(tabs)); HWND wnd_tab = GetDlgItem(wnd, IDC_TAB1); tabs.mask = TCIF_TEXT; tabs.pszText = "Variables"; uTabCtrl_InsertItem(wnd_tab, 0, &tabs); tabs.pszText = "Style"; uTabCtrl_InsertItem(wnd_tab, 1, &tabs); TabCtrl_SetCurSel(wnd_tab, g_cur_tab2); uSendDlgItemMessageText(wnd, IDC_CHAR7, WM_SETTEXT, 0, "\x07"); colour_code_gen(wnd, IDC_COLOUR, false, true); uSendDlgItemMessage(wnd, IDC_STRING, EM_LIMITTEXT, 0, 0); refresh_me(wnd); editproc = (WNDPROC)SetWindowLongPtr(GetDlgItem(wnd, IDC_STRING), GWLP_WNDPROC, (LPARAM)EditHook); g_editor_font_notify.set(GetDlgItem(wnd, IDC_STRING)); } break; case WM_NOTIFY: switch (((LPNMHDR)lp)->idFrom) { case IDC_TAB1: switch (((LPNMHDR)lp)->code) { case TCN_SELCHANGE: { save_string(wnd); int id = TabCtrl_GetCurSel(GetDlgItem(wnd, IDC_TAB1)); g_cur_tab2 = id; uSendDlgItemMessageText(wnd, IDC_STRING, WM_SETTEXT, 0, (g_cur_tab2 == 0 ? cfg_globalstring : cfg_colour)); } break; } break; } break; case WM_DESTROY: { g_editor_font_notify.release(); save_string(wnd); refresh_all_playlist_views(); pvt::ng_playlist_view_t::g_update_all_items(); } break; case WM_COMMAND: switch (wp) { case IDC_GLOBAL: cfg_global = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_DATE: cfg_playlist_date = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); set_day_timer(); pvt::ng_playlist_view_t::g_on_use_date_info_change(); break; case IDC_TFHELP: { RECT rc; GetWindowRect(GetDlgItem(wnd, IDC_TFHELP), &rc); // MapWindowPoints(HWND_DESKTOP, wnd, (LPPOINT)(&rc), 2); HMENU menu = CreatePopupMenu(); enum { IDM_TFHELP = 1, IDM_GHELP = 2, IDM_SPEEDTEST, IDM_PREVIEW, IDM_EDITORFONT, IDM_RESETSTYLE }; uAppendMenu(menu, (MF_STRING), IDM_TFHELP, "Titleformatting &help"); uAppendMenu(menu, (MF_STRING), IDM_GHELP, "&Global help"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_SPEEDTEST, "&Speed test"); uAppendMenu(menu, (MF_STRING), IDM_PREVIEW, "&Preview to console"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_EDITORFONT, "Change editor &font"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_RESETSTYLE, "&Reset style string"); int cmd = TrackPopupMenu(menu, TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, rc.left, rc.bottom, 0, wnd, 0); DestroyMenu(menu); if (cmd == IDM_TFHELP) { standard_commands::main_titleformat_help(); } else if (cmd == IDM_GHELP) { uMessageBox(wnd, COLOUR_HELP "\n\nNew global format: $set_global(var, val), retreive values using $get_global(var)", "Global help", 0); } else if (cmd == IDM_SPEEDTEST) { speedtest(g_columns, cfg_global != 0, cfg_oldglobal != 0, cfg_playlist_date != 0); } else if (cmd == IDM_PREVIEW) { preview_to_console(string_utf8_from_window(wnd, IDC_STRING), g_cur_tab2 != 0 && cfg_global); } else if (cmd == IDM_EDITORFONT) { if (font_picker(wnd, cfg_editor_font)) g_editor_font_notify.on_change(); } else if (cmd == IDM_RESETSTYLE) { extern const char * g_default_colour; cfg_colour = g_default_colour; if (g_cur_tab2 == 1) uSendDlgItemMessageText(wnd, IDC_STRING, WM_SETTEXT, 0, cfg_colour); refresh_all_playlist_views(); pvt::ng_playlist_view_t::g_update_all_items(); } } break; case IDC_OLDGLOBAL: cfg_oldglobal = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_GLOBALSORT: cfg_global_sort = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_APPLY: save_string(wnd); refresh_all_playlist_views(); pvt::ng_playlist_view_t::g_update_all_items(); break; case IDC_PICK_COLOUR: colour_code_gen(wnd, IDC_COLOUR, false, false); break; } } return 0; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { HDC hdc; WinProc_sub = hWnd; PAINTSTRUCT ps; HGDIOBJ hfDefault; RECT rt = { 100,100,1000,1000 }; static char str[256]; int xlnc, ylnc; int Lines; int nScroll; /* 하단 상태바 부분 */ int SBPart[4]; RECT prt; /* 플로팅 팝업 메뉴 부분 */ static COLORREF Color = RGB(255, 0, 0); HBRUSH hBrush; RECT crt; BOOLEAN delresult; switch (iMessage) { case WM_CREATE: AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hPopup, "즐겨찾기목록"); SetMenu(hWnd, hMenu); favorite_page_create(hWnd); EdittextBox = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", NULL, WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL, 115, 10, 300, 21, hWnd, (HMENU)IDC_MAIN_EDIT, NULL, NULL); hfDefault = GetStockObject(DEFAULT_GUI_FONT); SendMessage(EdittextBox, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); SendMessage(EdittextBox, WM_SETTEXT, NULL, (LPARAM)"주소입력창"); button = CreateWindow("BUTTON", "이동", WS_VISIBLE | WS_CHILD | WS_BORDER, 415, 10, 100, 20, hWnd, (HMENU)IDC_MAIN_BUTTON, NULL, NULL); SendMessage(button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); /* 디렉토리 버튼 */ directory_button = CreateWindow("BUTTON", "방문기록보기", WS_VISIBLE | WS_CHILD | WS_BORDER, 520, 10, 100, 20, hWnd, (HMENU)IDC_VISITPAGE_BUTTON, NULL, NULL); SendMessage(directory_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); back_button = CreateWindow("BUTTON", "<-", WS_VISIBLE | WS_CHILD | WS_BORDER, 10, 10, 20, 20, hWnd, (HMENU)BACK_BUTTON, NULL, NULL); front_button = CreateWindow("BUTTON", "->",WS_VISIBLE | WS_CHILD | WS_BORDER, 30, 10, 20, 20, hWnd, (HMENU)FRONT_BUTTON, NULL, NULL); refresh_button = CreateWindow("BUTTON", "새로고침", WS_VISIBLE | WS_CHILD | WS_BORDER, 50, 10, 60, 20, hWnd, (HMENU)REFRESH_BUTTON, NULL, NULL); SendMessage(refresh_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); favorite_button = CreateWindow("BUTTON", "★", WS_VISIBLE | WS_CHILD | WS_BORDER, 622, 10, 20, 20, hWnd, (HMENU)FAVORITE_BUTTON, NULL, NULL); SendMessage(favorite_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); SetFocus(EdittextBox); OldEditProc = (WNDPROC)SetWindowLongPtr(EdittextBox, GWLP_WNDPROC, (LONG_PTR)SubEditProc); /* 스크롤바 부분 시작*/ xPos = 0; yPos = 0; xMax = 1000; yMax = 1000; SetScrollRange(hWnd, SB_VERT, 0, yMax, TRUE); SetScrollPos(hWnd, SB_VERT, 0, TRUE); SetScrollRange(hWnd, SB_HORZ, 0, xMax, TRUE); SetScrollPos(hWnd, SB_HORZ, 0, TRUE); SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &Lines, 0); WheelUnit = WHEEL_DELTA / Lines; /* 하단 상태바 부분 시작*/ InitCommonControls(); hState = CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", hWnd, 0); SBPart[0] = 200; SBPart[1] = 500; SBPart[2] = 700; //남는 공간 나머지 할당 SBPart[3] = -1; SendMessage(hState, SB_SETPARTS, 4, (LPARAM)SBPart); SendMessage(hState, SB_SETTEXT, 0, (LPARAM) ""); //Progress bar SendMessage(hState, SB_SETTEXT, 1, (LPARAM) ""); //이미지 파일 이름 저장되는 공간 SendMessage(hState, SB_SETTEXT, 2, (LPARAM) ""); //다운로드파일 버튼 /* 프로그레스바 부분 시작 */ if (Pos) return 0; SendMessage(hState, SB_GETRECT, 0, (LPARAM)&prt); hProg = CreateWindow(PROGRESS_CLASS, NULL, WS_CHILD | PBS_SMOOTH | WS_VISIBLE, prt.left, prt.top, prt.right - prt.left, prt.bottom - prt.top, hState, NULL, g_hInst, NULL); Pos = 0; SendMessage(hProg, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); SendMessage(hProg, PBM_SETPOS, Pos, 0); ShowWindow(hProg, SW_SHOW); //SendMessage(hState, SB_GETRECT, 2, (LPARAM)&prt); //두번째 빈칸 나중에 활용하기 break; //This is where we change the color of the static to blue. If you only want the cursor //to change to a hand when the mouse passes over you don't need this stuff. case WM_CTLCOLORSTATIC: SetTextColor((HDC)wParam, RGB(0, 0, 255)); SetBkMode((HDC)wParam, TRANSPARENT); return (LONG)GetStockObject(NULL_BRUSH); /* 하이퍼링크 부분*/ /* case WM_SETCURSOR: if ((HWND)wParam == hwndStatic) { if (colormsg == 1) return TRUE; SendMessage(hwndStatus, SB_SETTEXT, 0, (LONG) "Email : [email protected]"); SendMessage(hwndStatic, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 1); colormsg = 1; InvalidateRgn((HWND)hWnd, 0, 1); SetCursor(mycur); return TRUE; } //If not on the static, change the font back to normal. You don't have to worry //about the cursor, it will change back to the arrow automatically. I use the //'colormsg' flag so it doesn't continually set the font when the cursor is moving //around, because it causes it to flicker. If you only use the cursor change and //don't worry about the font change you don't have to worry. if (colormsg == 1) { colormsg = 0; SendMessage(hwndStatus, SB_SETTEXT, 0, 0); SendMessage(hwndStatic, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); InvalidateRgn((HWND)hWnd, 0, 1); } break; */ /* 마우스 오른쪽 팝업 메뉴 */ case WM_CONTEXTMENU: hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU1)); hPopup = GetSubMenu(hMenu, 0); TrackPopupMenu(hPopup, TPM_LEFTALIGN, (short)LOWORD(lParam), (short)HIWORD(lParam), 0, hWnd, NULL); DestroyMenu(hMenu); break; case WM_LBUTTONDOWN: //BitBlt(GetDC(hWnd), 0, 0, 1000, 1000, 0, 0, 0, WHITENESS); //그냥 화면을 하얗게만 할 뿐 뒤에 남아있음 //image_hyperlink_maker(WinProc_sub, "www.daum.net"); break; case WM_SIZE: SendMessage(hState, WM_SIZE, wParam, lParam); MoveWindow(hList, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);//디렉터리 탐색창 break; case WM_COMMAND: if ((HWND)lParam == hwndStatic) { //ShellExecute(Main_hWnd, "open", "www.naver.com", 0, 0, 0); cases = 2; //케이스 2번으로 하고 해야 계속해서 링크를 통해 이미지를 받아올 수 있음 clientsocket(textbox_buffer, PORT_NUM); //cases = 2이기 때문에 그냥 바로 요청하면 된다. //input_valid_check(textbox_buffer); // 주소체크하고 dns 실행할지말지 결정 InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); } switch (LOWORD(wParam)) { case 50001: favorite_clicked(50001);break; case 50002: favorite_clicked(50002);break; case 50003: favorite_clicked(50003);break; case 50004: favorite_clicked(50004);break; case 50005: favorite_clicked(50005);break; case 50006: favorite_clicked(50006);break; case 50007: favorite_clicked(50007);break; case 50008: favorite_clicked(50008);break; case 50009: favorite_clicked(50009);break; case 50010: favorite_clicked(50010);break; case 50011: favorite_clicked(50011);break; case 50012: favorite_clicked(50012);break; case IDC_MAIN_BUTTON: // when button is clicked, this will happen: 버튼부분 SendMessage(EdittextBox, WM_GETTEXT, sizeof(textbox_buffer) / sizeof(textbox_buffer[0]), reinterpret_cast<LPARAM>(textbox_buffer)); image_file_name = NULL; Save_visit_page(textbox_buffer); input_valid_check(textbox_buffer); // 주소체크하고 dns 실행할지말지 결정 InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case IDC_VISITPAGE_BUTTON: printf("방문기록보기 버튼 클릭!\n"); Search_visit_page(); SetWindowText(Main_hWnd, "방문기록보기"); //ShellExecute(NULL, "open", "http://www.google.com", NULL, NULL, SW_SHOWNORMAL); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case BACK_BUTTON: back_button_page(textbox_buffer); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case FRONT_BUTTON: front_button_page(textbox_buffer); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case REFRESH_BUTTON: //새로고침 if (textbox_buffer[0] == NULL) break; input_valid_check(textbox_buffer); // 주소체크하고 dns 실행할지말지 결정 InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case FAVORITE_BUTTON: //즐겨찾기 등록 favorite_page(textbox_buffer, strlen(textbox_buffer), hWnd); break; case ID_FILE_40001: //잘라내기 break; case ID_FILE_40003: //복사 break; case ID_FILE_40004: //삭제 delresult = DeleteFile("lenna.bmp"); //현재 미구현 디폴트상황 if(delresult == TRUE) MessageBox(NULL, "파일삭제 성공!", "파일삭제!", MB_ICONINFORMATION); else MessageBox(NULL, "파일이 없습니다!(이미 삭제되거나 없는 파일)", "파일삭제실패!", MB_ICONINFORMATION); break; case ID_FILE_RENAME: //이름바꾸기 break; case ID_FILE_PROPERTY: //속성 break; } break; /* case WM_CHAR: //사용자로부터 그냥 입력받을 때 동작 len = strlen(str); str[len] = (TCHAR)wParam; str[len + 1] = 0; InvalidateRect(hWnd, NULL, FALSE); break; */ case WM_PAINT: //사용자로부터 입력받은 것을 화면에 뿌려줌 hdc = BeginPaint(hWnd, &ps); DrawText(hdc, totalresult, -1, &rt, DT_CENTER | DT_WORDBREAK | DT_NOCLIP); Draw_Image(hdc, image_file_name, 300, 300); SendMessage(hState, SB_SETTEXT, 1, (LPARAM)image_file_name); //하단 상태바에 받은 이미지 파일 이름 출력 EndPaint(hWnd, &ps); SendMessage(hwndStatic, WM_ENABLE | WM_ERASEBKGND | WM_DESTROY, NULL, 1); break; case WM_MOUSEWHEEL: nScroll = 0; SumDelta += (short)HIWORD(wParam); while (abs(SumDelta) >= WheelUnit) { if (SumDelta > 0) { nScroll--; original_position--; SumDelta -= WheelUnit; } else { //스크롤바 내려갈때 nScroll++; original_position++; SumDelta += WheelUnit; } } while (nScroll != 0) { if (nScroll > 0) { SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEDOWN, 0), 0); nScroll--; } else { SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEUP, 0), 0); nScroll++; } } if (original_position == 0) { InvalidateRect(Main_hWnd, NULL, TRUE); UpdateWindow(Main_hWnd); } break; case WM_HSCROLL: //가로스크롤 xlnc = 0; switch (LOWORD(wParam)) { case SB_LINELEFT: xlnc = -1; break; case SB_LINERIGHT: xlnc = -20; break; case SB_PAGELEFT: xlnc = -20; break; case SB_PAGERIGHT: xlnc = 20; break; case SB_THUMBTRACK: xlnc = HIWORD(wParam) - xPos; break; default: InvalidateRect(Main_hWnd, NULL, TRUE); UpdateWindow(Main_hWnd); break; } //새로운 위치는 최소한 0 이상 if (xPos + xlnc < 0) xlnc = -xPos; //새로운 위치는 최대한 xMax 이하 if (xPos + xlnc > xMax) xlnc = xMax - xPos; //새로운 위치 계산 xPos = xPos + xlnc; //스크롤 시키고 썸 위치를 다시 계산한다. ScrollWindow(hWnd, -xlnc, 0, NULL, NULL); SetScrollPos(hWnd, SB_HORZ, xPos, TRUE); break; case WM_VSCROLL: //세로 스크롤 ylnc = 0; switch (LOWORD(wParam)) { case SB_LINEUP: ylnc = -1; break; case SB_LINEDOWN: ylnc = 1; break; case SB_PAGEUP: ylnc = -20; break; case SB_PAGEDOWN: ylnc = 20; break; case SB_THUMBTRACK: ylnc = HIWORD(wParam) - yPos; break; default: InvalidateRect(Main_hWnd, NULL, TRUE); UpdateWindow(Main_hWnd); break; } //새로운 위치는 최소한 0 이상 if (yPos + ylnc < 0) ylnc = -yPos; //새로운 위치는 최대한 yMax 이하 if (yPos + ylnc > yMax) ylnc = yMax - yPos; //새로운 위치 계산 yPos = yPos + ylnc; //스크롤 시키고 썸 위치를 다시 계산한다. ScrollWindow(hWnd, 0, -ylnc, NULL, NULL); SetScrollPos(hWnd, SB_VERT, yPos, TRUE); break; case WM_DESTROY: SetWindowLongPtr(EdittextBox, GWLP_WNDPROC, (LONG_PTR)OldEditProc); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, iMessage, wParam, lParam); } }
static LRESULT CALLBACK wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { POINT pt; NOTIFYICONDATA nid; RECT rect; char *txt; #if 0 if(message!=WM_CTLCOLORSTATIC && message!=WM_TIMER) log(LOG_DEBUG, "Window message: %d", message); #endif switch (message) { case WM_CREATE: if (options.option.taskbar) /* taskbar update enabled? */ SetTimer(hwnd, 0x29a, 1000, NULL); /* 1-second timer */ return TRUE; case WM_SIZE: GetClientRect(hwnd, &rect); MoveWindow(EditControl, 0, 0, rect.right, rect.bottom, TRUE); UpdateWindow(EditControl); return TRUE; case WM_SETFOCUS: txt=log_txt(); SetWindowText(EditControl, txt); free(txt); SetFocus(EditControl); return TRUE; case WM_TIMER: update_taskbar(); return TRUE; case WM_CLOSE: set_visible(0); return TRUE; case WM_DESTROY: DestroyMenu(hmainmenu); DestroyMenu(htraymenu); ZeroMemory(&nid, sizeof(nid)); nid.cbSize=sizeof(NOTIFYICONDATA); nid.hWnd=hwnd; nid.uID=1; nid.uFlags=NIF_TIP; /* not really sure what to put here, but it works */ Shell_NotifyIcon(NIM_DELETE, &nid); /* this removes the icon */ PostQuitMessage(0); KillTimer(hwnd, 0x29a); return TRUE; case WM_COMMAND: switch(wParam) { case IDM_ABOUT: DialogBox(ghInst, "AboutBox", hwnd, (DLGPROC)about_proc); break; case IDM_LOG: set_visible(!visible); break; case IDM_CLOSE: set_visible(0); break; case IDM_EXIT: DestroyWindow(hwnd); break; case IDM_SAVEAS: save_file(hwnd); break; case IDM_SETUP: MessageBox(hwnd, "Function not implemented", options.win32_name, MB_ICONERROR); break; }; return TRUE; case UWM_SYSTRAY: switch (lParam) { case WM_RBUTTONUP: /* track a popup menu */ /* http://support.microsoft.com/support/kb/articles/Q135/7/88.asp */ GetCursorPos(&pt); SetForegroundWindow(hwnd); TrackPopupMenu(hpopup, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL); PostMessage(hwnd, WM_NULL, 0, 0); /* see above */ break; case WM_LBUTTONDBLCLK: /* switch log window visibility */ set_visible(!visible); break; } return TRUE; } return DefWindowProc(hwnd, message, wParam, lParam); }
void CMSWindowsPortableTaskBarReceiver::runMenu(int x, int y) { // do popup menu. we need a window to pass to TrackPopupMenu(). // the SetForegroundWindow() and SendMessage() calls around // TrackPopupMenu() are to get the menu to be dismissed when // another window gets activated and are just one of those // win32 weirdnesses. createWindow(); SetForegroundWindow(m_window); HMENU menu = GetSubMenu(m_menu, 0); SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE); HMENU logLevelMenu = GetSubMenu(menu, 3); CheckMenuRadioItem(logLevelMenu, 0, 6, CLOG->getFilter() - kERROR, MF_BYPOSITION); int n = TrackPopupMenu(menu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, x, y, 0, m_window, NULL); SendMessage(m_window, WM_NULL, 0, 0); // perform the requested operation switch (n) { case IDC_TASKBAR_STATUS: showStatus(); break; case IDC_TASKBAR_LOG: copyLog(); break; case IDC_TASKBAR_SHOW_LOG: ARCH->showConsole(true); break; case IDC_RELOAD_CONFIG: m_events->addEvent(CEvent(m_events->forCServerApp().reloadConfig(), m_events->getSystemTarget())); break; case IDC_FORCE_RECONNECT: m_events->addEvent(CEvent(m_events->forCServerApp().forceReconnect(), m_events->getSystemTarget())); break; case ID_SYNERGY_RESETSERVER: m_events->addEvent(CEvent(m_events->forCServerApp().resetServer(), m_events->getSystemTarget())); break; case IDC_TASKBAR_LOG_LEVEL_ERROR: CLOG->setFilter(kERROR); break; case IDC_TASKBAR_LOG_LEVEL_WARNING: CLOG->setFilter(kWARNING); break; case IDC_TASKBAR_LOG_LEVEL_NOTE: CLOG->setFilter(kNOTE); break; case IDC_TASKBAR_LOG_LEVEL_INFO: CLOG->setFilter(kINFO); break; case IDC_TASKBAR_LOG_LEVEL_DEBUG: CLOG->setFilter(kDEBUG); break; case IDC_TASKBAR_LOG_LEVEL_DEBUG1: CLOG->setFilter(kDEBUG1); break; case IDC_TASKBAR_LOG_LEVEL_DEBUG2: CLOG->setFilter(kDEBUG2); break; case IDC_TASKBAR_QUIT: quit(); break; } }
/*----------------------------------------------------------------- ---------------- when the clock is right-clicked show pop-up menu -----------------------------------------------------------------*/ void OnContextMenu(HWND hWnd, int xPos, int yPos) { BOOL g_bQMAudio; BOOL g_bQMNet; BOOL g_bQMLaunch; BOOL g_bQMExitWin; BOOL g_bQMDisplay; HMENU hPopupMenu; HMENU hMenu; int item; HBITMAP shield_bmp = NULL; g_bQMAudio = api.GetInt(L"QuickyMenu", L"AudioProperties", TRUE); g_bQMNet = api.GetInt(L"QuickyMenu", L"NetworkDrives", TRUE); g_bQMLaunch = api.GetInt(L"QuickyMenu", L"QuickyMenu", TRUE); g_bQMExitWin = api.GetInt(L"QuickyMenu", L"ExitWindows", TRUE); g_bQMDisplay = api.GetInt(L"QuickyMenu", L"DisplayProperties", TRUE); hMenu = LoadMenu(g_instance, MAKEINTRESOURCE(IDR_MENU)); hPopupMenu = GetSubMenu(hMenu, 0); if(!g_bQMAudio) DeleteMenu(hPopupMenu, IDC_SOUNDAUDIO, MF_BYCOMMAND); if(!g_bQMNet) DeleteMenu(hPopupMenu, IDC_NETWORK, MF_BYCOMMAND); if(!g_bQMLaunch) DeleteMenu(hPopupMenu, IDC_QUICKYS, MF_BYCOMMAND); if(!g_bQMExitWin) DeleteMenu(hPopupMenu, IDC_EXITWIN, MF_BYCOMMAND); if(!g_bQMDisplay) DeleteMenu(hPopupMenu, IDM_DISPLAYPROP, MF_BYCOMMAND); /// simple implementation of "Undo ..." (eg. Undo Cascade windows) if(!g_undo) DeleteMenu(hPopupMenu, IDM_FWD_UNDO, MF_BYCOMMAND); /// special menu items, only shown if SHIFT or CTRL was pressed if(!((GetAsyncKeyState(VK_SHIFT)|GetAsyncKeyState(VK_CONTROL))&0x8000)){ DeleteMenu(hPopupMenu, IDS_NONE, MF_BYCOMMAND); // seperator DeleteMenu(hPopupMenu, IDM_FWD_RUNAPP, MF_BYCOMMAND); DeleteMenu(hPopupMenu, IDM_FWD_EXITEXPLORER, MF_BYCOMMAND); } /// AlarmsTimer Menu Item y/n Goes HERE!!! UpdateAlarmMenu(hPopupMenu); UpdateTimerMenu(hPopupMenu); // Get the List of Active Timers. if(g_bQMLaunch) { wchar_t key[TNY_BUFF]; int offset = 9; wchar_t name[TNY_BUFF]; int idx; MENUITEMINFO mii = { sizeof(MENUITEMINFO) }; mii.fMask = MIIM_STRING | MIIM_ID; mii.dwTypeData=name; memcpy(key, L"MenuItem-", offset*sizeof(wchar_t)); for(idx=0; idx<12; ++idx) { offset = 9 + wsprintf(key+9, FMT("%i"), idx); if(api.GetInt(L"QuickyMenu\\MenuItems",key,0)){ memcpy(key+offset, L"-Text", 6*sizeof(wchar_t)); api.GetStr(L"QuickyMenu\\MenuItems", key, name, _countof(name), L""); mii.wID = IDM_I_MENU+idx; InsertMenuItem(hPopupMenu, IDM_SHOWCALENDER, FALSE, &mii); } } if(!HaveSetTimePermissions()) { HICON shield = GetStockIcon(SIID_SHIELD, SHGSI_SMALLICON); shield_bmp = GetBitmapFromIcon(shield, -2); DestroyIcon(shield); SetMenuItemBitmaps(hPopupMenu, IDM_SNTP_SYNC, MF_BYCOMMAND, shield_bmp, NULL); } } /// http://support.microsoft.com/kb/135788 SetForegroundWindow(hWnd); item = TrackPopupMenu(hPopupMenu, (TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD), xPos, yPos, 0, hWnd, NULL); if(item) { if(item >= IDM_I_BEGIN_) { if(item >= IDM_I_TIMER && item < (IDM_I_TIMER+1000)){ TimerMenuItemClick(hMenu, item); }else if(item >= IDM_I_ALARM && item < (IDM_I_ALARM+1000)){ AlarmEnable(item - IDM_I_ALARM, -1); }else if(item >= IDM_I_MENU && item < (IDM_I_MENU+1000)){ wchar_t key[MAX_PATH]; int offset = 9; wchar_t szQM_Target[MAX_PATH]; wchar_t szQM_Switch[MAX_PATH]; wcscpy(key, L"MenuItem-"); offset += wsprintf(key+offset, FMT("%i"), (item-IDM_I_MENU)); wcscpy(key+offset, L"-Target"); api.GetStr(L"QuickyMenu\\MenuItems", key, szQM_Target, _countof(szQM_Target), L""); wcscpy(key+offset, L"-Switches"); api.GetStr(L"QuickyMenu\\MenuItems", key, szQM_Switch, _countof(szQM_Switch), L""); api.Exec(szQM_Target, szQM_Switch, hWnd); } } else OnTClockCommand(hWnd, item); } PostMessage(hWnd, WM_NULL, 0, 0); DestroyMenu(hMenu); // Starting Over is Simpler & Recommended if(shield_bmp) DeleteBitmap(shield_bmp); }
void ProcessPageShowContextMenu(DWORD dwProcessId) { HMENU hMenu; HMENU hSubMenu; HMENU hPriorityMenu; POINT pt; SYSTEM_INFO si; HANDLE hProcess; DWORD dwProcessPriorityClass; WCHAR strDebugger[260]; DWORD dwDebuggerSize; HKEY hKey; memset(&si, 0, sizeof(SYSTEM_INFO)); GetCursorPos(&pt); GetSystemInfo(&si); hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_PROCESS_PAGE_CONTEXT)); hSubMenu = GetSubMenu(hMenu, 0); hPriorityMenu = GetSubMenu(hSubMenu, 4); hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId); dwProcessPriorityClass = GetPriorityClass(hProcess); CloseHandle(hProcess); if (si.dwNumberOfProcessors < 2) RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND); if (!DebugChannelsAreSupported()) RemoveMenu(hSubMenu, ID_PROCESS_PAGE_DEBUGCHANNELS, MF_BYCOMMAND); switch (dwProcessPriorityClass) { case REALTIME_PRIORITY_CLASS: CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND); break; case HIGH_PRIORITY_CLASS: CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND); break; case ABOVE_NORMAL_PRIORITY_CLASS: CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND); break; case NORMAL_PRIORITY_CLASS: CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND); break; case BELOW_NORMAL_PRIORITY_CLASS: CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND); break; case IDLE_PRIORITY_CLASS: CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND); break; } if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { dwDebuggerSize = 260; if (RegQueryValueExW(hKey, L"Debugger", NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS) { CharUpper(strDebugger); if (wcsstr(strDebugger, L"DRWTSN32")) EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); } else EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); RegCloseKey(hKey); } else { EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED); } TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL); DestroyMenu(hMenu); }
LRESULT CALLBACK CDateTimeCtrlEx::WndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { CDateTimeCtrlEx* pData; if (msg==WM_CREATE) { CREATESTRUCT* pCreateStruct=(CREATESTRUCT*)lParam; if (pCreateStruct->lpCreateParams==NULL) { pData=new CDateTimeCtrlEx(hWnd); if (pData==NULL) { SetHFCError(HFC_CANNOTALLOC); return FALSE; } } else { pData=(CDateTimeCtrlEx*)pCreateStruct->lpCreateParams; pData->Attach(hWnd); } ::SetWindowLongPtr(hWnd,GWLP_USERDATA,(LONG_PTR)pData); pData->CreateControls(); return FALSE; } pData=(CDateTimeCtrlEx*)::GetWindowLongPtr(hWnd,GWLP_USERDATA); if (pData==NULL) return DefWindowProc(hWnd,msg,wParam,lParam); switch (msg) { case WM_DESTROY: delete pData; ::SetWindowLongPtr(hWnd,GWLP_USERDATA,(LONG_PTR)NULL); return 0; case WM_ENABLE: ::EnableWindow(pData->m_hTimePickerWnd,(BOOL)wParam); ::EnableWindow(pData->m_hEditWnd,(BOOL)wParam); ::EnableWindow(pData->m_hSpinWnd,(BOOL)wParam); pData->Invalidate(); break; case DTM_GETSYSTEMTIME: return pData->GetExplicitDate((LPSYSTEMTIME)lParam,(DWORD)wParam); case DTM_SETSYSTEMTIME: return pData->SetExplicitDate((LPSYSTEMTIME)lParam,(DWORD)wParam); case DTM_GETRANGE: case DTM_SETRANGE: case DTM_SETFORMATA: case DTM_SETFORMATW: case DTM_SETMCCOLOR: case DTM_GETMCCOLOR: case DTM_GETMONTHCAL: case DTM_SETMCFONT: case DTM_GETMCFONT: return ::SendMessage(pData->m_hTimePickerWnd,msg,wParam,lParam); case WM_PAINT: pData->OnPaint(); break; case WM_MOUSEMOVE: if ((pData->m_dwFlags&ButtonStateMask)==Normal) { pData->m_dwFlags&=~ButtonStateMask; pData->m_dwFlags|=Hot; pData->Invalidate(); pData->SetCapture(); } else if ((pData->m_dwFlags&ButtonStateMask)==Hot) { CRect rcButtonArea; pData->GetClientRect(&rcButtonArea); if (pData->m_hTheme!=NULL && pData->m_pDrawThemeBackground!=NULL) rcButtonArea.left=rcButtonArea.right-BUTTON_WIDTHTHEME; else rcButtonArea.left=rcButtonArea.right-BUTTON_WIDTHORIG; if (!rcButtonArea.IsPtInRect(LOWORD(lParam),HIWORD(lParam))) { ReleaseCapture(); pData->m_dwFlags&=~ButtonStateMask; pData->m_dwFlags|=Normal; pData->Invalidate(); } } return 0; case WM_LBUTTONDOWN: { if ((pData->m_dwFlags&ButtonStateMask)==Hot) ReleaseCapture(); pData->m_dwFlags&=~ButtonStateMask; pData->m_dwFlags|=Pressed; pData->Invalidate(); RECT rcWindowRect; ::GetWindowRect(hWnd,&rcWindowRect); CMenu PopupMenus; PopupMenus.LoadMenu(IDR_POPUPMENU); if ((pData->m_dwFlags&ModeMask)==ModeExplicit) PopupMenus.CheckMenuItem(IDM_EXPLICITDATE,MF_CHECKED|MF_BYCOMMAND); else PopupMenus.CheckMenuItem(IDM_RELATIVEDATE,MF_CHECKED|MF_BYCOMMAND); int nCmd=TrackPopupMenu(PopupMenus.GetSubMenu(SUBMENU_DATETIMEPICKEXMENU), TPM_RIGHTALIGN|TPM_TOPALIGN|TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD, rcWindowRect.right,rcWindowRect.bottom,0,hWnd,NULL); PopupMenus.DestroyMenu(); switch (nCmd) { case IDM_EXPLICITDATE: pData->ChangeMode(FALSE); break; case IDM_RELATIVEDATE: pData->ChangeMode(TRUE); break; } if (!(pData->m_dwFlags&DontSendNotifications)) ::PostMessage(::GetParent(hWnd),WM_COMMAND,MAKEWPARAM(::GetWindowLong(hWnd,GWL_ID),DTXN_MODECHANGED),(LPARAM)hWnd); pData->m_dwFlags&=~ButtonStateMask; pData->m_dwFlags|=Normal; pData->Invalidate(); return 0; } case WM_LBUTTONUP: if ((pData->m_dwFlags&ButtonStateMask)==Pressed) { ReleaseCapture(); pData->m_dwFlags&=~ButtonStateMask; pData->m_dwFlags|=Normal; pData->Invalidate(); } return 0; case WM_SETFONT: if (pData!=NULL) { ::SendMessage(pData->m_hTimePickerWnd,WM_SETFONT,wParam,lParam); ::SendMessage(pData->m_hEditWnd,WM_SETFONT,wParam,lParam); ::SendMessage(pData->m_hSpinWnd,WM_SETFONT,wParam,lParam); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_RELATIVEDATE: switch (HIWORD(wParam)) { case EN_KILLFOCUS: pData->SetRelativeDate((int)::SendMessage(pData->m_hSpinWnd,UDM_GETPOS32,0,0), DTXF_NOSPINCHANGE|DTXF_NOMODECHANGE); break; case EN_CHANGE: if (!(pData->m_dwFlags&SpinBoxIsUpdating)) { int nVal=0; int nLen=(int)::SendMessage(pData->m_hEditWnd,WM_GETTEXTLENGTH,0,0); if (nLen>0) { if (IsUnicodeSystem()) { WCHAR* pText=new WCHAR[nLen+1]; ::SendMessageW(pData->m_hEditWnd,WM_GETTEXT,nLen+1,(LPARAM)pText); nVal=GetValueFromText(pText); delete[] pText; } else { char* pText=new char[nLen+1]; ::SendMessage(pData->m_hEditWnd,WM_GETTEXT,nLen+1,(LPARAM)pText); nVal=GetValueFromText(A2W(pText)); delete[] pText; } } ::SendMessage(pData->m_hSpinWnd,UDM_SETPOS32,0,nVal); if (!(pData->m_dwFlags&DontSendNotifications)) ::SendMessage(::GetParent(hWnd),WM_COMMAND,MAKEWPARAM(::GetWindowLong(hWnd,GWL_ID),DTXN_CHANGE),(LPARAM)hWnd); } break; } break; } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->idFrom==IDC_RELATIVEDATESPIN && ((LPNMHDR)lParam)->code==UDN_DELTAPOS) { LPNMUPDOWN pUD=(LPNMUPDOWN)lParam; int nNewPos=pUD->iPos+pUD->iDelta; if (nNewPos<0) { pUD->iDelta=-pUD->iPos; nNewPos=0; } pData->m_dwFlags|=SpinBoxIsUpdating; //::SendMessage(pData->m_hEditWnd,WM_SETTEXT,0,(LPARAM)szEmpty); pData->SetRelativeDate(nNewPos,DTXF_NOSPINCHANGE|DTXF_NOMODECHANGE); pData->m_dwFlags&=~SpinBoxIsUpdating; if (!(pData->m_dwFlags&DontSendNotifications)) ::SendMessage(::GetParent(hWnd),WM_COMMAND,MAKEWPARAM(::GetWindowLong(hWnd,GWL_ID),DTXN_CHANGE),(LPARAM)hWnd); } else if (((LPNMHDR)lParam)->idFrom==IDC_EXPLICITIDATE && ((LPNMHDR)lParam)->code==DTN_DATETIMECHANGE) { if (!(pData->m_dwFlags&DontSendNotifications)) ::SendMessage(::GetParent(hWnd),WM_COMMAND,MAKEWPARAM(::GetWindowLong(hWnd,GWL_ID),DTXN_CHANGE),(LPARAM)hWnd); } break; case DTXM_SETRELDATE: // wParam is new pos, lparam contains flags (DTXF_*) pData->SetRelativeDate((int)wParam,(DWORD)lParam); break; case DTXM_GETRELDATE: return pData->GetRelativeDate(); case DTXM_GETCLASS: return (LRESULT)pData; case DTXM_CHANGEMODE: pData->ChangeMode((BOOL)wParam); break; case DTXM_GETMODE: return pData->GetMode(); case WM_SETFOCUS: if ((pData->m_dwFlags&ModeMask)==ModeExplicit) ::SetFocus(pData->m_hTimePickerWnd); else { ::SetFocus(pData->m_hEditWnd); ::SendMessage(pData->m_hEditWnd,EM_SETSEL,0,-1); } return 0; } return DefWindowProc(hWnd,msg,wParam,lParam); }
LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: try { StartUp(hWnd); } catch (Error e) { e.output(); MessageBoxA(hWnd, e.what(), "error", MB_OK); return -1; } return 0; case WM_CLOSE: endFlag = true; WaitForSingleObject((HANDLE)hThd, INFINITE); break; case WM_DESTROY: CleanUp(); PostQuitMessage(0); return 0; case WM_DISPLAYCHANGE: DisplaySize.cx = HIWORD(lParam); DisplaySize.cy = LOWORD(lParam); break; case WM_NCHITTEST: if (!Settings.ScreenOnly || GetAsyncKeyState(VK_RBUTTON) || g_fullScr) { break; } return HTCAPTION; case WM_NCPAINT: if (Settings.ScreenOnly) { return 0; } break; case WM_NCCALCSIZE: if (Settings.ScreenOnly) { return 0; } break; case WM_ERASEBKGND: break; case WM_RBUTTONDOWN: { if (g_fullScr | (Settings.PopupMenu == 0 && Settings.PopupMenuID == 0)) { break; } POINT pt; HMENU hmenu, hSubmenu; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); if (Settings.PopupMenu != NULL) { hmenu = Settings.PopupMenu; } else { hmenu = LoadMenu((HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE), MAKEINTRESOURCE(Settings.PopupMenuID)); } hSubmenu = GetSubMenu(hmenu, Settings.PopupMenuNum); ClientToScreen(hWnd, &pt); TrackPopupMenu(hSubmenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, NULL); DestroyMenu(hmenu); } break; case WM_COMMAND: if (Settings.menuProc != NULL) { Settings.menuProc(LOWORD(wParam)); } break; } return DefWindowProc(hWnd, msg, wParam, lParam); }
static int winPopupMenu( Ihandle* h, int x, int y ) { HWND activehwnd = GetActiveWindow(); HMENU hmenu = (HMENU) handle(h); int tray_menu = 0; POINT pt; int menuId; if (!hmenu) { iupwinCreatePopupMenu(h); hmenu = (HMENU)handle(h); if (!hmenu) return IUP_ERROR; } GetCursorPos( &pt ); if (x == IUP_MOUSEPOS) x = pt.x; if (y == IUP_MOUSEPOS) y = pt.y; if (!activehwnd) { /* search for a valid handle */ Ihandle* dlg = iupDlgListFirst(); do { if (handle(dlg)) { activehwnd = handle(dlg); if (iupCheck(dlg, "TRAY")==YES) /* keep searching for a "TRAY" dialog */ break; } dlg = iupDlgListNext(); } while (dlg); } /* Necessary to avoid tray dialogs to lock popup menus (they get sticky after the 1st time) */ if (activehwnd) { Ihandle* dlg = iupwinHandleGet(activehwnd); if (dlg && iupCheck(dlg, "TRAY")==YES) { /* To display a context menu for a notification icon, the current window must be the foreground window. */ SetForegroundWindow(activehwnd); tray_menu = 1; } } /* stop processing here. messages will not go to the message loop */ menuId = TrackPopupMenu(hmenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, x, y, 0, activehwnd, NULL); if (tray_menu) { /* You must force a task switch to the application that called TrackPopupMenu at some time in the near future. This is done by posting a benign message to the window. */ PostMessage(activehwnd, WM_NULL, 0, 0); } if (menuId) { IFni cb; Ihandle* n = iupwinGetMenuIhandle(menuId); if (!n) return IUP_NOERROR; cb = (IFni) IupGetCallback(n, IUP_ACTION); assert(number(n)>0); if (cb) { int ret = cb(n, GetMenuState ((HMENU)handle(n), number(n), MF_BYCOMMAND) == MF_CHECKED); if (ret == IUP_CLOSE) IupExitLoop(); } } return IUP_NOERROR; }
// Process window messages LRESULT CALLBACK vncMenu::WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { // This is a static method, so we don't know which instantiation we're // dealing with. We use Allen Hadden's ([email protected]) suggestion // from a newsgroup to get the pseudo-this. vncMenu *_this = (vncMenu *) GetWindowLong(hwnd, GWL_USERDATA); // Beep(100,10); // vnclog.Print(LL_INTINFO, VNCLOG("iMsg 0x%x \n"),iMsg); switch (iMsg) { // Every five seconds, a timer message causes the icon to update case WM_TIMER: // *** HACK for running servicified if (vncService::RunningAsService()) { // Attempt to add the icon if it's not already there _this->AddTrayIcon(); // Trigger a check of the current user PostMessage(hwnd, WM_USERCHANGED, 0, 0); } if (nport!=0) { PostMessage(hwnd, RETRY_MESSAGE, 0, 0); } // Update the icon _this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0); break; // DEAL WITH NOTIFICATIONS FROM THE SERVER: case WM_SRV_CLIENT_AUTHENTICATED: case WM_SRV_CLIENT_DISCONNECT: // Adjust the icon accordingly _this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0); if (_this->m_server->AuthClientCount() != 0) { if (_this->m_server->RemoveWallpaperEnabled()) KillWallpaper(); } else { if (_this->m_server->RemoveWallpaperEnabled()) RestoreWallpaper(); } return 0; // STANDARD MESSAGE HANDLING case WM_CREATE: return 0; case WM_COMMAND: // User has clicked an item on the tray menu switch (LOWORD(wParam)) { case ID_DEFAULT_PROPERTIES: /* // Show the default properties dialog, unless it is already displayed vnclog.Print(LL_INTINFO, VNCLOG("show default properties requested\n")); _this->m_properties.ShowAdmin(TRUE, FALSE); _this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0);*/ break; case ID_PROPERTIES: // Show the properties dialog, unless it is already displayed vnclog.Print(LL_INTINFO, VNCLOG("show user properties requested\n")); _this->m_propertiesPoll.Show(TRUE, TRUE); _this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0); break; case ID_ABOUT: // Show the About box _this->m_about.Show(TRUE); break; case ID_CLOSE: // User selected Close from the tray menu _this->m_server->KillAuthClients(); PostMessage(hwnd, WM_CLOSE, 0, 0); break; } return 0; case WM_TRAYNOTIFY: // User has clicked on the tray icon or the menu { // Get the submenu to use as a pop-up menu HMENU submenu = GetSubMenu(_this->m_hmenu, 0); // What event are we responding to, RMB click? if (lParam==WM_RBUTTONUP) { if (submenu == NULL) { vnclog.Print(LL_INTERR, VNCLOG("no submenu available\n")); return 0; } // Make the first menu item the default (bold font) SetMenuDefaultItem(submenu, 0, TRUE); // Get the current cursor position, to display the menu at POINT mouse; GetCursorPos(&mouse); // There's a "bug" // (Microsoft calls it a feature) in Windows 95 that requires calling // SetForegroundWindow. To find out more, search for Q135788 in MSDN. // SetForegroundWindow(_this->m_nid.hWnd); // Display the menu at the desired position TrackPopupMenu(submenu, 0, mouse.x, mouse.y, 0, _this->m_nid.hWnd, NULL); return 0; } // Or was there a LMB double click? if (lParam==WM_LBUTTONDBLCLK) { // double click: execute first menu item SendMessage(_this->m_nid.hWnd, WM_COMMAND, GetMenuItemID(submenu, 0), 0); } return 0; } case WM_CLOSE: // Only accept WM_CLOSE if the logged on user has AllowShutdown set if (!_this->m_properties.AllowShutdown()) { return 0; } // tnatsni Wallpaper fix RestoreWallpaper(); break; case WM_DESTROY: // The user wants WinVNC to quit cleanly... vnclog.Print(LL_INTINFO, VNCLOG("quitting from WM_DESTROY\n")); PostQuitMessage(0); return 0; case WM_QUERYENDSESSION: vnclog.Print(LL_INTERR, VNCLOG("WM_QUERYENDSESSION\n")); break; case WM_ENDSESSION: vnclog.Print(LL_INTERR, VNCLOG("WM_ENDSESSION\n")); break; case WM_USERCHANGED: // The current user may have changed. { char newuser[UNLEN+1]; if (vncService::CurrentUser((char *) &newuser, sizeof(newuser))) { vnclog.Print(LL_INTINFO, // VNCLOG("usernames : old=\"%s\", new=\"%s\"\n"), _this->m_username, newuser); // Check whether the user name has changed! if (strcmp(newuser, _this->m_username) != 0) { vnclog.Print(LL_INTINFO, VNCLOG("user name has changed\n")); // User has changed! strcpy(_this->m_username, newuser); // Redraw the tray icon and set it's state _this->DelTrayIcon(); _this->AddTrayIcon(); _this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0); } } } return 0; default: if (iMsg == MENU_DEFAULT_PROPERTIES_SHOW) { // External request to show our Properties dialog PostMessage(hwnd, WM_COMMAND, MAKELONG(ID_DEFAULT_PROPERTIES, 0), 0); return 0; } if (iMsg == MENU_ABOUTBOX_SHOW) { // External request to show our About dialog PostMessage(hwnd, WM_COMMAND, MAKELONG(ID_ABOUT, 0), 0); return 0; } if (iMsg == MENU_SERVICEHELPER_MSG) { // External ServiceHelper message. // This message holds a process id which we can use to // impersonate a specific user. In doing so, we can load their // preferences correctly // vncService::ProcessUserHelperMessage(wParam, lParam); // Modif Jeremy C. vncService::ProcessUserHelperMessage((WPARAM)&_this->m_server->m_impersonationtoken, lParam); // - Trigger a check of the current user PostMessage(hwnd, WM_USERCHANGED, 0, 0); return 0; } if (iMsg == RETRY_MESSAGE) { connect_counter++; if (connect_counter%5==0) { // Attempt to create a new socket // Beep(1000,100); VSocket *tmpsock; tmpsock = new VSocket; if (tmpsock) { // Connect out to the specified host on the VNCviewer listen port tmpsock->Create(); if (tmpsock->Connect(szAdrName, nport)) { // Add the new client to this server if (strcmp(g_idcode,"")==NULL) g_id=false; else g_id=true; char sendID[_MAX_PATH]; strcpy(sendID,"ID:"); strcat(sendID,g_idcode); if (g_id) tmpsock->Send(sendID,250); _this->m_server->AddClient(tmpsock, TRUE, TRUE); nport=0; connected=1; _this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0); return 0; } else { delete tmpsock; connect_counter++; if (connect_counter>25) // Sleep(5000); PostMessage(hwnd, WM_CLOSE, 0, 0); } } } return 0; } if (iMsg == MENU_ADD_CLIENT_MSG) { // sf@2003 - Autoreconnect // Dirty trick to avoid to add a new MSG... no time if (lParam == 999) { _this->m_server->AutoReconnect(true); return 0; } /* // sf@2005 - FTNoUserImpersonation // Dirty trick to avoid to add a new MSG... no time if (lParam == 998) { _this->m_server->FTUserImpersonation(false); return 0; } */ // Add Client message. This message includes an IP address // of a listening client, to which we should connect. char *nameDup = 0; // sf@2003 - Values are already converted if (_this->m_server->AutoReconnect() && strlen(_this->m_server->AutoReconnectAdr()) > 0) { nport = _this->m_server->AutoReconnectPort(); strcpy(szAdrName, _this->m_server->AutoReconnectAdr()); } else { // Get the IP address stringified struct in_addr address; address.S_un.S_addr = lParam; char *name = inet_ntoa(address); if (name == 0) return 0; nameDup = strdup(name); if (nameDup == 0) return 0; strcpy(szAdrName, nameDup); // Free the duplicate name if (nameDup != 0) free(nameDup); // Get the port number nport = (unsigned short)wParam; if (nport == 0) nport = INCOMING_PORT_OFFSET; } // sf@2003 // Stores the client adr/ports the first time we try to connect // This way we can call this message again later to reconnect with the same values if (_this->m_server->AutoReconnect() && strlen(_this->m_server->AutoReconnectAdr()) == 0) { _this->m_server->AutoReconnectAdr(szAdrName); _this->m_server->AutoReconnectPort(nport); } // Attempt to create a new socket _this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0); VSocket *tmpsock; tmpsock = new VSocket; if (tmpsock) { // Connect out to the specified host on the VNCviewer listen port tmpsock->Create(); if (tmpsock->Connect(szAdrName, nport)) { // Add the new client to this server if (strcmp(g_idcode,"")==NULL) g_id=false; else g_id=true; char sendID[_MAX_PATH]; strcpy(sendID,"ID:"); strcat(sendID,g_idcode); if (g_id) tmpsock->Send(sendID,250); _this->m_server->AddClient(tmpsock, TRUE, TRUE); nport=0; connected=1; _this->FlashTrayIcon(_this->m_server->AuthClientCount() != 0); return 0; } else { delete tmpsock; // Sleep(5000); // PostMessage(hwnd, WM_CLOSE, 0, 0); } } return 0; } // Process FileTransfer asynchronous Send Packet Message if (iMsg == FileTransferSendPacketMessage) { vncClient* pClient = (vncClient*) wParam; if (_this->m_server->IsClient(pClient)) pClient->SendFileChunk(); } } // Message not recognised return DefWindowProc(hwnd, iMsg, wParam, lParam); }
INT_PTR CALLBACK HistoryDlgProc(HWND hwndDlg, UINT Message, WPARAM wparam, LPARAM lparam) { MCONTACT hContact; TCHAR sztemp[1024]; switch (Message) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); hContact = (MCONTACT)lparam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lparam); mir_sntprintf(sztemp, _T("%s: %s"), pcli->pfnGetContactDisplayName(hContact, 0), TranslateT("last seen history")); SetWindowText(hwndDlg, sztemp); Window_SetSkinIcon_IcoLib(hwndDlg, SKINICON_OTHER_MIRANDA); if (db_get_b(hContact, S_MOD, "OnlineAlert", 0)) CheckDlgButton(hwndDlg, IDC_STATUSCHANGE, BST_CHECKED); SendDlgItemMessage(hwndDlg, IDC_DETAILS, BM_SETIMAGE, IMAGE_ICON, (WPARAM)Skin_LoadIcon(SKINICON_OTHER_USERDETAILS)); SendDlgItemMessage(hwndDlg, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (WPARAM)Skin_LoadIcon(SKINICON_OTHER_DOWNARROW)); SendDlgItemMessage(hwndDlg, IDC_SENDMSG, BM_SETIMAGE, IMAGE_ICON, (WPARAM)Skin_LoadIcon(SKINICON_EVENT_MESSAGE)); //set-up tooltips SendDlgItemMessage(hwndDlg, IDC_DETAILS, BUTTONADDTOOLTIP, (WPARAM)TranslateT("View User's Details"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_USERMENU, BUTTONADDTOOLTIP, (WPARAM)TranslateT("User Menu"), BATF_TCHAR); SendDlgItemMessage(hwndDlg, IDC_SENDMSG, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Send Instant Message"), BATF_TCHAR); Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, S_MOD, "History_"); ShowWindow(hwndDlg, SW_SHOW); return TRUE; case WM_MEASUREITEM: return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lparam); case WM_DRAWITEM: return Menu_DrawItem((LPDRAWITEMSTRUCT)lparam); case WM_COMMAND: hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wparam), MPCF_CONTACTMENU), hContact)) break; switch (LOWORD(wparam)) { case IDCANCEL: SendMessage(hwndDlg, WM_CLOSE, 0, 0); break; case IDOK: if (IsDlgButtonChecked(hwndDlg, IDC_STATUSCHANGE) == BST_CHECKED) db_set_b(hContact, S_MOD, "OnlineAlert", 1); else db_set_b(hContact, S_MOD, "OnlineAlert", 0); SendMessage(hwndDlg, WM_CLOSE, 0, 0); break; case IDC_USERMENU: { RECT rc; GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); HMENU hMenu = Menu_BuildContactMenu(hContact); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); } break; case IDC_DETAILS: CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); break; case IDC_SENDMSG: CallService(MS_MSG_SENDMESSAGE, hContact, 0); break; case IDC_TEST: debug(ParseString(LPGENT("Date: %d.%m.%y(%Y) \n Date desc: %W - %w - %E - %e \n Time: %H:%M:%S (%h-%p) \n user: %n - %u \n Status: %s \n IP: %i - %r"), hContact)); break; } break; case WM_SIZE: int dx, dy; { HDWP hDwp = BeginDeferWindowPos(6); MyResizeGetOffset(GetDlgItem(hwndDlg, IDC_HISTORYLIST), LOWORD(lparam) - 15, HIWORD(lparam) - 99, &dx, &dy); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_USERMENU), dx, 0, 0, 0); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_DETAILS), dx, 0, 0, 0); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_SENDMSG), dx, 0, 0, 0); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_HISTORYLIST), 0, 0, dx, dy); hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_STATUSCHANGE), 0, dy, dx, 0); hDwp = MyHorizCenterWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDOK), LOWORD(lparam), dy, 0); EndDeferWindowPos(hDwp); } break; case WM_GETMINMAXINFO: MINMAXINFO mmi; { memcpy(&mmi, (LPMINMAXINFO)lparam, sizeof(MINMAXINFO)); /* The minimum width in points*/ mmi.ptMinTrackSize.x = 200; /* The minimum height in points*/ mmi.ptMinTrackSize.y = 190; memcpy((LPMINMAXINFO)lparam, &mmi, sizeof(MINMAXINFO)); } break; case WM_CLOSE: DestroyWindow(hwndDlg); WindowList_Remove(hWindowList, hwndDlg); break; case WM_DESTROY: Utils_SaveWindowPosition(hwndDlg, NULL, S_MOD, "History_"); DestroyIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0)); DestroyIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0)); break; } return FALSE; }
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static SERVICE_TABLE_ENTRY service_table[] = { {server_name, (LPSERVICE_MAIN_FUNCTION) ServiceMain}, {NULL, NULL} }; int service_installed; char buf[200], *service_argv[] = {__argv[0], NULL}; POINT pt; HMENU hMenu; switch (msg) { case WM_CREATE: if (__argv[1] != NULL && !strcmp(__argv[1], service_magic_argument)) { start_mongoose(1, service_argv); StartServiceCtrlDispatcher(service_table); exit(EXIT_SUCCESS); } else { start_mongoose(__argc, __argv); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_QUIT: mg_stop(ctx); Shell_NotifyIcon(NIM_DELETE, &TrayIcon); PostQuitMessage(0); break; case ID_EDIT_CONFIG: edit_config_file(); break; case ID_INSTALL_SERVICE: case ID_REMOVE_SERVICE: manage_service(LOWORD(wParam)); break; } break; case WM_USER: switch (lParam) { case WM_RBUTTONUP: case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, server_name); AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, ""); service_installed = manage_service(0); snprintf(buf, sizeof(buf), "NT service: %s installed", service_installed ? "" : "not"); AppendMenu(hMenu, MF_STRING | MF_GRAYED, ID_SEPARATOR, buf); AppendMenu(hMenu, MF_STRING | (service_installed ? MF_GRAYED : 0), ID_INSTALL_SERVICE, "Install service"); AppendMenu(hMenu, MF_STRING | (!service_installed ? MF_GRAYED : 0), ID_REMOVE_SERVICE, "Deinstall service"); AppendMenu(hMenu, MF_SEPARATOR, ID_SEPARATOR, ""); AppendMenu(hMenu, MF_STRING, ID_EDIT_CONFIG, "Edit config file"); AppendMenu(hMenu, MF_STRING, ID_QUIT, "Exit"); GetCursorPos(&pt); SetForegroundWindow(hWnd); TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hWnd, NULL); PostMessage(hWnd, WM_NULL, 0, 0); DestroyMenu(hMenu); break; } break; case WM_CLOSE: mg_stop(ctx); Shell_NotifyIcon(NIM_DELETE, &TrayIcon); PostQuitMessage(0); return 0; // We've just sent our own quit message, with proper hwnd. } return DefWindowProc(hWnd, msg, wParam, lParam); }
void TrayIcon::OnContextMenu() { HMENU hMenu, hmenuTrackPopup; POINT pt; HRESULT res; int i; Desktop * desk; //Get the "base" menu hMenu = Locale::GetInstance().LoadMenu(IDC_VIRTUALDIMENSION); if (hMenu == NULL) return; hmenuTrackPopup = GetSubMenu(hMenu, 0); //Append the list of desktops InsertMenu(hmenuTrackPopup, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); i = 0; for( desk = deskMan->GetFirstDesktop(); desk != NULL; desk = deskMan->GetNextDesktop()) { MENUITEMINFO mii; mii.cbSize = sizeof(mii); mii.fMask = MIIM_STATE | MIIM_STRING | MIIM_ID | MIIM_DATA; if (desk->IsActive()) mii.fState = MFS_CHECKED; else mii.fState = MFS_UNCHECKED; mii.dwItemData = (DWORD)desk; std::vector<TCHAR> svec( desk->GetText(), desk->GetText() + _tcslen(desk->GetText()) + 1); mii.dwTypeData = &(svec[0]); mii.cch = (UINT)_tcslen(mii.dwTypeData); mii.wID = WM_USER + i++; InsertMenuItem(hmenuTrackPopup, 0, TRUE, &mii); } //And show the menu GetCursorPos(&pt); SetForegroundWindow(m_hWnd); res = TrackPopupMenu(hmenuTrackPopup, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, m_hWnd, NULL); //Process the resulting message if (res >= WM_USER) { Desktop * desk; MENUITEMINFO mii; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA; GetMenuItemInfo(hmenuTrackPopup, res, FALSE, &mii); desk = (Desktop*)mii.dwItemData; deskMan->SwitchToDesktop(desk); InvalidateRect(m_hWnd, NULL, TRUE); } else PostMessage(m_hWnd, WM_COMMAND, res, 0); //Do not forget to destroy the menu DestroyMenu(hMenu); }
void ProjectPanel::popupMenuCmd(int cmdID) { // get selected item handle HTREEITEM hTreeItem = _treeView.getSelection(); if (!hTreeItem) return; switch (cmdID) { // // Toolbar menu buttons // case IDB_PROJECT_BTN: { POINT p = getMenuDisplayPoint(0); TrackPopupMenu(_hWorkSpaceMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL); } break; case IDB_EDIT_BTN: { POINT p = getMenuDisplayPoint(1); HMENU hMenu = NULL; NodeType nodeType = getNodeType(hTreeItem); if (nodeType == nodeType_project) hMenu = _hProjectMenu; else if (nodeType == nodeType_folder) hMenu = _hFolderMenu; else if (nodeType == nodeType_file) hMenu = _hFileMenu; if (hMenu) TrackPopupMenu(hMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL); } break; // // Toolbar menu commands // case IDM_PROJECT_NEWPROJECT : { HTREEITEM root = _treeView.getRoot(); NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); generic_string newProjectLabel = pNativeSpeaker->getAttrNameStr(PM_NEWPROJECTNAME, "ProjectManager", "NewProjectName"); HTREEITEM addedItem = _treeView.addItem(newProjectLabel.c_str(), root, INDEX_PROJECT); setWorkSpaceDirty(true); _treeView.expand(hTreeItem); TreeView_EditLabel(_treeView.getHSelf(), addedItem); } break; case IDM_PROJECT_NEWWS : { if (_isDirty) { int res = ::MessageBox(_hSelf, TEXT("The current workspace was modified. Do you want to save the current project?"), TEXT("New Workspace"), MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); if (res == IDYES) { if (!saveWorkSpace()) return; } else if (res == IDNO) { // Don't save so do nothing here } else if (res == IDCANCEL) { // User cancels action "New Workspace" so we interrupt here return; } } _treeView.removeAllItems(); newWorkSpace(); } break; case IDM_PROJECT_RENAME : TreeView_EditLabel(_treeView.getHSelf(), hTreeItem); break; case IDM_PROJECT_NEWFOLDER : { NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); generic_string newFolderLabel = pNativeSpeaker->getAttrNameStr(PM_NEWFOLDERNAME, "ProjectManager", "NewFolderName"); addFolder(hTreeItem, newFolderLabel.c_str()); setWorkSpaceDirty(true); } break; case IDM_PROJECT_MOVEDOWN : { if (_treeView.moveDown(hTreeItem)) setWorkSpaceDirty(true); } break; case IDM_PROJECT_MOVEUP : { if (_treeView.moveUp(hTreeItem)) setWorkSpaceDirty(true); } break; case IDM_PROJECT_ADDFILES : { addFiles(hTreeItem); if (getNodeType(hTreeItem) == nodeType_folder) _treeView.setItemImage(hTreeItem, INDEX_OPEN_NODE, INDEX_OPEN_NODE); } break; case IDM_PROJECT_ADDFILESRECUSIVELY : { addFilesFromDirectory(hTreeItem); if (getNodeType(hTreeItem) == nodeType_folder) _treeView.setItemImage(hTreeItem, INDEX_OPEN_NODE, INDEX_OPEN_NODE); } break; case IDM_PROJECT_OPENWS: { if (_isDirty) { int res = ::MessageBox(_hSelf, TEXT("The current workspace was modified. Do you want to save the current project?"), TEXT("Open Workspace"), MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); if (res == IDYES) { if (!saveWorkSpace()) return; } else if (res == IDNO) { // Don't save so do nothing here } else if (res == IDCANCEL) { // User cancels action "New Workspace" so we interrupt here return; } } FileDialog fDlg(_hSelf, ::GetModuleHandle(NULL)); fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); if (TCHAR *fn = fDlg.doOpenSingleFileDlg()) { if (!openWorkSpace(fn)) { ::MessageBox(_hSelf, TEXT("The workspace could not be opened.\rIt seems the file to open is not a valid project file."), TEXT("Open Workspace"), MB_OK); return; } } } break; case IDM_PROJECT_RELOADWS: { if (_isDirty) { int res = ::MessageBox(_hSelf, TEXT("The current workspace was modified. Reloading will discard all modifications.\rDo you want to continue?"), TEXT("Reload Workspace"), MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); if (res == IDYES) { // Do nothing } else if (res == IDNO) { return; } } if (::PathFileExists(_workSpaceFilePath.c_str())) { openWorkSpace(_workSpaceFilePath.c_str()); } else { ::MessageBox(_hSelf, TEXT("Cannot find the file to reload."), TEXT("Reload Workspace"), MB_OK | MB_ICONEXCLAMATION | MB_APPLMODAL); } } break; case IDM_PROJECT_SAVEWS: saveWorkSpace(); break; case IDM_PROJECT_SAVEACOPYASWS: case IDM_PROJECT_SAVEASWS: { saveWorkSpaceAs(cmdID == IDM_PROJECT_SAVEACOPYASWS); } break; case IDM_PROJECT_DELETEFOLDER : { HTREEITEM parent = _treeView.getParent(hTreeItem); if (_treeView.getChildFrom(hTreeItem) != NULL) { TCHAR str2display[MAX_PATH] = TEXT("All the sub-items will be removed.\rAre you sure you want to remove this folder from the project?"); if (::MessageBox(_hSelf, str2display, TEXT("Remove folder from project"), MB_YESNO) == IDYES) { _treeView.removeItem(hTreeItem); setWorkSpaceDirty(true); } } else { _treeView.removeItem(hTreeItem); setWorkSpaceDirty(true); } if (getNodeType(parent) == nodeType_folder) _treeView.setItemImage(parent, INDEX_CLOSED_NODE, INDEX_CLOSED_NODE); } break; case IDM_PROJECT_DELETEFILE : { HTREEITEM parent = _treeView.getParent(hTreeItem); TCHAR str2display[MAX_PATH] = TEXT("Are you sure you want to remove this file from the project?"); if (::MessageBox(_hSelf, str2display, TEXT("Remove file from project"), MB_YESNO) == IDYES) { _treeView.removeItem(hTreeItem); setWorkSpaceDirty(true); if (getNodeType(parent) == nodeType_folder) _treeView.setItemImage(parent, INDEX_CLOSED_NODE, INDEX_CLOSED_NODE); } } break; case IDM_PROJECT_MODIFYFILEPATH : { FileRelocalizerDlg fileRelocalizerDlg; fileRelocalizerDlg.init(_hInst, _hParent); TCHAR textBuffer[MAX_PATH]; TVITEM tvItem; tvItem.hItem = hTreeItem; tvItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvItem.pszText = textBuffer; tvItem.cchTextMax = MAX_PATH; SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0,(LPARAM)&tvItem); if (!tvItem.lParam) return; generic_string * fn = (generic_string *)tvItem.lParam; if (fileRelocalizerDlg.doDialog(fn->c_str()) == 0) { generic_string newValue = fileRelocalizerDlg.getFullFilePath(); if (*fn == newValue) return; *fn = newValue; TCHAR *strValueLabel = ::PathFindFileName(fn->c_str()); lstrcpy(textBuffer, strValueLabel); int iImage = ::PathFileExists(fn->c_str())?INDEX_LEAF:INDEX_LEAF_INVALID; tvItem.iImage = tvItem.iSelectedImage = iImage; SendMessage(_treeView.getHSelf(), TVM_SETITEM, 0,(LPARAM)&tvItem); setWorkSpaceDirty(true); } } break; } }
INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam) { LPNMHDR nm = (LPNMHDR)lParam; switch (nm->code) { case NM_CLICK: if (nm->idFrom == IDC_MANAGESKINS_ADDMETADATA_LINK) { std::wstring file = Rainmeter->GetSkinPath() + m_SkinFolderPath; file += L'\\'; file += m_SkinFileName; WritePrivateProfileString(L"Rainmeter", L"\r\n[Metadata]\r\nName=\r\nInformation=\r\nLicense=\r\nVersion", L"", file.c_str()); SendMessage(m_Window, WM_COMMAND, MAKEWPARAM(IDC_MANAGESKINS_EDIT_BUTTON, 0), 0); ShowWindow(nm->hwndFrom, SW_HIDE); } break; case NM_DBLCLK: if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW && !m_SkinFileName.empty()) { OnCommand(MAKEWPARAM(IDC_MANAGESKINS_LOAD_BUTTON, 0), 0); } break; case NM_RCLICK: if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW) { POINT pt; GetCursorPos(&pt); TVHITTESTINFO ht; ht.pt = pt; ScreenToClient(nm->hwndFrom, &ht.pt); if (TreeView_HitTest(nm->hwndFrom, &ht) && !(ht.flags & TVHT_NOWHERE)) { TreeView_SelectItem(nm->hwndFrom, ht.hItem); TVITEM tvi = {0}; tvi.hItem = TreeView_GetSelection(nm->hwndFrom); tvi.mask = TVIF_STATE; HMENU menu = LoadMenu(Rainmeter->GetResourceInstance(), MAKEINTRESOURCE(IDR_MANAGESKINS_MENU)); if (menu && TreeView_GetItem(nm->hwndFrom, &tvi)) { HMENU subMenu; MENUITEMINFO mii = {0}; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_STRING; if (m_SkinFileName.empty()) { // It's a folder subMenu = GetSubMenu(menu, 0); SetMenuDefaultItem(subMenu, IDM_MANAGESKINSMENU_EXPAND, MF_BYCOMMAND); if (tvi.state & TVIS_EXPANDED) { mii.dwTypeData = GetString(ID_STR_COLLAPSE); SetMenuItemInfo(subMenu, IDM_MANAGESKINSMENU_EXPAND, MF_BYCOMMAND, &mii); } } else { // It's a skin subMenu = GetSubMenu(menu, 1); SetMenuDefaultItem(subMenu, IDM_MANAGESKINSMENU_LOAD, MF_BYCOMMAND); if (m_SkinWindow) { mii.dwTypeData = GetString(ID_STR_UNLOAD); SetMenuItemInfo(subMenu, IDM_MANAGESKINSMENU_LOAD, MF_BYCOMMAND, &mii); } else { EnableMenuItem(subMenu, IDM_MANAGESKINSMENU_REFRESH, MF_BYCOMMAND | MF_GRAYED); } } // Show context menu TrackPopupMenu( subMenu, TPM_RIGHTBUTTON | TPM_LEFTALIGN, pt.x, pt.y, 0, m_Window, NULL ); DestroyMenu(menu); } } } break; case TVN_SELCHANGED: if (nm->idFrom == IDC_MANAGESKINS_SKINS_TREEVIEW) { m_SkinWindow = NULL; m_SkinFileName.clear(); m_SkinFolderPath.clear(); // Temporarily disable handling commands m_HandleCommands = false; WCHAR buffer[MAX_PATH]; // Get current selection name TVITEM tvi = {0}; tvi.hItem = TreeView_GetSelection(nm->hwndFrom); tvi.mask = TVIF_TEXT | TVIF_CHILDREN; tvi.pszText = buffer; tvi.cchTextMax = MAX_PATH; TreeView_GetItem(nm->hwndFrom, &tvi); if (tvi.cChildren == 0) { // Current selection is file m_SkinFileName = buffer; tvi.mask = TVIF_TEXT; // Loop through parents to get skin folder m_SkinFolderPath.clear(); while ((tvi.hItem = TreeView_GetParent(nm->hwndFrom, tvi.hItem)) != NULL) { TreeView_GetItem(nm->hwndFrom, &tvi); m_SkinFolderPath.insert(0, 1, L'\\'); m_SkinFolderPath.insert(0, buffer); } m_SkinFolderPath.resize(m_SkinFolderPath.length() - 1); // Get rid of trailing slash ReadSkin(); } else { DisableControls(true); } m_HandleCommands = true; } break; default: return FALSE; } return TRUE; }
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText) { HMENU hSubMenu = 0; *hMenu = GetSubMenu(g_hMenu, iIndex); TranslateMenu(*hMenu); GCMENUITEMS gcmi = { 0 }; gcmi.pszID = si->ptszID; gcmi.pszModule = si->pszModule; gcmi.pszUID = pszUID; if (iIndex == 1) { int i = GetRichTextLength(GetDlgItem(hwndDlg, IDC_LOG)); EnableMenuItem(*hMenu, ID_CLEARLOG, MF_ENABLED); EnableMenuItem(*hMenu, ID_COPYALL, MF_ENABLED); ModifyMenu(*hMenu, 4, MF_GRAYED | MF_BYPOSITION, 4, NULL); if (!i) { EnableMenuItem(*hMenu, ID_COPYALL, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(*hMenu, ID_CLEARLOG, MF_BYCOMMAND | MF_GRAYED); if (pszWordText && pszWordText[0]) ModifyMenu(*hMenu, 4, MF_ENABLED | MF_BYPOSITION, 4, NULL); } if (pszWordText && pszWordText[0]) { TCHAR szMenuText[4096]; mir_sntprintf(szMenuText, _countof(szMenuText), TranslateT("Look up '%s':"), pszWordText); ModifyMenu(*hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText); } else ModifyMenu(*hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up")); gcmi.Type = MENU_ON_LOG; } else if (iIndex == 0) { TCHAR szTemp[50]; if (pszWordText) mir_sntprintf(szTemp, TranslateT("&Message %s"), pszWordText); else mir_tstrncpy(szTemp, TranslateT("&Message"), _countof(szTemp) - 1); if (mir_tstrlen(szTemp) > 40) mir_tstrcpy(szTemp + 40, _T("...")); ModifyMenu(*hMenu, ID_MESS, MF_STRING | MF_BYCOMMAND, ID_MESS, szTemp); gcmi.Type = MENU_ON_NICKLIST; } NotifyEventHooks(pci->hBuildMenuEvent, 0, (WPARAM)&gcmi); if (gcmi.nItems > 0) AppendMenu(*hMenu, MF_SEPARATOR, 0, 0); for (int i = 0; i < gcmi.nItems; i++) { TCHAR* ptszText = TranslateTS(gcmi.Item[i].pszDesc); DWORD dwState = gcmi.Item[i].bDisabled ? MF_GRAYED : 0; if (gcmi.Item[i].uType == MENU_NEWPOPUP) { hSubMenu = CreateMenu(); AppendMenu(*hMenu, dwState | MF_POPUP, (UINT_PTR)hSubMenu, ptszText); } else if (gcmi.Item[i].uType == MENU_POPUPHMENU) AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_POPUP, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_POPUPITEM) AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_POPUPCHECK) AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_POPUPSEPARATOR) AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, MF_SEPARATOR, 0, ptszText); else if (gcmi.Item[i].uType == MENU_SEPARATOR) AppendMenu(*hMenu, MF_SEPARATOR, 0, ptszText); else if (gcmi.Item[i].uType == MENU_HMENU) AppendMenu(*hMenu, dwState | MF_POPUP, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_ITEM) AppendMenu(*hMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText); else if (gcmi.Item[i].uType == MENU_CHECK) AppendMenu(*hMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText); } return TrackPopupMenu(*hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL); }
virtual int WindowProc( void *pWnd, int uMsg, long wParam, long lParam ) { HWND hWnd = (HWND)pWnd; switch( uMsg ) { // Right button brings up the popup menu. case MYWM_NOTIFYICON: { if ( lParam == WM_RBUTTONDOWN ) { POINT cursorPos; GetCursorPos( &cursorPos ); UpdatePopupMenuState(); // Make a popup menu. SetForegroundWindow( hWnd ); TrackPopupMenu( g_hPopupMenu, TPM_RIGHTALIGN | TPM_BOTTOMALIGN, cursorPos.x, cursorPos.y, 0, hWnd, NULL ); return 0; } else if ( lParam == WM_LBUTTONDOWN ) { // Left button brings up the console. g_pConsoleWnd->SetVisible( true ); UpdatePopupMenuState(); return 0; } } break; case WM_COMMAND: { switch( wParam ) { case ID_ENABLE_WORKER: { char cPacket = VMPI_SERVICE_ENABLE; g_ConnMgr.SendPacket( -1, &cPacket, 1 ); } break; case ID_DISABLE_WORKER: { char cPacket = VMPI_SERVICE_DISABLE; g_ConnMgr.SendPacket( -1, &cPacket, 1 ); } break; case ID_KILLCURRENTJOB: { char cPacket = VMPI_KILL_PROCESS; g_ConnMgr.SendPacket( -1, &cPacket, 1 ); } break; case ID_HIGHLIGHT_ICON_WHEN_BUSY: { g_bHighlightIconWhenBusy = !g_bHighlightIconWhenBusy; SaveStateToRegistry(); UpdateAppIcon(); UpdatePopupMenuState(); } break; case ID_SCREENSAVER_MODE: { g_bScreensaverMode = !g_bScreensaverMode; char cPacket[2] = { VMPI_SERVICE_SCREENSAVER_MODE, g_bScreensaverMode }; g_ConnMgr.SendPacket( -1, cPacket, sizeof( cPacket ) ); } break; case ID_SHOW_CONSOLE_WINDOW: { g_pConsoleWnd->SetVisible( true ); UpdatePopupMenuState(); } break; case ID_HIDE_CONSOLE_WINDOW: { g_pConsoleWnd->SetVisible( false ); UpdatePopupMenuState(); } break; case ID_SET_PASSWORD: { DialogBox( g_hInstance, MAKEINTRESOURCE( IDD_SET_PASSWORD ), NULL, SetPasswordDlgProc ); } break; case ID_EXIT_SERVICE: { // Quit the service app.. char cPacket = VMPI_SERVICE_EXIT; g_ConnMgr.SendPacket( -1, &cPacket, 1 ); // Stop showing the icon. g_ShellIconMgr.Term(); // Wait for a bit for the connection to go away. DWORD startTime = GetTickCount(); while ( GetTickCount()-startTime < 2000 ) { g_ConnMgr.Update(); if ( !g_ConnMgr.IsConnected() ) break; else Sleep( 10 ); } // Quit the UI app. PostQuitMessage( 0 ); return 1; } break; } } break; } return DefWindowProc( (HWND)hWnd, uMsg, wParam, lParam ); }
LRESULT CDebugCommandsView::OnCommandListRightClicked(NMHDR* pNMHDR) { EndOpEdit(); if (g_MMU == NULL) { return 0; } NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR); int nItem = pIA->iItem; uint32_t address = m_StartAddress + nItem * 4; m_SelectedAddress = address; HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_OP_POPUP)); HMENU hPopupMenu = GetSubMenu(hMenu, 0); g_MMU->LW_VAddr(m_SelectedAddress, m_SelectedOpCode.Hex); if (m_SelectedOpInfo.IsStaticJump()) { m_FollowAddress = (m_SelectedAddress & 0xF0000000) | (m_SelectedOpCode.target * 4); } else if (m_SelectedOpInfo.IsBranch()) { m_FollowAddress = m_SelectedAddress + ((int16_t)m_SelectedOpCode.offset + 1) * 4; } else { EnableMenuItem(hPopupMenu, ID_POPUPMENU_FOLLOWJUMP, MF_DISABLED | MF_GRAYED); } if (m_SelectedOpInfo.IsLoadStoreCommand()) { m_FollowAddress = g_Reg->m_GPR[m_SelectedOpCode.base].UW[0] + (int16_t)m_SelectedOpCode.offset; } else { EnableMenuItem(hPopupMenu, ID_POPUPMENU_VIEWMEMORY, MF_DISABLED | MF_GRAYED); } if (!IsOpEdited(m_SelectedAddress)) { EnableMenuItem(hPopupMenu, ID_POPUPMENU_RESTORE, MF_DISABLED | MF_GRAYED); } if (m_EditedOps.size() == 0) { EnableMenuItem(hPopupMenu, ID_POPUPMENU_RESTOREALL, MF_DISABLED | MF_GRAYED); } if (m_SelectedOpInfo.IsNOP()) { EnableMenuItem(hPopupMenu, ID_POPUPMENU_INSERTNOP, MF_DISABLED | MF_GRAYED); } if (m_Breakpoints->Execution().size() == 0) { EnableMenuItem(hPopupMenu, ID_POPUPMENU_CLEARBPS, MF_DISABLED | MF_GRAYED); } POINT mouse; GetCursorPos(&mouse); TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN, mouse.x, mouse.y, 0, m_hWnd, NULL); DestroyMenu(hMenu); return 0; }