void MfcViewAdapter::redraw(bool) { if (_wnd->GetSafeHwnd()) { _coreView->submitDynamicShapes(this); _wnd->InvalidateRect(NULL, FALSE); } }
void CSkinListBox::OnRButtonUp(UINT nFlags, CPoint point) { CRect rcItem(0,0,0,0); SetSel(-1,FALSE); for (int i =0; i<GetCount(); i++) { GetItemRect(i, &rcItem); if(rcItem.PtInRect(point)) { if( IsSingleSel() ) SetCurSel(i); else SetSel(i); break; } } CWnd *pWnd = GetParent(); if ( (pWnd == NULL) && (pWnd->GetSafeHwnd() != NULL) ) return; pWnd->PostMessage(WM_COMMAND,GetDlgCtrlID(),0); __super::OnRButtonUp(nFlags, point); }
void CEditViewDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); if (GetSafeHwnd() == NULL) { return; } CRect rect, crect; GetClientRect(rect); CWnd *wnd = GetDlgItem(IDC_BUTTON_OPEN); if (wnd == NULL || (wnd && wnd->GetSafeHwnd() == NULL)) { return; } wnd->GetWindowRect(crect); wnd->SetWindowPos(NULL, 4, 4, crect.Width(), crect.Height(), SWP_SHOWWINDOW); wnd = GetDlgItem(IDC_BUTTON_SAVE); int left = 8 + crect.Width(); wnd->SetWindowPos(NULL, left, 4, crect.Width(), crect.Height(), SWP_SHOWWINDOW); wnd = GetDlgItem(IDOK); wnd->SetWindowPos(NULL, rect.Width() - crect.Width() - 4, 4, crect.Width(), crect.Height(), SWP_SHOWWINDOW); editInfo.SetWindowPos(NULL, 4, 8 + crect.Height(), rect.Width() - 8, rect.Height() - crect.Height() * 2 - 16, SWP_SHOWWINDOW); wnd = GetDlgItem(IDC_BUTTON_GOTO); wnd->SetWindowPos(NULL, 4, rect.Height() - 4 - crect.Height(), crect.Width(), crect.Height(), SWP_SHOWWINDOW); wnd = GetDlgItem(IDC_EDIT_GOTO); wnd->SetWindowPos(NULL, 8 + crect.Width(), rect.Height() - 3 - crect.Height(), crect.Width() + 8, crect.Height() - 3, SWP_SHOWWINDOW); wnd = GetDlgItem(IDC_STATIC_LINE); wnd->SetWindowPos(NULL, 30 + crect.Width() * 2, rect.Height() - crect.Height(), crect.Width() * 2, crect.Height(), SWP_SHOWWINDOW); wnd = GetDlgItem(IDC_EDIT_LINE); wnd->SetWindowPos(NULL, 40 + crect.Width() * 3, rect.Height() - crect.Height(), crect.Width() + 8, crect.Height(), SWP_SHOWWINDOW); }
void CWebCtrl::EnterMenu(POINT* pPoint) { if ( m_pThis != NULL ) { SetWindowLongPtr( m_pThis->m_hWndThis, GWLP_WNDPROC, (LONG_PTR)m_pThis->m_pWndProc ); m_pThis = NULL; } if ( pPoint == NULL || m_pMenu == NULL ) return; CPoint ptScreen( *pPoint ); ptScreen.Offset( 2, 2 ); CWnd* pChild = this; for ( ; ; ) { CPoint ptClient( ptScreen ); pChild->ScreenToClient( &ptClient ); CWnd* pNext = pChild->ChildWindowFromPoint( ptClient, CWP_ALL ); if ( pNext == NULL || pNext == pChild ) break; pChild = pNext; } TCHAR szClass[128]; GetClassName( *pChild, szClass, 128 ); if ( _tcsistr( szClass, _T("Internet Explorer") ) == NULL ) return; m_pThis = this; m_hWndThis = pChild->GetSafeHwnd(); m_pWndProc = (WNDPROC)(LONG_PTR)GetWindowLongPtr( m_hWndThis, GWLP_WNDPROC ); SetWindowLongPtr( m_hWndThis, GWLP_WNDPROC, (LONG_PTR)&WebWndProc ); }
void CInPlaceList::EndEdit() { CString str; GetWindowText(str); // Send Notification to parent GV_DISPINFO dispinfo; dispinfo.hdr.hwndFrom = GetSafeHwnd(); dispinfo.hdr.idFrom = GetDlgCtrlID(); dispinfo.hdr.code = GVN_ENDLABELEDIT; dispinfo.item.mask = LVIF_TEXT|LVIF_PARAM; dispinfo.item.row = m_nRow; dispinfo.item.col = m_nCol; dispinfo.item.szText = str; dispinfo.item.lParam = (LPARAM) m_nLastChar; CWnd* pOwner = GetOwner(); if (IsWindow(pOwner->GetSafeHwnd())) pOwner->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo ); // Close this window (PostNcDestroy will delete this) PostMessage(WM_CLOSE, 0, 0); }
/////////////////////////////////////////////////////////////////////////////// // OnEvent // Send message to parent window to indicate connection status void CSocketManager::OnEvent(UINT uEvent, LPVOID lpvData) { if (NULL == m_pMsgCtrl) return; CWnd* pParent = m_pMsgCtrl->GetParent(); if (!::IsWindow( pParent->GetSafeHwnd())) return; switch( uEvent ) { case EVT_CONSUCCESS: //AppendMessage( _T("Connection Established\r\n") ); break; case EVT_CONFAILURE: //AppendMessage( _T("Connection Failed\r\n") ); break; case EVT_CONDROP: //AppendMessage( _T("Connection Abandonned\r\n") ); break; case EVT_ZEROLENGTH: //AppendMessage( _T("Zero Length Message\r\n") ); break; default: TRACE("Unknown Socket event\n"); break; } pParent->PostMessage( WM_UPDATE_CONNECTION, uEvent, (LPARAM) this); }
void CCoolMenuBarCtrl::UpdateWindowMenu(CMenu* pMenu) { for ( UINT nItem = 0 ; nItem < pMenu->GetMenuItemCount() ; nItem++ ) { UINT nID = pMenu->GetMenuItemID( nItem ); if ( nID >= AFX_IDM_FIRST_MDICHILD ) { for ( UINT nRemove = nItem ; nRemove < pMenu->GetMenuItemCount() ; ) pMenu->RemoveMenu( nItem, MF_BYPOSITION ); pMenu->RemoveMenu( nItem - 1, MF_BYPOSITION ); break; } } CMDIFrameWnd* pFrame = (CMDIFrameWnd*)AfxGetMainWnd(); if ( ! pFrame->IsKindOf( RUNTIME_CLASS(CMDIFrameWnd) ) ) return; for ( CWnd* pClient = pFrame->GetWindow( GW_CHILD ) ; pClient ; pClient = pClient->GetNextWindow() ) { TCHAR szClass[64]; GetClassName( pClient->GetSafeHwnd(), szClass, 64 ); if ( _tcsicmp( szClass, _T("MDIClient") ) == 0 ) break; } if ( pClient == NULL ) return; CMDIChildWnd* pActive = pFrame->MDIGetActive(); BOOL bSeparator = TRUE; for ( UINT nIndex = 1, nID = AFX_IDM_FIRST_MDICHILD ; nIndex <= 10 ; nIndex++, nID++ ) { CWnd* pWnd = pClient->GetDlgItem( nID ); if ( ! pWnd ) break; #ifdef _SHAREAZA CChildWnd* pChildWnd = (CChildWnd*)pWnd; if ( pChildWnd->m_bTabMode ) { nIndex--; continue; } #endif if ( bSeparator ) { pMenu->AppendMenu( MF_SEPARATOR, ID_SEPARATOR ); bSeparator = FALSE; } CString strMenu, strWindow; pWnd->GetWindowText( strWindow ); strMenu.Format( _T("&%i %s"), nIndex, (LPCTSTR)strWindow ); pMenu->AppendMenu( MF_STRING | ( pWnd == pActive ? MF_CHECKED : 0 ), nID, strMenu ); } }
LRESULT CXTPTaskDialogFrame::OnDialogEnableButton(WPARAM wParam, LPARAM lParam) { CWnd* pWnd = DYNAMIC_DOWNCAST(CButton, GetDlgItem((UINT)wParam)); if (!pWnd) return FALSE; if (!lParam && (::GetFocus() == pWnd->GetSafeHwnd())) { CWnd* pWndNext = GetNextDlgTabItem(pWnd); PostMessage(WM_NEXTDLGCTL, (WPARAM)pWndNext->GetSafeHwnd(), TRUE); } pWnd->EnableWindow(lParam != 0); return TRUE; }
CLog& CLog::Instance() { CWinApp *pApp = AfxGetApp(); CWnd *pMainWnd = pApp->GetMainWnd(); static CLog obj(pMainWnd->GetSafeHwnd()); return obj; }
void CConfigRecord::SetEditText(UINT nID, CString strText) { CWnd *pWnd = GetDlgItem(nID); if (pWnd->GetSafeHwnd()) { pWnd->SetWindowText(strText); } }
void CKSInputDialog::SetDialogPosition(void) { CPaintDC dc(this); // device context for painting // 设置字体 LOGFONT lf; memset(&lf,0,sizeof lf); lf.lfCharSet = GB2312_CHARSET; strcpy(lf.lfFaceName,m_fontName.GetBuffer(1)); lf.lfHeight = m_fontSize; lf.lfWeight = FW_BOLD; CFont font; CFont *pOldFont; // 添加老的字体对象 font.CreateFontIndirect(&lf); // dc.SelectObject(font); // 隐掉 pOldFont = dc.SelectObject(&font); // 选入新的字体资源 ////////////////////////////////////////////////////////////////////////// // 取得字体属性 //TEXTMETRIC tm; //memset(&tm,0,sizeof tm); //dc.GetTextMetrics(&tm); CSize fs = dc.GetTextExtent(m_prompt); int textWidth = fs.cx;//tm.tmAveCharWidth * m_prompt.GetLength(); ////////////////////////////////////////////////////////////////////////// // 计算窗体宽度 RECT edtRect; m_edtInput.GetWindowRect(&edtRect); int edtWidth = edtRect.right - edtRect.left; int cx = (textWidth < edtWidth ) ? edtWidth : textWidth; cx += 40; CWnd * desktop = CWnd::GetDesktopWindow(); if(::IsWindow(desktop->GetSafeHwnd())) { // CRect desktopRect; desktop->GetWindowRect(desktopRect); RECT clientRect; this->GetWindowRect(&clientRect); if(desktopRect.Width() <= cx) { cx = desktopRect.Width() - 80; } int x = (desktopRect.right - cx) / 2; int y = (desktopRect.bottom - clientRect.bottom) / 2; int cy = (desktopRect.bottom - clientRect.top); this->SetWindowPos(&CWnd::wndTopMost,x,y,cx,cy,SWP_NOREDRAW); RECT edtRect; m_edtInput.GetWindowRect(&edtRect); ScreenToClient(&edtRect); x = (cx - textWidth) / 2; y = GetTextLineHeight(fs.cy,cx,fs.cx) + 5; m_edtInput.MoveWindow(x,y+20,textWidth ,edtRect.bottom-edtRect.top + 10,TRUE); } dc.SelectObject(pOldFont); // 收回老的字体资源 font.DeleteObject(); // 字体资源本身要回收 }
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 CXTPSyntaxEditColorComboBox::NotifyOwner(UINT nCode) { CWnd* pWndOwner = CWnd::GetOwner(); if (::IsWindow(pWndOwner->GetSafeHwnd())) { pWndOwner->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), nCode), (LPARAM)m_hWnd); } }
void CXTPControlCustom::SetRect(CRect rcControl) { if (m_rcControl == rcControl && !(m_hwndControl && ::GetParent(m_hwndControl) != m_pParent->GetSafeHwnd())) return; m_rcControl = rcControl; CWnd* pControlWnd = CWnd::FromHandle(m_hwndControl); if (pControlWnd && pControlWnd->GetSafeHwnd() && ::IsWindow(pControlWnd->GetSafeHwnd())) { pControlWnd->SetParent(m_pParent); pControlWnd->ModifyStyle(WS_POPUP, WS_CHILD); rcControl.DeflateRect(m_rcBorders); pControlWnd->MoveWindow(rcControl); ShowHideChildControl(); } }
afx_msg LRESULT CHgzListCtrl::OnEnChange(WPARAM wParam, LPARAM lParam) { CWnd *parent = GetParent(); if (parent) { ::PostMessage(parent->GetSafeHwnd(), EN_CHANGE, wParam, lParam); } return 0; }
/** * This function shows/hides a child control. * * @param parent The parent window. * @param id The id of the child window to show or hide. * @param show The show/hide command. */ void controls::showWindow(CWnd &parent, UINT id, UINT show) { if (parent.GetSafeHwnd() != 0) { CWnd *child = parent.GetDlgItem(id); if (child != NULL) child->ShowWindow(show); } }
/** * This sets the text of a child control. * * @param parent The parent control. * @param id The id of the child control. * @param text The new text of the control. */ void controls::setWindowText(CWnd &parent, UINT id, std::string const &text) { if (parent.GetSafeHwnd() != 0) { CWnd *child = parent.GetDlgItem(id); if (child != NULL) child->SetWindowText(text.c_str()); } }
void CItemEdit::OnKillFocus(CWnd* pNewWnd) { CEdit::OnKillFocus(pNewWnd); CWnd* pParent = this->GetParent(); ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,0,0); // TODO: 在此处添加消息处理程序代码 }
/** * This function enables/disables a child control. * * @param parent The parent window. * @param id The id of the child window to enable/disable. * @param enable If true the window is enabled, otherwise it is disabled. */ void controls::enableWindow(CWnd &parent, UINT id, bool enable) { if (parent.GetSafeHwnd() != 0) { CWnd *child = parent.GetDlgItem(id); if (child != NULL) child->EnableWindow(enable ? TRUE : FALSE); } }
void CEditEx::OnKillFocus( CWnd* pNewWnd ) { CEdit::OnKillFocus(pNewWnd); // TODO: 在此处添加消息处理程序代码 CWnd* pParent = this->GetParent(); ::SendMessage(pParent->GetSafeHwnd(),ORANGE_LVN_ENDEDIT,0,0); }
bool CExtButton::_IsMouseOnButton() { POINT point; VERIFY( GetCursorPos( &point ) ); CWnd * pWndUnderMouse = WindowFromPoint( point ); if( pWndUnderMouse->GetSafeHwnd() == m_hWnd ) return true; return false; }
void CPanelBase::MoveChildCtrlWindow(CWnd &wndCtrl, int cx, int cy) { if (wndCtrl.GetSafeHwnd()) { CRect wr; wndCtrl.GetWindowRect(wr); ScreenToClient(wr); wndCtrl.MoveWindow(wr.left, wr.top, cx, wr.Height()); } }
/** * This function gets the extens of a child window in the parent window's * coordinate system * * @param parent The parent window. * @param id The id of the child window. * @returns The extents of the child window. */ CRect controls::childExtents(CWnd const &parent, UINT id) { if (parent.GetSafeHwnd() != 0) { CWnd *child = parent.GetDlgItem(id); if (child != NULL) return childExtents(*child); } return CRect(); }
void CShoshTreeCtrl::OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); HTREEITEM hSelect; CWnd * pParent = NULL; pParent = GetParent(); if (pParent == NULL) pParent = GetOwner(); UINT flag = TVHT_ONITEM; hSelect =pNMTreeView->itemNew.hItem; if(hSelect == NULL) { return; } CResLibData* pResLibDataBase =(CResLibData*) GetItemData(hSelect); if (pResLibDataBase == NULL) { return ; } DWORD_PTR* pArray = new DWORD_PTR[pResLibDataBase->m_pBaseList.size()]; int nRetRobotLen =0; pResLibDataBase->m_pBaseList.sort(Cmpare()); for (list<CResLibData*>::iterator it = pResLibDataBase->m_pBaseList.begin(); it != pResLibDataBase->m_pBaseList.end() ;it++) { if (((*it))->m_sEntType.find("0") != string::npos) { pArray[nRetRobotLen++] = (DWORD_PTR)(*it); } } if (pParent != NULL && IsWindow(pParent->GetSafeHwnd())) ::SendMessage(pParent->GetSafeHwnd() , WM_RESLIB_NOTIFY_SELCHANGED ,(WPARAM )pArray, (LPARAM)nRetRobotLen); delete[] pArray; pArray = NULL; }
void CDialogCoord::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // Do not call CDialog::OnPaint() for painting messages CWnd* picwnd = GetDlgItem(IDC_PIC); //shower.Show(picwnd->GetSafeHwnd(), cvx::SW_CENTER); shower.Show(picwnd->GetSafeHwnd(), cvx::SW_FIT); }
void CFormulaSelectDialog::OnButtonComma() { if (m_FocusedID != IDC_WEIGH_EDIT) { return; } CWnd * pWnd = GetDlgItem(m_FocusedID); ::SetFocus(pWnd->GetSafeHwnd()); keybd_event(190, 0, 0, 0); }
void CTreeCtrlFolder::OnKillFocus(CWnd* pNewWnd) { CPoint point; GetCursorPos(&point); CWnd* wnd = WindowFromPoint(point); if (wnd->GetSafeHwnd() != m_comboBoxFolder->GetSafeHwnd()) ShowWindow(SW_HIDE); CDriveTree::OnKillFocus(pNewWnd); }
LRESULT CXTPTaskDialogFrame::OnDialogClickButton(WPARAM wParam, LPARAM /*lParam*/) { CWnd* pWnd = GetDlgItem((UINT)wParam); if (!pWnd) return FALSE; WindowProc(WM_COMMAND, MAKEWPARAM((UINT)wParam, BN_CLICKED), (LPARAM)pWnd->GetSafeHwnd()); return TRUE; }
//*************************************************************************** void CBCGPRibbonKeyTip::UpdateMenuShadow () { CWnd* pMenu = CBCGPPopupMenu::GetActiveMenu (); if (pMenu != NULL && CWnd::FromHandlePermanent (pMenu->GetSafeHwnd ()) != NULL && !m_rectScreen.IsRectEmpty ()) { CBCGPPopupMenu::UpdateAllShadows (m_rectScreen); } }
void CEditDialogBar::Resize(int cx, int cy) { int count = (int)m_ResizeInfo.GetSize (); if (count == 0) { return; } HDWP hDwp = ::BeginDeferWindowPos (count); for (int i = 0; i < count; i++) { const XResizeInfo& ri = m_ResizeInfo[i]; DWORD dwFlags = SWP_NOMOVE; if (ri.m_resize == e_ResizeMoveH || ri.m_resize == e_ResizeMoveV || ri.m_resize == e_ResizeMoveHV) { dwFlags = SWP_NOSIZE; } CSize szDiff (cx - m_szWindow.cx, cy - m_szWindow.cy); CWnd* pWnd = GetDlgItem (ri.m_id); ASSERT_VALID (pWnd); CRect rect (ri.m_rectInit); if (ri.m_resize == e_ResizeMoveH || ri.m_resize == e_ResizeMoveHV) { rect.OffsetRect (szDiff.cx, 0); } if (ri.m_resize == e_ResizeMoveV || ri.m_resize == e_ResizeMoveHV) { rect.OffsetRect (0, szDiff.cy); } if (ri.m_resize == e_ResizeSizeH || ri.m_resize == e_ResizeSizeHV) { rect.right += szDiff.cx; } if (ri.m_resize == e_ResizeSizeV || ri.m_resize == e_ResizeSizeHV) { rect.bottom += szDiff.cy; } ::DeferWindowPos (hDwp, pWnd->GetSafeHwnd (), HWND_TOP, rect.left, rect.top, rect.Width (), rect.Height (), SWP_NOZORDER | SWP_NOOWNERZORDER | dwFlags); } ::EndDeferWindowPos (hDwp); }