static LRESULT CALLBACK PanelWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: return OnCreate(hWnd, wParam, lParam); case WM_CLOSE: DestroyWindow(hWnd); return 0; case WM_SIZE: SendMessage(hStatusWnd, msg, wParam, lParam); break; case WM_DESTROY: SaveSettings(); PostQuitMessage(0); return 0; case WM_SYSCOMMAND: switch(wParam) { case ID_ABOUT: ShowAboutDlg(hWnd); break; } break; } return DefWindowProc(hWnd, msg, wParam, lParam); }
//---------------------------------------------------- void CPhoto::keyPressEvent ( QKeyEvent* e) { switch ( e->key()) { case Qt::Key_Space : SeeNextImg(); break ; case Qt::Key_Backspace: SeePrevImg(); break ; case Qt::Key_Plus: on_BtnPlus_clicked(); ; break ; case Qt::Key_Minus: on_BtnMinus_clicked(); ; break ; case Qt::Key_Delete: on_BtnDel_clicked() ; break ; case Qt::Key_Shift: m_bShiftPressed = true ; ui->ImgView->SetShiftPressed( true); break ; case Qt::Key_F1 : ShowAboutDlg() ; break ; case Qt::Key_F : SwitchFullScreen() ; break ; case Qt::Key_Escape : if ( m_bShowHelp) OnHelp(); else if ( m_bFullScreen) SwitchFullScreen(); break ; case Qt::Key_Control : m_bCtrlPressed = true ; break ; case Qt::Key_Q : if ( m_bCtrlPressed) on_BtnExit_clicked(); break ; case Qt::Key_A : OnZoomAll(); break ; case Qt::Key_O : on_BtnOpen_clicked(); break ; case Qt::Key_H : OnHelp(); break ; case Qt::Key_S : OnStartSlideShow(); break ; case Qt::Key_E : OnShowLog() ; break ; case Qt::Key_Home : if ( m_bFullScreen) GoToStartEnd( true); break ; case Qt::Key_End : if( m_bFullScreen) GoToStartEnd( false); break ; case Qt::Key_C : OnConfig(); break ; case Qt::Key_L : on_BtnLibrary_clicked(); break ; //TODO /*case Qt::Key_M : m_player->state() == Phonon::PausedState ? m_player->play() : m_player->pause() ; break ;*/ case Qt::Key_B : OnPauseSlideShow() ; break ; case Qt::Key_N : on_BtnNotes_clicked() ; break ; } }
// // WM_COMMAND message handler for main window // UINT CommandHandler(HWND hwnd, UINT nCtrlId, UINT nCtrlCode, HWND hwndFrom) { RECT rect; switch(nCtrlId) { case IDM_FILE_NEW: // reset to an empty file SetWindowFileName(hwnd, _T("Untitled"), FALSE); TextView_Clear(g_hwndTextView); g_szFileTitle[0] = '\0'; g_fFileChanged = FALSE; return 0; case IDM_FILE_OPEN: // get a filename to open if(ShowOpenFileDlg(hwnd, g_szFileName, g_szFileTitle)) { DoOpenFile(hwnd, g_szFileName, g_szFileTitle); } return 0; case IDM_FILE_SAVE: MessageBox(hwnd, _T("Not implemented"), APP_TITLE, MB_ICONINFORMATION); return 0; case IDM_FILE_SAVEAS: // does nothing yet if(ShowSaveFileDlg(hwnd, g_szFileName, g_szFileTitle)) { MessageBox(hwnd, _T("Not implemented"), APP_TITLE, MB_ICONINFORMATION); } return 0; case IDM_FILE_PRINT: DeleteDC( ShowPrintDlg(hwnd) ); return 0; case IDM_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); return 0; case IDM_EDIT_UNDO: case WM_UNDO: SendMessage(g_hwndTextView, WM_UNDO, 0, 0); return 0; case IDM_EDIT_REDO: SendMessage(g_hwndTextView, TXM_REDO, 0, 0); return 0; case IDM_EDIT_COPY: case WM_COPY: SendMessage(g_hwndTextView, WM_COPY, 0, 0); return 0; case IDM_EDIT_CUT: case WM_CUT: SendMessage(g_hwndTextView, WM_CUT, 0, 0); return 0; case IDM_EDIT_PASTE: case WM_PASTE: SendMessage(g_hwndTextView, WM_PASTE, 0, 0); return 0; case IDM_EDIT_DELETE: case WM_CLEAR: SendMessage(g_hwndTextView, WM_CLEAR, 0, 0); return 0; case IDM_EDIT_FIND: ShowFindDlg(hwnd, FIND_PAGE); return 0; case IDM_EDIT_REPLACE: ShowFindDlg(hwnd, REPLACE_PAGE); return 0; case IDM_EDIT_GOTO: ShowFindDlg(hwnd, GOTO_PAGE); return 0; case IDM_EDIT_SELECTALL: TextView_SelectAll(g_hwndTextView); return 0; case IDM_VIEW_OPTIONS: ShowOptions(hwnd); return 0; case IDM_VIEW_LINENUMBERS: g_fLineNumbers = !g_fLineNumbers; TextView_SetStyleBool(g_hwndTextView, TXS_LINENUMBERS, g_fLineNumbers); return 0; case IDM_VIEW_LONGLINES: g_fLongLines = !g_fLongLines; TextView_SetStyleBool(g_hwndTextView, TXS_LONGLINES, g_fLongLines); return 0; case IDM_VIEW_STATUSBAR: g_fShowStatusbar = !g_fShowStatusbar; ShowWindow(g_hwndStatusbar, SW_HIDE); GetClientRect(hwnd, &rect); PostMessage(hwnd, WM_SIZE, 0, MAKEWPARAM(rect.right, rect.bottom)); return 0; case IDM_VIEW_SAVEEXIT: g_fSaveOnExit = !g_fSaveOnExit; return 0; case IDM_VIEW_SAVENOW: SaveRegSettings(); return 0; case IDM_HELP_ABOUT: ShowAboutDlg(hwnd); return 0; default: return 0; } }
LRESULT CALLBACK MainWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch(uMsg) { case WM_CREATE: ZeroMemory(&m_NotifyIcon, sizeof(m_NotifyIcon)); m_NotifyIcon.cbSize = sizeof(m_NotifyIcon); m_NotifyIcon.hIcon = g_hIcon; m_NotifyIcon.hWnd = hWnd; m_NotifyIcon.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP; m_NotifyIcon.uCallbackMessage = wm_ShellNotify; m_NotifyIcon.uID = 1; _tcscpy_s(m_NotifyIcon.szTip, sizeof(m_NotifyIcon.szTip), _T("TouchFreeze (Automatic mode)")); Shell_NotifyIcon(NIM_ADD, &m_NotifyIcon); return 0; case WM_DESTROY: Shell_NotifyIcon(NIM_DELETE, &m_NotifyIcon); return 0; case WM_TIMER: if (wParam == IDT_HIDE_BALLOON) { if (GetTickCount() > g_HideBalloonTime) { g_HideBalloonTime = 0; KillTimer(hWnd, IDT_HIDE_BALLOON); HideBalllon(hWnd, 1); } } return 0; case WM_COMMAND: switch(LOWORD(wParam)) { case ID_ABOUT: ShowAboutDlg(g_hInst, hWnd); break; case ID_EXIT: PostQuitMessage(1); break; case ID_AUTOSTART_ON: SetAutorun(TRUE); break; case ID_AUTOSTART_OFF: SetAutorun(FALSE); break; case ID_DONATE: ContactOrDonate(hWnd, 1); break; } return 0; case WM_CLOSE: PostQuitMessage(1); return 0; } if (uMsg == wm_KBHookNotify) { ShowBallon(hWnd, 1); g_HideBalloonTime = GetTickCount() + g_BalloonTimeout; KillTimer(hWnd, IDT_HIDE_BALLOON); SetTimer(hWnd, IDT_HIDE_BALLOON, g_BalloonTimeout, NULL); return 0; } else if (uMsg == wm_ShellNotify) { switch(lParam) { case WM_LBUTTONUP: case WM_RBUTTONUP: ShowContextMenu(hWnd); break; } return 0; } return DefWindowProc(hWnd, uMsg, wParam, lParam); }
extern "C" LRESULT CALLBACK osd_hook(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam, BOOL *pfhandled) { LRESULT iResult = 0; static CController* pController = NULL; static UINT uVPinMAMEAdjustWindowMsg = 0; static BOOL fMoveWindow = FALSE; static int iWindowMovedX = 0; static int iWindowMovedY = 0; static int iWindowStyle = -1; switch ( message ) { // Only some inits case WM_CREATE: pController = m_pController; uVPinMAMEAdjustWindowMsg = RegisterWindowMessage(VPINMAMEADJUSTWINDOWMSG); *pfhandled = TRUE; break; // Clear var for Move window as user drags it with left mouse button! case WM_LBUTTONUP: ReleaseCapture(); fMoveWindow = FALSE; // save the new position to the registry SaveWindowPosition(wnd, pController); *pfhandled = TRUE; break; // Track vars for Move window as user drags it with left mouse button! case WM_LBUTTONDOWN: SetCapture(wnd); fMoveWindow = TRUE; RECT windowRect, clientRect; GetWindowRect(wnd, &windowRect); GetClientRect(wnd, &clientRect); ClientToScreen(wnd, (LPPOINT) &clientRect.left); ClientToScreen(wnd, (LPPOINT) &clientRect.right); iWindowMovedX = LOWORD(lparam) - (windowRect.left-clientRect.left); iWindowMovedY = HIWORD(lparam) - (windowRect.top-clientRect.top); *pfhandled = TRUE; break; // Move window as user drags it with left mouse button! case WM_MOUSEMOVE: if ( fMoveWindow ) { POINT pt = {(short) LOWORD(lparam), (short) HIWORD(lparam)}; ClientToScreen(wnd, &pt); SetWindowPos(wnd, 0, pt.x-iWindowMovedX, pt.y-iWindowMovedY, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE); } *pfhandled = TRUE; break; // Show context menu if the user uses the right mouse button case WM_RBUTTONUP: // Get the menu from the resource HMENU hMenu; hMenu = GetSubMenu(LoadMenu(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_CTXMENU)), 0); // Check the proper entry for the current display mode switch ( iWindowStyle ) { case 0: // title + border CheckMenuItem(hMenu, ID_CTRLCTXMENU_DISPLAY_TITLE, MF_BYCOMMAND|MF_CHECKED); CheckMenuItem(hMenu, ID_CTRLCTXMENU_DISPLAY_BORDER, MF_BYCOMMAND|MF_CHECKED); break; case 1: // no title CheckMenuItem(hMenu, ID_CTRLCTXMENU_DISPLAY_TITLE, MF_BYCOMMAND|MF_UNCHECKED); CheckMenuItem(hMenu, ID_CTRLCTXMENU_DISPLAY_BORDER, MF_BYCOMMAND|MF_CHECKED); break; case 2: // borderless CheckMenuItem(hMenu, ID_CTRLCTXMENU_DISPLAY_TITLE, MF_BYCOMMAND|MF_UNCHECKED); CheckMenuItem(hMenu, ID_CTRLCTXMENU_DISPLAY_BORDER, MF_BYCOMMAND|MF_UNCHECKED); break; } POINT Pos; Pos.x = LOWORD(lparam); Pos.y = HIWORD(lparam); ClientToScreen(wnd, &Pos); TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, Pos.x, Pos.y, 0, wnd, NULL); *pfhandled = TRUE; break; // If the display is locked, return the active window state // to the previous one case WM_ACTIVATE: if ( !pController->m_fDisplayLocked ) return 0; if ( wparam==WA_INACTIVE ) return 0; ::SetActiveWindow((HWND) lparam); *pfhandled = TRUE; break; // On destroy, save the current window position for future use case WM_DESTROY: SaveWindowPosition(wnd, pController); *pfhandled = TRUE; break; // handle the messages from the context menu case WM_COMMAND: switch ( LOWORD(wparam) ) { case ID_CTRLCTXMENU_GAMEOPTIONS: pController->m_pGameSettings->ShowSettingsDlg(0); *pfhandled = TRUE; break; case ID_CTRLCTXMENU_PATHES: pController->m_pControllerSettings->ShowSettingsDlg(0); *pfhandled = TRUE; break; case ID_CTRLCTXMENU_DISPLAY_TITLE: { CComVariant vValue((VARIANT_BOOL) VARIANT_TRUE); pController->m_pGameSettings->put_Value(CComBSTR("dmd_border"), vValue); vValue = (VARIANT_BOOL)((iWindowStyle == 0) ? VARIANT_FALSE : VARIANT_TRUE); pController->m_pGameSettings->put_Value(CComBSTR("dmd_title"), vValue); } *pfhandled = TRUE; break; case ID_CTRLCTXMENU_DISPLAY_BORDER: { CComVariant vValue((VARIANT_BOOL) VARIANT_FALSE); pController->m_pGameSettings->put_Value(CComBSTR("dmd_title"), vValue); vValue = (VARIANT_BOOL)((iWindowStyle == 2) ? VARIANT_TRUE : VARIANT_FALSE); pController->m_pGameSettings->put_Value(CComBSTR("dmd_border"), vValue); } *pfhandled = TRUE; break; #if 0 // not needed in new flat menu case ID_CTRLCTXMENU_DISPLAY_DMDONLY: { CComVariant vValue((VARIANT_BOOL) VARIANT_FALSE); pController->m_pGameSettings->put_Value(CComBSTR("dmd_title"), vValue); pController->m_pGameSettings->put_Value(CComBSTR("dmd_border"), vValue); } *pfhandled = TRUE; break; #endif case ID_CTRLCTXMENU_DISPLAY_RESTORESIZE: { CComVariant vValue((int) 0); pController->m_pGameSettings->put_Value(CComBSTR("dmd_width"), vValue); pController->m_pGameSettings->put_Value(CComBSTR("dmd_height"), vValue); *pfhandled = TRUE; } break; case ID_CTRLCTXMENU_INFO: ShowAboutDlg(wnd); *pfhandled = TRUE; break; case ID_CTRLCTXMENU_STOPEMULATION: PostMessage(wnd, WM_CLOSE, 0, 0); *pfhandled = TRUE; break; } } // adjust the window layout if ( message==uVPinMAMEAdjustWindowMsg ) { iWindowStyle = 0; if ( !dmd_title ) { if ( dmd_border ) iWindowStyle = 1; // Border without title else iWindowStyle = 2; // No border } SetWindowStyle(wnd, iWindowStyle); AdjustWindowPosition(wnd, pController); *pfhandled = TRUE; iResult = 1; } return iResult; }