void CADDigitView::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here if (point.x == -1 && point.y == -1) { //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(IDR_ShowMode)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); }
void CVarView::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: この位置にメッセージ ハンドラ用のコードを追加してください CPoint client_point; client_point = point; ScreenToClient(&client_point); // スクリーン座標からクライアント座標へ変換する // CG: このブロックはポップアップ メニュー コンポーネントによって追加されました { if (point.x == -1 && point.y == -1){ //キーストロークの発動 CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_VARVIEW)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } }
BOOL MyBitmapButton::ReplaceDlgCtrl(CDialog* pDialog, int buttonID) { CWnd* pWnd = pDialog->GetDlgItem(buttonID); if (pWnd == NULL) return FALSE; #if 0 DWORD styles = pWnd->GetStyle(); //DWORD stylesEx = pWnd->GetExStyle(); CString caption; CRect rect; pWnd->GetWindowText(caption); pWnd->GetWindowRect(&rect); pDialog->ScreenToClient(&rect); // pWnd->DestroyWindow(); if (Create(caption, styles, rect, pDialog, buttonID) == FALSE) { LOGI("ERROR: unable to replace dialog ctrl (buttonID=%d)", buttonID); return FALSE; } #endif /* latch on to their window handle */ Attach(pWnd->m_hWnd); return TRUE; }
BOOL CMyPropertySheet::OnHelpInfo(HELPINFO* pHelpInfo) { BOOL ret = FALSE; bool handled = false; if (GetStyle() & WS_CHILD) { // were an embedded property sheet, need to pass up // the chain to get this message processed correctly CWnd * pWnd = GetParent(); while (pWnd != NULL && pWnd->GetStyle() & WS_CHILD) { // move up the window heirarchy while // finding child windows pWnd = pWnd->GetParent(); } if (pWnd != NULL) { ret = GetParent()->GetParent()->SendMessage(WM_HELP, 0, (LPARAM)(pHelpInfo)); handled = true; } // the sheet does not have a non child parent, // some kind of problem! ASSERT(handled); } if (!handled) { ret = CPropertySheet::OnHelpInfo(pHelpInfo); } return ret; }
/* ================ DefaultOnToolHitTest ================ */ int DefaultOnToolHitTest(const toolTip_t *toolTips, const CDialog *dialog, CPoint point, TOOLINFO *pTI) { CWnd *wnd; RECT clientRect, rect; dialog->GetWindowRect(&clientRect); point.x += clientRect.left; point.y += clientRect.top; for (int i = 0; toolTips[i].tip; i++) { wnd = dialog->GetDlgItem(toolTips[i].id); if (!(wnd->GetStyle() & WS_VISIBLE)) { continue; } wnd->GetWindowRect(&rect); if (point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom) { pTI->hwnd = dialog->GetSafeHwnd(); pTI->uFlags |= TTF_IDISHWND; pTI->uFlags &= ~TTF_CENTERTIP; pTI->uId = (UINT_PTR) wnd->GetSafeHwnd(); return pTI->uId; } } return -1; }
BOOL CSAPrefsSubDlg::PreTranslateMessage(MSG* pMsg) { // Don't let CDialog process the Escape key. if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_ESCAPE)) { return TRUE; } // Don't let CDialog process the Return key, if a multi-line edit has focus if ((pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_RETURN)) { // Special case: if control with focus is an edit control with // ES_WANTRETURN style, let it handle the Return key. TCHAR szClass[10]; CWnd* pWndFocus = GetFocus(); if (((pWndFocus = GetFocus()) != NULL) && IsChild(pWndFocus) && (pWndFocus->GetStyle() & ES_WANTRETURN) && GetClassName(pWndFocus->m_hWnd, szClass, 10) && (lstrcmpi(szClass, _T("EDIT")) == 0)) { pWndFocus->SendMessage(WM_CHAR, pMsg->wParam, pMsg->lParam); return TRUE; } return FALSE; } return CDialog::PreTranslateMessage(pMsg); }
void CTimeAxis::OnRButtonUp(UINT nFlags, CPoint point) { m_bRBtnDown = FALSE; ReleaseCapture(); CSize sz = point - m_ptTimeR; if ((sz.cx < 3 && sz.cx > -3) && (sz.cy < 3 && sz.cy > -3)) // 单击 { CMenu menu; VERIFY(menu.LoadMenu(IDR_MENU_TIMEAXIS)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); ClientToScreen(&point); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } // CStatic::OnRButtonUp(nFlags, point); }
/*! * This function should be called inside the parent window @c WM_NCCALCSIZE * message handler to help eliminate flickering. * * @param bAfterDefault Flag that specifies wether the call is made before * or after the default handler * @param lpncsp Pointer to the @c NCCALCSIZE_PARAMS structure that is * passed to the message handler * @param lResult Reference to the result of the message handler. * It contains the default handler result on input and the value to * return from the window procedure on output. * * @remarks This function fixes the annoying flickering effect that is * visible when resizing the top or left edges of the window * (at least on a "left to right" Windows localized version). */ void CResizableLayout::HandleNcCalcSize(BOOL bAfterDefault, LPNCCALCSIZE_PARAMS lpncsp, LRESULT &lResult) { // prevent useless complication when size is not changing // prevent recursion when resetting the window region (see below) if ((lpncsp->lppos->flags & SWP_NOSIZE) #if (_WIN32_WINNT >= 0x0501) || m_bNoRecursion #endif ) return; if (!bAfterDefault) { // save a copy before default handler gets called m_rectClientBefore = lpncsp->rgrc[2]; } else // after default WM_NCCALCSIZE msg processing { if (lResult != 0) { // default handler already uses an advanced validation policy, give up return; } // default calculated client rect RECT &rectClientAfter = lpncsp->rgrc[0]; // intersection between old and new client area is to be preserved // set source and destination rects to this intersection RECT &rectPreserve = lpncsp->rgrc[1]; ::IntersectRect(&rectPreserve, &rectClientAfter, &m_rectClientBefore); lpncsp->rgrc[2] = rectPreserve; lResult = WVR_VALIDRECTS; // FIX: window region must be updated before the result of the // WM_NCCALCSIZE message gets processed by the system, // otherwise the old window region will clip the client // area during the preservation process. // This is especially evident on WinXP when the non-client // area is rendered with Visual Styles enabled and the // windows have a non rectangular region. // NOTE: Implementers of skin systems that modify the window region // should not rely on this fix and should handle non-client // window messages themselves, to avoid flickering #if (_WIN32_WINNT >= 0x0501) if ((real_WIN32_WINNT >= 0x0501) && (real_ThemeSettings & STAP_ALLOW_NONCLIENT)) { CWnd* pWnd = GetResizableWnd(); DWORD dwStyle = pWnd->GetStyle(); if ((dwStyle & (WS_CAPTION|WS_MAXIMIZE)) == WS_CAPTION) { m_bNoRecursion = TRUE; pWnd->SetWindowRgn(NULL, FALSE); m_bNoRecursion = FALSE; } } #endif } }
void CCJControlBar::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { // if no menu, just return. if (m_menuID == 0 ) { TRACE0("No control bar menu defined.\n"); return; } if (point.x == -1 && point.y == -1) { //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(m_menuID)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); }
bool CDlgTKManage::InitGraphList() { CWnd* pWnd = GetDlgItem(IDC_STATIC_BMP); if (NULL == pWnd) { return false; } DWORD dwStyle = pWnd->GetStyle(); CRect rc; pWnd->GetWindowRect(rc); ScreenToClient(rc); pWnd->DestroyWindow(); if (!m_gsView.Create(rc, this, IDC_STATIC_BMP, dwStyle)) { return false; } m_gsView.SetCurDatabase(m_pDb); m_gsView.ShowItemCaption(false); m_gsView.EnableDefault(false); m_gsView.EnableSel(true); m_gsView.SetLayer(1, 1); m_gsView.InsertItem(0, ACDB_MODEL_SPACE); return true; }
/*! * This function modifies a window to enable resizing functionality. * This affects the window style, size, system menu and appearance. * * @param lpCreateStruct Pointer to a @c CREATESTRUCT structure, usually * passed by the system to the window procedure in a @c WM_CREATE * or @c WM_NCCREATE * * @remarks The function is intended to be called only inside a @c WM_CREATE * or @c WM_NCCREATE message handler. */ void CResizableLayout::MakeResizable(LPCREATESTRUCT lpCreateStruct) { if (lpCreateStruct->style & WS_CHILD) return; CWnd* pWnd = GetResizableWnd(); #if (_WIN32_WINNT >= 0x0501 && !defined(RSZLIB_NO_XP_DOUBLE_BUFFER)) // enable double-buffering on supported platforms pWnd->ModifyStyleEx(0, WS_EX_COMPOSITED); #endif if (!(lpCreateStruct->style & WS_THICKFRAME)) { // set resizable style pWnd->ModifyStyle(DS_MODALFRAME, WS_THICKFRAME); // keep client area CRect rect(CPoint(lpCreateStruct->x, lpCreateStruct->y), CSize(lpCreateStruct->cx, lpCreateStruct->cy)); pWnd->SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)&rect); // adjust size to reflect new style ::AdjustWindowRectEx(&rect, pWnd->GetStyle(), ::IsMenu(pWnd->GetMenu()->GetSafeHmenu()), pWnd->GetExStyle()); pWnd->SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), SWP_NOSENDCHANGING|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREPOSITION); // update dimensions lpCreateStruct->cx = rect.Width(); lpCreateStruct->cy = rect.Height(); } }
int CResizableSheetEx::GetMinWidth() { CWnd* pWnd = NULL; CRect rectWnd, rectSheet; GetTotalClientRect(&rectSheet); int max = 0, min = rectSheet.Width(); // search for leftmost and rightmost button margins for (int i = 0; i < 7; i++) { pWnd = GetDlgItem(_propButtons[i]); // exclude not present or hidden buttons if (pWnd == NULL || !(pWnd->GetStyle() & WS_VISIBLE)) continue; // left position is relative to the right border // of the parent window (negative value) pWnd->GetWindowRect(&rectWnd); ::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rectWnd, 2); int left = rectSheet.right - rectWnd.left; int right = rectSheet.right - rectWnd.right; if (left > max) max = left; if (right < min) min = right; } // sizing border width int border = GetSystemMetrics(SM_CXSIZEFRAME); // compute total width return max + min + 2*border; }
void CLryEDBQryView::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here CMenu Menu; CMenu *pMenu; Menu.LoadMenu(IDR_POPUP_E_DATABASE); pMenu = Menu.GetSubMenu(0); if(pReportdlg.m_hWnd==NULL) { pMenu->EnableMenuItem(ID_FILE_PRINT_PREVIEW,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND); pMenu->EnableMenuItem(ID_PRINT_REPORT_SETTING,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND); pMenu->EnableMenuItem(ID_FILE_PRINT_PREVIEW,MF_DISABLED|MF_GRAYED|MF_BYCOMMAND); } CRect rect; CPoint pt; GetClientRect(&rect); pt = point; ScreenToClient(&pt); CWnd *pOwner = this; while(pOwner->GetStyle()&WS_CHILD) { pOwner = pOwner->GetParent(); } if(PtInRect(rect,pt)) pMenu->TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,pOwner); //弹出自己的右键菜单 else CXTListView::OnContextMenu(pWnd,point); //弹出默认的滚动条菜单 }
// Author & Date: Almut Branner 12 May 2003 // Purpose: Replace this static control with this window // Inputs: // rcParentWindow - the window this is going to be placed into // rcNewWindow - the window that is to be created // nControlID - the ID of the control (from the resource editor) void ReplaceWindowControl(const CWnd &rcParentWindow, CWnd &rcNewWindow, int nControlID) { CWnd *pStatic = rcParentWindow.GetDlgItem(nControlID); // For debug mode ASSERT(pStatic != 0); // For released code if (pStatic == 0) return; CRect rctWindowSize; DWORD frmstyle = pStatic->GetStyle(); DWORD frmexstyle = pStatic->GetExStyle(); pStatic->GetWindowRect(rctWindowSize); // Get window coord. rcParentWindow.ScreenToClient(rctWindowSize); // change to client coord. pStatic->DestroyWindow(); CWnd *pParent = const_cast<CWnd *>(&rcParentWindow); rcNewWindow.CreateEx(frmexstyle, NULL, NULL, frmstyle, rctWindowSize, pParent, nControlID); // Use for debugging // AllocConsole(); }
void CMyView::OnContextMenu(CWnd*, CPoint point) { // CG: This block was added by the Pop-up Menu component { if (point.x == -1 && point.y == -1) { //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_MY_VIEW)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } }
//定义钩子函数 LRESULT CALLBACK HOOKProc( int nCode, WPARAM wParam, LPARAM lParam ) { PCWPSTRUCT wc = (PCWPSTRUCT) lParam; HWND hWnd = wc->hwnd; if( hWnd ) { char ClassName[MAX_PATH] = ""; GetClassName( hWnd, ClassName, MAX_PATH ); if( strcmp( ClassName, "Button" ) == 0 ) { CWnd *pWnd = CWnd::FromHandle( hWnd ); if ( pWnd->GetStyle() & BS_RADIOBUTTON ||pWnd->GetStyle() & BS_CHECKBOX ) { return 1; } WNDPROC WndProc; WndProc = (WNDPROC) GetWindowLong( hWnd, GWL_WNDPROC ); CDrawButton *pButton=(CDrawButton*)GetWindowLong(hWnd,GWL_USERDATA); if (pButton != NULL&& pButton->m_Flag==1 ) { SetWindowLong(hWnd,GWL_USERDATA,0); SetWindowLong( hWnd, GWL_WNDPROC, (LONG)pButton->m_OldProc ); pButton->m_OldProc = NULL; delete pButton; } else if (pButton == NULL ) { if( WndProc !=DefWindowProc1 ) { pButton = new CDrawButton; pButton->m_OldProc = WndProc; SetWindowLong(hWnd,GWL_USERDATA,(long)pButton); WndProc = (WNDPROC) SetWindowLong( hWnd, GWL_WNDPROC, (LONG) DefWindowProc1); } } } } return CallNextHookEx( hWndHook, nCode, wParam, lParam ); }
BOOL CMainFrame::OnViewBar(UINT nID) { CWnd* pBar; if ((pBar = GetDlgItem(nID)) == NULL) return FALSE; // not for us // toggle visible state pBar->ShowWindow((pBar->GetStyle() & WS_VISIBLE) == 0); RecalcLayout(); return TRUE; }
void CMainFrame::OnUpdateBarMenu(CCmdUI* pCmdUI) { CWnd* pBar; if ((pBar = GetDlgItem(pCmdUI->m_nID)) == NULL) { pCmdUI->ContinueRouting(); return; // not for us } pCmdUI->SetCheck((pBar->GetStyle() & WS_VISIBLE) != 0); }
// // Generic handler for press on any BResultType button. // Records which button was pressed, then pops up the result type menu. // void CPageDisplay::OnBResultType( int which_button ) { CMenu menu; CRect button_rect; RECT screen_rect; int menu_height, menu_x, menu_y; // Record which button was pressed, for later use by OnMDisplay(). selected_button = which_button; // This prevents the menu from popping up if the user is "unchecking" the button. if ( ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->GetCheck() ) { ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )-> SetCheck( FALSE ); return; } // Create the popup menu from the resource. VERIFY(menu.LoadMenu(IDR_POPUP_DISPLAY_LIST)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); // Find the first non-child window to be the popup's parent. CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); // Get the screen coordinates of the button that was pressed. GetDlgItem( BResultType1 + selected_button )->GetWindowRect( &button_rect ); // Position the menu with its upper left corner at the lower left corner of the button. menu_x = button_rect.TopLeft().x; menu_y = button_rect.BottomRight().y; // If the menu would go off the bottom of the screen, make it go *up* from the button instead. menu_height = GetSystemMetrics(SM_CYMENUSIZE) * MDisplayNumSubmenus; if ( SystemParametersInfo( SPI_GETWORKAREA, 0, &screen_rect, 0) && (menu_y + menu_height > screen_rect.bottom) ) { menu_y = button_rect.TopLeft().y - menu_height + 1; } // Set the button's visual state to "pressed" as long as the menu is popped up. ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->SetCheck( TRUE ); // Pop up the menu. pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, menu_x, menu_y, pWndPopupOwner); // The user's selection (if any) from the pop-up menu will result in a call to one of the // CGalileoView::OnMDisplay...() functions, which will in turn call CPageDisplay::OnMDisplay(). // Set the button's visual state to "not pressed" after the menu is dismissed. ( (CButton*)GetDlgItem( BResultType1 + selected_button ) )->SetState( FALSE ); }
void CEditButton::OnClicked() { switch (m_eType) { case SEARCH_DIRECTORY: { CSHFileInfo sfi; sfi.m_strTitle = _T("Select Folder Location:"); if (sfi.BrowseForFolder(GetParent()) == IDOK) { m_pWnd->SetWindowText(sfi.m_strPath); } } break; case SEARCH_FILE: { static char BASED_CODE szFilter[] = _T("All Files (*.*)|*.*||"); CFileDialog dlg(TRUE, _T("*.*"), NULL, OFN_HIDEREADONLY, szFilter, GetParent()); if (dlg.DoModal() == IDOK) { m_pWnd->SetWindowText(dlg.GetPathName()); } } break; case SEARCH_POPUP: { ASSERT(m_nMenu!=-1); SetState(TRUE); CRect rc; GetWindowRect(&rc); CWnd* pParentWnd = m_pWnd->GetParent(); CMenu menu; VERIFY(menu.LoadMenu(m_nMenu)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, rc.right, rc.top, pParentWnd, &rc); // Return the button state to normal. SetState(FALSE); } break; } }
//------------------------------------------------------------------------// void CBCGPGlobalUtils::ForceAdjustLayout (CBCGPDockManager* pDockManager, BOOL bForce, BOOL bForceInvisible, BOOL bForceNcArea) { if (pDockManager != NULL && (CBCGPControlBar::m_bHandleMinSize || bForce)) { CWnd* pDockSite = pDockManager->GetDockSite (); if (pDockSite == NULL) { return; } if (!pDockSite->IsWindowVisible () && !bForceInvisible) { return; } if (pDockSite->IsKindOf(RUNTIME_CLASS(CBCGPFrameWnd)) || pDockSite->IsKindOf(RUNTIME_CLASS(CBCGPMDIFrameWnd))) { m_bIsAdjustLayout = (pDockSite->GetStyle() & WS_MAXIMIZE) == WS_MAXIMIZE; } CRect rectWnd; pDockSite->SetRedraw (FALSE); pDockSite->GetWindowRect (rectWnd); pDockSite->SetWindowPos (NULL, -1, -1, rectWnd.Width () + 1, rectWnd.Height () + 1, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); pDockSite->SetWindowPos (NULL, -1, -1, rectWnd.Width (), rectWnd.Height (), SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); pDockSite->SetRedraw (TRUE); if (bForceNcArea) { pDockSite->SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); } m_bIsAdjustLayout = FALSE; pDockSite->RedrawWindow (NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN); } }
void CEditorView::OnContextMenu(CWnd*, CPoint point) { // CG: This function was added by the Pop-up Menu component CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_EDITOR_VIEW)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); }
void CPagePowerManagement::EnableWindowGroup(WORD nID, BOOL bEnabled) { CWnd* wndGrp = GetDlgItem(nID); ASSERT(wndGrp); wndGrp->EnableWindow(bEnabled); wndGrp = wndGrp->GetNextWindow(); while (wndGrp) { if (wndGrp->GetStyle() & WS_GROUP) break; wndGrp->EnableWindow(bEnabled); wndGrp = wndGrp->GetNextWindow(); } }
BOOL CExtResizableDialog::PreTranslateMessage(MSG* pMsg) { UINT message = pMsg->message; WPARAM wParam = pMsg->wParam; LPARAM lParam = pMsg->lParam; if( message == WM_SYSKEYDOWN || message == WM_SYSKEYUP || message == WM_KEYDOWN //|| message == WM_KEYUP ) { BOOL bKeyUp = ( // nMsg == WM_KEYUP || message == WM_SYSKEYUP) ? TRUE : FALSE; // BOOL bCtrl = GetKeyState(VK_CONTROL) & 0x80000000; // BOOL bShift = GetKeyState(VK_SHIFT) & 0x80000000; BOOL bAlt = HIWORD(lParam) & KF_ALTDOWN; TCHAR vkTCHAR = (TCHAR)wParam; if( bAlt && vkTCHAR == VK_SPACE ) { if( !bKeyUp ) { // allow child popup track it's system menu CWnd * pWnd = CWnd::GetActiveWindow(); if( pWnd == NULL || (!(::IsWindow(pWnd->GetSafeHwnd()))) ) return TRUE; if( pWnd->GetSafeHwnd() != GetSafeHwnd() && (pWnd->GetStyle() & WS_POPUP) != 0 ) return TRUE; // track dialog system menu /// CExtToolControlBar::g_bMenuTrackingExpanded = false; /// CExtToolControlBar::g_bMenuTrackingExpanded = false; _TrackDialogSystemMenu(NULL,TRUE); } return 1; // 0 } // if( bAlt && vkTCHAR == VK_SPACE ) } return CDialog::PreTranslateMessage(pMsg); }
void CActivityView::OnContextMenu(CWnd*, CPoint point) { // CG: This block was added by the Pop-up Menu component { if (point.x == -1 && point.y == -1){ //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_ACTIVITY_VIEW)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; CMenu mainmenu; // in full-screen mode, give access to all menu items if (Frame.IsFullScreen ()) { VERIFY(mainmenu.LoadMenu(IDR_MUSHCLTYPE)); pPopup->AppendMenu (MF_SEPARATOR, 0, ""); pPopup->AppendMenu (MF_POPUP | MF_ENABLED, (UINT ) mainmenu.m_hMenu, "Main Menus"); } while (pWndPopupOwner->GetStyle() & WS_CHILD && pWndPopupOwner != pWndPopupOwner->GetParent()) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } } // end of CActivityView::OnContextMenu
void CTransparentDemoDlg::OnContextMenu(CWnd*, CPoint point) { // CG: This block was added by the Pop-up Menu component { if (point.x == -1 && point.y == -1){ //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(IDR_POUPMENU)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); /* //DWORD dwCmd = pPopup->TrackPopupMenu(TPM_RETURNCMD|TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, // pWndPopupOwner); DWORD dwCmd = TrackSkinPopupMenu( pPopup->m_hMenu , TPM_RETURNCMD|TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner->m_hWnd ); //DWORD dwCmd = TrackSkinPopupMenuEx( pPopup->m_hMenu , NULL, TPM_RETURNCMD|TPM_LEFTALIGN | TPM_RIGHTBUTTON, // point.x, point.y, pWndPopupOwner->m_hWnd , // MenuImage , 6 ,m_hMenuImage , NULL,NULL ); if( dwCmd != 0 ) { CString strR; strR.Format("%d" , dwCmd ); AfxMessageBox( strR , MB_OK ); } */ } }
BOOL CBCGPPopupDlg::OnInitDialog() { CBCGPDialog::OnInitDialog(); CWnd* pWndChild = GetWindow (GW_CHILD); while (pWndChild != NULL) { ASSERT_VALID (pWndChild); CBCGPButton* pButton = DYNAMIC_DOWNCAST(CBCGPButton, pWndChild); if (pButton != NULL) { pButton->m_bDrawFocus = FALSE; if (m_pParentPopup != NULL) { CBCGPURLLinkButton* pLink = DYNAMIC_DOWNCAST(CBCGPURLLinkButton, pWndChild); if (pLink != NULL) { pLink->SetCustomTextColors(m_pParentPopup->GetLinkTextColor(this, FALSE), m_pParentPopup->GetLinkTextColor(this, TRUE)); } } } else { TCHAR lpszClassName [MAX_CLASS_NAME + 1]; ::GetClassName (pWndChild->GetSafeHwnd (), lpszClassName, MAX_CLASS_NAME); CString strClass = lpszClassName; if (strClass == STATIC_CLASS && (pWndChild->GetStyle () & SS_ICON) == SS_ICON) { pWndChild->ShowWindow (SW_HIDE); } } pWndChild = pWndChild->GetNextWindow (); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CMlsSimpleBitmapButton::Initialize(UINT nID, CWnd* pParent) { CString csText; TRY { CWnd* pControl = pParent->GetDlgItem(nID); if (pControl != NULL) { CRect crControl; pControl->GetWindowRect(crControl); pParent->ScreenToClient(crControl); pControl->GetWindowText(csText); Create(NULL, csText, pControl->GetStyle(), crControl, pParent, nID, NULL); SetWindowPos(pControl, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); SetFont(pControl->GetFont()); pControl->DestroyWindow(); } } END_TRY }
void CMainFrame::OnContextMenu(CWnd*, CPoint point) { if(point.x == -1 && point.y == -1) { CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_MAIN_FRAME)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while(pWndPopupOwner->GetStyle() & WS_CHILD) { pWndPopupOwner = pWndPopupOwner->GetParent(); } pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); }
CCaptionRect::CalcCaptionRect(const CWnd& wnd, const int nBdrInc, const int nTitleInc) { left = right = top = bottom = 0; // make sure values are 0 first BOOL fCustThickness = FALSE; // Get size of frame around window DWORD dwStyle = wnd.GetStyle(); CSize szFrame = (dwStyle & WS_THICKFRAME) ? CSize(GetSystemMetrics(SM_CXSIZEFRAME), GetSystemMetrics(SM_CYSIZEFRAME)) : CSize(GetSystemMetrics(SM_CXFIXEDFRAME), GetSystemMetrics(SM_CYFIXEDFRAME)); if ( dwStyle & CAC_THICKFRAME) { szFrame.cx += nBdrInc / 2; szFrame.cy += nBdrInc / 2; fCustThickness = TRUE; } int cxIcon = GetSystemMetrics(SM_CXSIZE); // width of caption icon/button /*int frameX = szFrame.cx; int frameY = szFrame.cy;*/ // Compute rectangle wnd.GetWindowRect(this); // window rect in screen coords *this -= CPoint(left, top); // shift origin to (0,0) left += szFrame.cx; // frame right -= szFrame.cx; // frame top += szFrame.cy; // top = end of frame bottom = top + GetSystemMetrics(SM_CYCAPTION) // height of caption - ((fCustThickness)? 0: GetSystemMetrics(SM_CYBORDER)) // minus gray shadow border + nTitleInc; m_czFrameInset = szFrame; }