void OUGUIObject::SetMouseLButton(bool bDown) { if(bDown == m_bMouseLButton) return; m_bMouseLButton = bDown; if(m_bMouseLButton) { /** 设置控件 */ if(!IsChild(OUGUIObject::GetFocusControl())) { OUGUIObject::SetFocusControl(this); } /** 激活控件 (如拖曳) */ if(!IsChild(OUGUIObject::GetActiveControl())) { OUGUIObject::SetActiveControl(this); } OnMouseLButtonDown(); } else { if(OUGUIObject::GetActiveControl() == this) { OUGUIObject::SetActiveControl(NULL); } OnMouseLButtonUp(); } }
IGraphEdge * GetEdge(unsigned int hash) const { CComPtr<IGraphEdge> retVal = m_graph.GetEdge(hash); if (IsChild(retVal->GetSource()) || IsChild(retVal->GetTarget())) { return retVal; } return NULL; }
// Edge --- IGraphEdge * GetEdge(const CUniqueID & id) const { CComPtr<IGraphEdge> retVal = m_graph.GetEdge(id); if (IsChild(retVal->GetSource()) || IsChild(retVal->GetTarget())) { return retVal; } return NULL; }
void Container::Add( const Widget::Ptr& widget ) { if( IsChild( widget ) ) { return; } m_children.push_back( widget ); HandleAdd( widget ); // Check if HandleAdd still wants the little boy. if( IsChild( widget ) ) { widget->SetParent( shared_from_this() ); RequestResize(); } }
// // Usually called in response to a Ctrl+Tab keyboard accelerator // BOOL WINAPI DockWnd_NextWindow(HWND hwndMain) { HWND hwndFocus; HWND hwndLast = 0; DOCKSERVER *dsp; DOCKPANEL *dpp; BOOL fMainFocus = TRUE; if((dsp = GetDockServer(hwndMain)) == 0) return FALSE; hwndFocus = GetFocus(); // is focus on one of the dockwindows? //for(i = 0; i < dsp->nNumDockPanels; i++) for(dpp = dsp->PanelListHead; dpp; dpp = dpp->flink) { //DOCKPANEL *dwp = &dsp->PanelList[i]; if(hwndFocus == dpp->hwndPanel || IsChild(dpp->hwndPanel, hwndFocus)) fMainFocus = FALSE; } //for(i = 0; i < dsp->nNumDockPanels; i++) for(dpp = dsp->PanelListHead; dpp; dpp = dpp->flink) { // DOCKPANEL *dwp = &dsp->PanelList[i]; if(dpp->hwndPanel) { // is the focus set to this window? if(hwndFocus == dpp->hwndPanel || IsChild(dpp->hwndPanel, hwndFocus)) { hwndLast = dpp->hwndPanel; } // look for next window that doesn't have focus else if((hwndLast || fMainFocus) && !(dpp->dwStyle & DWS_NOSETFOCUS)) { SetFocus(dpp->hwndPanel); return TRUE; } } } // not found? go to the main window SetFocus(hwndMain); return TRUE; }
/**************************************************************************** * * * FUNCTION : FindAdviseChild() * * * * PURPOSE : Search through the child windows of hwndMDI for an info * * ctrl that has the same Item and format and is an * * ADVSTART ADVSTOP or ADVDATA transaction window. * * * * We use these to show the associated advise data. * * * * RETURNS : The transaction window handle or 0 on failure. * * * ****************************************************************************/ HWND FindAdviseChild( HWND hwndMDI, HSZ hszItem, WORD wFmt) { HWND hwnd, hwndStart; XACT *pxact; if (!IsWindow(hwndMDI)) return 0; hwnd = hwndStart = GetWindow(hwndMDI, GW_CHILD); while (hwnd && IsChild(hwndMDI, hwnd)) { pxact = (XACT *)GetWindowWord(hwnd, GWW_WUSER); if (pxact && (pxact)->wFmt == wFmt && (pxact)->hszItem == hszItem && ( ((pxact->wType & XTYP_ADVSTART) == XTYP_ADVSTART) || (pxact->wType == XTYP_ADVSTOP) || (pxact->wType == XTYP_ADVDATA) ) ) { return(hwnd); } hwnd = GetWindow(hwnd, GW_HWNDNEXT); if (hwnd == hwndStart) return 0; } return 0; }
void CNGWizard::OnPaletteChanged(CWnd* pFocusWnd) { if (!m_bmpHeader.IsEmpty() ) { CPalette* pPal = m_bmpHeader.GetPalette(); if ( (NULL != pPal) && (NULL != GetSafeHwnd()) && (this != pFocusWnd) && !IsChild(pFocusWnd) ) { CClientDC dc(this); CPalette* pOldPalette = dc.SelectPalette(pPal, TRUE); UINT nChanged = dc.RealizePalette(); dc.SelectPalette(pOldPalette, TRUE); if (0 != nChanged) { Invalidate(); } } } else { CNGWizard_BASE::OnPaletteChanged(pFocusWnd); } }
// Returns TRUE if we're at the end of the tab list static BOOL NEAR AtEndOfTabList(HWND hwndDlg) { HWND hCtl; BOOL bShift; // See whether we should check for the end of the tab list or // the shift-tab list bShift = GetKeyState(VK_SHIFT) < 0; // Get the control that currently has focus hCtl = GetFocus(); assert(IsChild(hwndDlg, hCtl)); // Get the first-level child for the control. This matters for controls // like a combo box which have child windows while (GetParent(hCtl) != hwndDlg) hCtl = GetParent(hCtl); // Look for another child window that's enabled and wants TAB keys do { hCtl = bShift ? GetPrevSibling(hCtl) : GetNextSibling(hCtl); if (hCtl == NULL) return TRUE; // no more child windows } while ((GetWindowStyle(hCtl) & (WS_DISABLED | WS_TABSTOP)) != WS_TABSTOP); return FALSE; }
bool TopWindow::Key(dword key, int count) { if(Ctrl::Key(key, count)) return true; if(IsChild()) return false; if(key == K_DOWN || key == K_RIGHT || key == K_TAB) { Ctrl *ctrl = GetFocusChildDeep(); if(ctrl && IterateFocusForward(ctrl, this)) return true; ctrl = GetFirstChild(); if(ctrl) { if(ctrl->SetWantFocus()) return true; return IterateFocusForward(ctrl, this); } } if(key == K_UP || key == K_LEFT || key == K_SHIFT_TAB) { Ctrl *ctrl = GetFocusChildDeep(); if(ctrl && IterateFocusBackward(ctrl, this)) return true; ctrl = GetLastChild(); if(ctrl) { if(ctrl->SetWantFocus()) return true; return IterateFocusBackward(ctrl, this); } } return false; }
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 palEditDlg::OnPaletteChanged(CWnd* pFocusWnd) { if (pFocusWnd == this || IsChild(pFocusWnd)) return; OnQueryNewPalette(); }
Bar::Item& MenuBar::AddSubMenu(Event<Bar&> proc) { LLOG("MenuBar::AddSubMenu " << Name()); SubMenuBase *w; MenuItemBase *q; if(IsChild()) { TopSubMenuItem *a = new TopSubMenuItem; q = a; w = a; } else { SubMenuItem *a = new SubMenuItem; q = a; w = a; } item.Add(q); pane.Add(q, Null); q->SetFont(font); q->LeftGap(Nvl(leftgap, style->leftgap)); q->TextGap(style->textgap); q->Style(style); q->MaxIconSize(IsNull(maxiconsize) ? style->maxiconsize : maxiconsize); w->SetParent(this); w->Set(proc); return *q; }
bool CChordEaseApp::HandleDlgKeyMsg(MSG* pMsg) { static const LPCSTR EditBoxCtrlKeys = "ACHVX"; // Z reserved for app undo CMainFrame *Main = theApp.GetMain(); ASSERT(Main != NULL); // main frame must exist switch (pMsg->message) { case WM_KEYDOWN: { int VKey = INT64TO32(pMsg->wParam); bool bTryMainAccels = FALSE; // assume failure if ((VKey >= VK_F1 && VKey <= VK_F24) || VKey == VK_ESCAPE) { bTryMainAccels = TRUE; // function key or escape } else { bool IsAlpha = VKey >= 'A' && VKey <= 'Z'; CEdit *pEdit = CFocusEdit::GetEdit(); if (pEdit != NULL) { // if an edit control has focus if ((IsAlpha // if (alpha key && strchr(EditBoxCtrlKeys, VKey) == NULL // and unused by edit && (GetKeyState(VK_CONTROL) & GKS_DOWN)) // and Ctrl is down) || ((VKey == VK_SPACE // or (space key, || VKey == VK_RETURN || VKey == VK_BACK) // Enter or Backspace && (GetKeyState(VK_CONTROL) & GKS_DOWN)) // and Ctrl is down) || (VKey == VK_SPACE // or (space key && (GetKeyState(VK_SHIFT) & GKS_DOWN)) // and Shift is down) || (IsAlpha // or (alpha key && pEdit->IsKindOf(RUNTIME_CLASS(CNumEdit)) // and numeric edit && (VKey > 'G' // and (key above G || !pEdit->IsKindOf(RUNTIME_CLASS(CNoteEdit))) // or not note edit) && (GetKeyState(VK_SHIFT) & GKS_DOWN))) // and Shift is down) bTryMainAccels = TRUE; // give main accelerators a try } else { // non-edit control has focus if (IsAlpha // if alpha key || VKey == VK_SPACE // or space key || (GetKeyState(VK_CONTROL) & GKS_DOWN) // or Ctrl is down || (GetKeyState(VK_SHIFT) & GKS_DOWN)) // or Shift is down bTryMainAccels = TRUE; // give main accelerators a try } } if (bTryMainAccels) { HACCEL hAccel = Main->GetAccelTable(); if (hAccel != NULL && TranslateAccelerator(Main->m_hWnd, hAccel, pMsg)) return(TRUE); // message was translated, stop dispatching } } break; case WM_SYSKEYDOWN: // if focused window isn't descendant of main frame (e.g. floating bar's controls // are descendants of miniframe) main frame must steal focus else main menus fail if (!IsChild(Main->m_hWnd, GetFocus())) { // avoid stealing focus needlessly if (GetKeyState(VK_SHIFT) & GKS_DOWN) // if context menu return(FALSE); // keep dispatching (false alarm) Main->SetFocus(); // main frame must have focus to display menus Main->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam); // enter menu mode return(TRUE); // message was translated, stop dispatching } break; } return(FALSE); // continue dispatching }
HWND WINAPI GetNextDlgGroupItem(HWND hWndDlg, HWND hWndCtrl, BOOL fPrevious) { if (!IsChild(hWndDlg,hWndCtrl)) return (HWND)0; return GetWindow(hWndCtrl,(fPrevious)?GW_HWNDPREVGROUP:GW_HWNDNEXTGROUP); }
vector<LocalStmtPair> FakeDirectiveHandler::GenerateWritePairs(Stmt * Base, SwitchStmt * Parent, Stmt * Top) { vector<LocalStmtPair> Pairs; LocalStmtPair Pair; // Cond if (IsChild(Base, Parent->getCond())) { Pair.insertAfter = false; Pair.stmt = Top; Pairs.push_back(Pair); // Body } else { Pair.insertAfter = false; Pair.stmt = Base; Pairs.push_back(Pair); } return Pairs; }
bool FakeDirectiveHandler::VisitCompoundStmt(CompoundStmt *S) { if (WaitingHeader) { CompilerInstance &CI = FullDirectives->GetCI(S->getLocStart()); if (IsChild(S, WaitingHeader)) { return true; } FullDirectives->Push(WaitingDirective, WaitingHeader, S, CI); WaitingDirective = NULL; WaitingHeader = NULL; return true; } else { PragmaDirectiveMap::iterator it; it = Directives->find(S->getLocStart().getRawEncoding()); if (it != Directives->end()) { WaitingHeader = S; WaitingDirective = it->second; } return true; } }
bool CWindowManager::CoreHandleEvent(CWidget *emitter, int event) { if (CGroup::CoreHandleEvent(emitter, event)) return true; if (event == EVENT_REQQUEUEDDRAW) { CWidget *focwidget = GetFocusedWidget(); if (focwidget) { if ((focwidget != emitter) && !IsChild(emitter, focwidget)) focwidget->RequestQueuedDraw(); } return true; } else if (event == EVENT_REQUPDATE) { if (IsDirectChild(emitter, this)) { m_WidgetQueue.push_back(emitter); UpdateLayout(); PushEvent(EVENT_REQUPDATE); return true; } } return false; }
bool MenuBar::HotKey(dword key) { if(Ctrl::HotKey(key)) return true; if(IsChild()) { if((key == (K_ALT_KEY|K_KEYUP) || key == K_F10) && (submenu || HasFocusDeep())) { LLOG("CloseMenu()"); CloseMenu(); if(restorefocus) restorefocus->SetFocus(); s_doaltkey = false; return true; } if(key == K_ALT_KEY) { LLOG("K_ALT_KEY"); s_doaltkey = true; return true; } if((key == K_F10 || key == (K_ALT_KEY|K_KEYUP) && s_doaltkey) && !submenu && !HasFocusDeep() && GetTopWindow() && GetTopWindow()->IsForeground()) { LLOG("Open menu by F10 or ALT-UP"); SetupRestoreFocus(); for(Ctrl *q = pane.GetFirstChild(); q; q = q->GetNext()) if(q->SetFocus()) return true; } } LLOG("MenuBar::HotKey"); return (key == K_LEFT || key == K_RIGHT) && parentmenu ? parentmenu->Key(key, 1) : false; }
void BarCtrl::SyncBar() { if(IsChild() && InFrame()) UpdateParentLayout(); else Layout(); }
///////////////////////////////////////////////////////////////////////////// // CControlTreeDate message handlers // --- void CControlTreeDate::OnKillFocus( CWnd* pNewWnd ) { CDateTimeCtrl::OnKillFocus(pNewWnd); if ( !pNewWnd || !IsChild(pNewWnd) ) { CMonthCalCtrl *pMonthCtrl = GetMonthCalCtrl(); if ( !pMonthCtrl || pMonthCtrl->GetSafeHwnd() != pNewWnd->GetSafeHwnd() ) { CString str; GetWindowText( str ); // Send Notification to parent of ListView ctrl TV_DISPINFO dispinfo; dispinfo.hdr.hwndFrom = GetParent()->GetSafeHwnd(); dispinfo.hdr.idFrom = GetDlgCtrlID(); dispinfo.hdr.code = TVN_ENDLABELEDIT; dispinfo.item.mask = TVIF_TEXT; dispinfo.item.hItem = m_hItem; dispinfo.item.pszText = m_bESC ? NULL : LPTSTR((LPCTSTR)str); dispinfo.item.cchTextMax = str.GetLength(); GetParent()->GetParent()->SendMessage( WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo ); PostMessage( WM_CLOSE ); } } }
BOOL CMiniPieFrame::PreTranslateMessage(MSG* pMsg) { if(CFrameWindowImpl<CMiniPieFrame>::PreTranslateMessage(pMsg)) return TRUE; if((pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) && (pMsg->message < WM_MOUSEFIRST || pMsg->message > WM_MOUSELAST)) return FALSE; if (m_bFullScreen && pMsg->message == WM_KEYUP && (pMsg->wParam == VK_F1 || pMsg->wParam == VK_F2)) SetFullScreen(false); HWND hWndCtl = ::GetFocus(); if(IsChild(hWndCtl)) { // find a direct child of the dialog from the window that has focus while(::GetParent(hWndCtl) != m_hWnd) hWndCtl = ::GetParent(hWndCtl); // give control a chance to translate this message if(::SendMessage(hWndCtl, WM_FORWARDMSG, 0, (LPARAM)pMsg) != 0) return TRUE; } return FALSE; }
void CPatchPageDlg::OnPaint() { if (theApp.GetMain()->IsMidiLearn()) { // if learning MIDI assignments CPaintDC dc(this); // device context for painting CWnd *pFocusWnd = GetFocus(); // if focus window is one of our controls if (pFocusWnd != NULL && IsChild(pFocusWnd)) { int iPart; // find MIDI target corresponding to control, if any int iTarget = theApp.GetMain()->GetCtrlMidiTarget(pFocusWnd, iPart); if (iTarget < 0) { // if target not found int nID = pFocusWnd->GetDlgCtrlID(); if (nID == IDC_PART_IN_PORT || nID == IDC_PART_IN_CHAN) iTarget = INT_MAX; // input port/channel are special targets } if (iTarget >= 0) { // if control mapped to MIDI target COLORREF cSel = RGB(0, 255, 0); CRect rSel; GetSelectionRect(pFocusWnd, rSel); dc.FillSolidRect(rSel, cSel); // highlight control } } } else { // not learning MIDI assignments Default(); } }
BOOL CBCGPPopupDlg::HasFocus () const { if (GetSafeHwnd () == NULL) { return FALSE; } if (m_bMenuIsActive) { return TRUE; } CWnd* pWndMain = AfxGetMainWnd (); if (pWndMain->GetSafeHwnd () == NULL) { return FALSE; } if (pWndMain->IsIconic () || !pWndMain->IsWindowVisible() || pWndMain != GetForegroundWindow ()) { return FALSE; } CWnd* pFocus = GetFocus(); BOOL bActive = (pFocus->GetSafeHwnd () != NULL && (IsChild (pFocus) || pFocus->GetSafeHwnd () == GetSafeHwnd ())); return bActive; }
/*************************************************** OnGetDlgCode The Ultimate Grid handles this event to ensure proper behavior when grid is placed on a dialog. Params: <none> Returns: Please see MSDN for complete list of valid return values. *****************************************************/ UINT CUGGrid::OnGetDlgCode() { if(IsChild(GetFocus())) return DLGC_WANTALLKEYS|DLGC_WANTARROWS; else return CWnd::OnGetDlgCode() | DLGC_WANTARROWS | DLGC_WANTALLKEYS; }
// GetMsgProc - monitors the message stream for mouse messages intended // for a control window in the dialog box. // Returns a message-dependent value. // nCode - hook code. // wParam - message flag (not used). // lParam - address of an MSG structure. LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam) { MSG *lpmsg; lpmsg = (MSG *) lParam; if (nCode < 0 || !(IsChild(hWndWorkspace, lpmsg->hwnd))) return (CallNextHookEx(g_hhk, nCode, wParam, lParam)); switch (lpmsg->message) { case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: if (gdi_main->getToolTip() != NULL) { MSG msg; msg.lParam = lpmsg->lParam; msg.wParam = lpmsg->wParam; msg.message = lpmsg->message; msg.hwnd = lpmsg->hwnd; SendMessage(gdi_main->getToolTip(), TTM_RELAYEVENT, 0, (LPARAM) (LPMSG) &msg); } break; default: break; } return (CallNextHookEx(g_hhk, nCode, wParam, lParam)); }
BOOL CXTPPropertyGridInplaceMonthCal::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) { if (message == WM_KILLFOCUS) { CWnd* pWnd = CWnd::FromHandle((HWND)wParam); if (pWnd && IsChild(pWnd)) { return CWnd::OnWndMsg(message, wParam, lParam, pResult); } OnCancel(); return TRUE; } if (message == WM_KEYDOWN && wParam == VK_ESCAPE) { OnCancel(); return TRUE; } if (message == WM_KEYDOWN && wParam == VK_RETURN) { OnAccept(); return TRUE; } return CWnd::OnWndMsg(message, wParam, lParam, pResult); }
DLL_EXPORT LRESULT CALLBACK fhook(int code, WPARAM wp, LPARAM lp) { if(code < 0 || lp == 0) return CallNextHookEx(0, code, wp, lp); PCWPSTRUCT cwp = (PCWPSTRUCT)lp; HWND hwnd = cwp->hwnd; switch(cwp->message) { // case WM_WINDOWPOSCHANGING: case WM_ENTERSIZEMOVE: if(IsZoomed(hwnd) || IsChild(hwnd)) break; subclass_install(hwnd); break; case WM_NCDESTROY: case WM_EXITSIZEMOVE: subclass_uninstall(hwnd); break; } if(cwp->message == WMU_SNAPIT_UNINSTALL) { _log_("fhook | WMU_SNAPIT_UNINSTALL: thread = %d, hwnd = %08X", GetCurrentThreadId(), hwnd); subclass_uninstall(hwnd); } return CallNextHookEx(0, code, wp, lp); } // fhook
void MenuBar::LeftDown(Point, dword) { if(IsChild() && HasFocusDeep()) { if(restorefocus) restorefocus->SetFocus(); } WhenLeftClick(); }
void CUIWindow::AttachChild(CUIWindow* pChild) { if(!pChild) return; R_ASSERT( !IsChild(pChild) ); pChild->SetParent(this); m_ChildWndList.push_back(pChild); }
IGraphVertex * GetVertex(unsigned int hash) const { CComPtr<IGraphVertex> retVal = m_graph.GetVertex(hash); if (IsChild(retVal)) { return retVal; } return NULL; }