void CRollupGripper::OnMouseMove(UINT nFlags, CPoint point) { CRect rClientRect; GetClientRect(&rClientRect); if(point.x >= rClientRect.left && point.x <= rClientRect.right && point.y >= rClientRect.top && point.y <= rClientRect.bottom) { if(!m_bMouseOver) { m_bMouseOver = true; SetCapture(); if(m_iState < GRIPPER_STATE_MOUSEOVER) { m_iState = GRIPPER_STATE_MOUSEOVER; Invalidate(); } } } else { m_bMouseOver = false; if(!m_bLButtonDown) { m_iState = GRIPPER_STATE_NORMAL; ReleaseCapture(); Invalidate(); } } if(m_bLButtonDown) { CWnd* pParent = GetParent(); if(!pParent) pParent = GetDesktopWindow(); CRect ParentRect; // Parent client area (Parent coords) pParent->GetClientRect(ParentRect); ClientToScreen(&point); // Convert point to parent coords pParent->ScreenToClient(&point); CRect ButtonRect; // Button Dimensions (Parent coords) GetWindowRect(ButtonRect); pParent->ScreenToClient(ButtonRect); if(point != m_cpLastPoint) { m_iLastMove = m_cpLastPoint.y - point.y; if(m_iLastMove != 0) GetParent()->SendMessage(WM_COMMAND, USRMSG_GRIPPERMOVE, (long)m_hWnd); m_cpLastPoint = point; } } CWnd::OnMouseMove(nFlags, point); }
// ============================================= // CallbackSelectDir // 概要 : フォルダ参照で使用するコールバック関数 // : 開いたときにフォルダを選択した状態で開かせる処理をする場合に必要 // 引数 : ... // 戻り値: int CALLBACK // ============================================= int CALLBACK CSHBrowseForFolder::CallbackSelectDir(HWND hWnd, UINT uMsg, LPARAM, LPARAM lpData) { if (uMsg == BFFM_INITIALIZED) { // デフォルトのフォルダを選択させる SendMessage(hWnd, BFFM_SETSELECTION, (WPARAM)TRUE, lpData); { // フォルダーツリーで常に選択状態を表示 HWND hwndTree = FindWindowEx(hWnd, NULL, "SysTreeView32", NULL); if (hwndTree != NULL) { LONG style; style = GetWindowLong(hwndTree, GWL_STYLE); style |= TVS_SHOWSELALWAYS; SetWindowLong(hwndTree, GWL_STYLE, style); } } // [サブディレクトリを検索] ボタンを追加 if (GetEnableSubDirButton()) { pSubDir = new CButton; /* WildCherry2 080 */ if (pSubDir) { RECT rectClient, rectOK, rectCancel, rect; CWnd *pClient = CWnd::FromHandle(hWnd); CWnd *pOK = pClient->GetDlgItem(IDOK); CWnd *pCANCEL = pClient->GetDlgItem(IDCANCEL); // クライアントウィンドウサイズを取得 pClient->GetClientRect(&rectClient); // [OK] / [CANCEL] のウィンドウ位置を取得 pOK->GetWindowRect(&rectOK); pCANCEL->GetWindowRect(&rectCancel); pClient->ScreenToClient(&rectOK) ; pClient->ScreenToClient(&rectCancel) ; // サブディレクトリ対象チェックボタンの RECT を求める rect = CRect(rectClient.right - rectCancel.right, rectCancel.top, rectOK.left, rectCancel.bottom); // チェックボタン作成 if (pSubDir->Create(GetCheckBoxTitle(), WS_CHILD | WS_VISIBLE | BS_CHECKBOX | WS_TABSTOP, rect, pClient, IDC_CH_SUB_DIR)) { // フォントを設定 HFONT hFontCurr = (HFONT)pClient->SendMessage(WM_GETFONT, 0, 0); if (hFontCurr != NULL) pSubDir->PostMessage(WM_SETFONT, (WPARAM)hFontCurr, 0); // チェック状態を設定 pSubDir->SetCheck(GetSearchSubDirState() ? TRUE : FALSE); // サブクラス化 m_VSSelectOrgProc = (WNDPROC)SetWindowLong(hWnd, GWL_WNDPROC, (LONG)VSSelectFolderSubProc); } } } } return 0; }
/* OnInitDone * ---------------------------------------------------------------------------- */ void CFolderDialog::OnInitDone() { HideControl(stc2); HideControl(cmb1); CWnd* pFD = GetParent(); LCID lcid = GetSystemDefaultLCID(); switch(PRIMARYLANGID(LANGIDFROMLCID(lcid))) { default: case LANG_ENGLISH: SetControlText(stc3, "Folder:"); SetControlText(IDOK, "&Select"); pFD->SetWindowText("Select Folder"); break; case LANG_GERMAN: SetControlText(stc3, "Verzeichnis:"); SetControlText(IDOK, "&Auswahl"); pFD->SetWindowText("Verzeichnis auswählen"); break; } SetControlText(edt1, m_sSelPath); CRect rStatic; pFD->GetDlgItem(stc3)->GetWindowRect(rStatic); pFD->ScreenToClient(rStatic); rStatic.right -= 10; pFD->GetDlgItem(stc3)->SetWindowPos(0, 0, 0, rStatic.Width(), rStatic.Height(), SWP_NOMOVE | SWP_NOZORDER); CRect rectCancel; pFD->GetDlgItem(IDCANCEL)->GetWindowRect(rectCancel); pFD->ScreenToClient(rectCancel); CRect rectOK; pFD->GetDlgItem(IDOK)->GetWindowRect(rectOK); pFD->ScreenToClient(rectOK); pFD->GetDlgItem(IDOK)->SetWindowPos(0,rectCancel.left - rectOK.Width() - 4, rectCancel.top, 0,0, SWP_NOZORDER | SWP_NOSIZE); CRect rList; pFD->GetDlgItem(lst1)->GetWindowRect(rList); pFD->ScreenToClient(rList); CRect rEdit; pFD->GetDlgItem(edt1)->GetWindowRect(rEdit); pFD->ScreenToClient(rEdit); rEdit.left = rStatic.right + 10; pFD->GetDlgItem(edt1)->SetWindowPos(0, rEdit.left, rEdit.top, rList.right - rEdit.left, rEdit.Height(), SWP_NOZORDER); m_fpWndProcDiag = (WNDPROC)SetWindowLong(pFD->m_hWnd, GWL_WNDPROC, (long)WindowProcDiag); m_fpWndProcEdit = (WNDPROC)SetWindowLong(pFD->GetDlgItem(edt1)->m_hWnd, GWL_WNDPROC, (long)WindowProcEdit); }
// Move and resize the window so that the window is the same size // as the hyperlink text. This stops the hyperlink cursor being active // when it is not directly over the text. If the text is left justified // then the window is merely shrunk, but if it is centred or right // justified then the window will have to be moved as well. // // Suggested by Pål K. Tønder // void CXHyperLink::PositionWindow() { if (!::IsWindow(GetSafeHwnd()) || !m_bAdjustToFit) return; // Get the current window position CRect WndRect, ClientRect; GetWindowRect(WndRect); GetClientRect(ClientRect); ClientToScreen(ClientRect); CWnd* pParent = GetParent(); if (pParent) { pParent->ScreenToClient(WndRect); pParent->ScreenToClient(ClientRect); } // Get the size of the window text CString strWndText; GetWindowText(strWndText); CDC* pDC = GetDC(); CFont* pOldFont = pDC->SelectObject(&m_UnderlineFont); CSize Extent = pDC->GetTextExtent(strWndText); pDC->SelectObject(pOldFont); ReleaseDC(pDC); // Adjust for window borders Extent.cx += WndRect.Width() - ClientRect.Width(); Extent.cy += WndRect.Height() - ClientRect.Height(); // Get the text justification via the window style DWORD dwStyle = GetStyle(); // Recalc the window size and position based on the text justification if (dwStyle & SS_CENTERIMAGE) WndRect.DeflateRect(0, (WndRect.Height() - Extent.cy)/2); else WndRect.bottom = WndRect.top + Extent.cy; if (dwStyle & SS_CENTER) WndRect.DeflateRect((WndRect.Width() - Extent.cx)/2, 0); else if (dwStyle & SS_RIGHT) WndRect.left = WndRect.right - Extent.cx; else // SS_LEFT = 0, so we can't test for it explicitly WndRect.right = WndRect.left + Extent.cx; // Move the window SetWindowPos(NULL, WndRect.left, WndRect.top, WndRect.Width(), WndRect.Height(), SWP_NOZORDER); }
BOOL CChildWnd::TestPoint(const CPoint& ptScreen) { CWnd* pHit = WindowFromPoint( ptScreen ); if ( pHit == NULL ) return FALSE; if ( pHit == this ) return TRUE; if ( ! IsWindow( pHit->m_hWnd ) || ! IsWindow( GetSafeHwnd() ) ) return FALSE; if ( ::GetAncestor( pHit->m_hWnd, GA_ROOT ) != ::GetAncestor( GetSafeHwnd(), GA_ROOT ) ) return FALSE; CPoint ptChild( ptScreen ); pHit->ScreenToClient( &ptChild ); CWnd* pChild = pHit->ChildWindowFromPoint( ptChild, CWP_SKIPINVISIBLE ); if ( pChild == NULL ) pChild = pHit; while ( pChild != NULL ) { if ( pChild == this ) return TRUE; pChild = pChild->GetParent(); } return FALSE; }
void CImportDialog::OnInitDone() { CRect rct; // Used to move/resize controls CWnd *pp; // Parent = the dialog window itself VERIFY(pp = GetParent()); ASSERT(pp->GetDlgItem(cmb1) != NULL && pp->GetDlgItem(IDOK) != NULL); // Create a new button below the "Type" drop down list pp->GetDlgItem(cmb1)->GetWindowRect(rct); // Get button rectangle pp->ScreenToClient(rct); rct.InflateRect(0, 4, -rct.Width()/3, 4); // Make 2/3 width, + make higher for 2 lines of text rct.OffsetRect(0, 30); m_discon.Create(_T("Use import addresses\r\n(for non-adjoining records)"), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX | BS_MULTILINE, rct, pp, IDC_DISCON); m_discon.SetFont(pp->GetDlgItem(IDOK)->GetFont()); m_discon.SetCheck(theApp.import_discon_); rct.OffsetRect(rct.Width()+4, 0); rct.InflateRect(0, 0, -(rct.Width()/2), 0); // Make half width of IDC_DISCON checkbox (= 1/3 of cmb1 width) m_highlight.Create(_T("Highlight"), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX | BS_MULTILINE, rct, pp, IDC_IMPORT_HIGHLIGHT); m_highlight.SetFont(pp->GetDlgItem(IDOK)->GetFont()); m_highlight.SetCheck(theApp.import_highlight_); CHexFileDialog::OnInitDone(); }
void CSplitterControl::OnMouseMove(UINT nFlags, CPoint point) { if (m_bMouseIsDown) { // erase the old splitter CWindowDC dc(NULL); this->DrawSplitterLine(&dc); // calc the new pos of the splitter CPoint pt = point; this->ClientToScreen(&pt); CWnd* pParent = GetParent(); ASSERT(pParent); ASSERT(IsWindow(pParent->m_hWnd)); pParent->ScreenToClient(&pt); // split position limit pt.x = (pt.x < m_iMinPos)?m_iMinPos:pt.x; pt.y = (pt.y < m_iMinPos)?m_iMinPos:pt.y; pt.x = (pt.x > m_iMaxPos)?m_iMaxPos:pt.x; pt.y = (pt.y > m_iMaxPos)?m_iMaxPos:pt.y; // save the current pos, this value will be used when the mouse up pParent->ClientToScreen(&pt); m_ptCurrent = pt; // repaint the splitter this->DrawSplitterLine(&dc); } CStatic::OnMouseMove(nFlags, point); }
//设置背景位图,设置的位图资源由调用者负责释放 void CBmpButton::SetStateBitmap(CBitmap *p_pUncheckedBmpNormal, CBitmap *p_pUncheckedBmpSelect, CBitmap *p_pBmpUncheckedOver, CBitmap *p_pBmpDisable, CBitmap *p_pCheckedBmpNormal, CBitmap *p_pCheckedBmpSelect, CBitmap *p_pBmpCheckedOver) { ASSERT(p_pUncheckedBmpNormal); m_pBmpUncheckedNormal = p_pUncheckedBmpNormal; m_pBmpUncheckedSelect = p_pUncheckedBmpSelect; m_pBmpUncheckedOver = p_pBmpUncheckedOver; m_pBmpCheckedNormal = p_pCheckedBmpNormal; m_pBmpCheckedSelect = p_pCheckedBmpSelect; m_pBmpCheckedOver = p_pBmpCheckedOver; m_pBmpDisable = p_pBmpDisable; m_bBmpIsCreateBySelf = FALSE; /////////////////////////////// BITMAP BmpInfo; p_pUncheckedBmpNormal->GetBitmap(&BmpInfo); CRect rcBtnRect; CWnd *pWnd = this->GetParent(); GetWindowRect(&rcBtnRect); pWnd->ScreenToClient(rcBtnRect); rcBtnRect.right = rcBtnRect.left + BmpInfo.bmWidth; rcBtnRect.bottom = rcBtnRect.top + BmpInfo.bmHeight; MoveWindow(rcBtnRect); }
///////////////////////////////////////////////////////////////////////////// // CFileOpenDialog - derived from CFileDialog (via CHexFileDialog) for handling extra control void CFileOpenDialog::OnInitDone() { CRect rct; // Used to move/resize controls CWnd *pp; // Parent = the dialog window itself VERIFY(pp = GetParent()); ASSERT(pp->GetDlgItem(cmb1) != NULL && pp->GetDlgItem(chx1) != NULL && pp->GetDlgItem(IDOK) != NULL); // Create a new check box next to Read only check box pp->GetDlgItem(cmb1)->GetWindowRect(rct); // Get "Type" drop down list width int width = rct.Width(); pp->GetDlgItem(chx1)->GetWindowRect(rct); // Get "Read only" rectangle pp->ScreenToClient(rct); // Make read only check box half the width of "Type" box (it is sometimes much wider than it needs to be) rct.right = rct.left + width/2 - 2; pp->GetDlgItem(chx1)->MoveWindow(rct); // Work out rect of new check box rct.OffsetRect(width/2, 0); // move over (so not on top of "read only" checkbox) //rct.InflateRect(0, 0, 10, 0); m_open_shared.Create(_T("Open shareable"), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX | BS_MULTILINE, rct, pp, IDC_OPEN_SHARED); m_open_shared.SetFont(pp->GetDlgItem(IDOK)->GetFont()); m_open_shared.SetCheck(theApp.open_file_shared_); CHexFileDialog::OnInitDone(); }
BOOL CTransparentStatic2::OnEraseBkgnd(CDC* pDC) { if (m_Bmp.GetSafeHandle() == NULL) { CRect Rect; GetWindowRect(&Rect); CWnd *pParent = GetParent(); ASSERT(pParent); pParent->ScreenToClient(&Rect); //convert our corrdinates to our parents //copy what's on the parents at this point CDC *pDC = pParent->GetDC(); CDC MemDC; MemDC.CreateCompatibleDC(pDC); m_Bmp.CreateCompatibleBitmap(pDC,Rect.Width(),Rect.Height()); CBitmap *pOldBmp = MemDC.SelectObject(&m_Bmp); MemDC.BitBlt(0,0,Rect.Width(),Rect.Height(),pDC,Rect.left,Rect.top,SRCCOPY); MemDC.SelectObject(pOldBmp); pParent->ReleaseDC(pDC); } else //copy what we copied off the parent the first time back onto the parent { CRect Rect; GetClientRect(Rect); CDC MemDC; MemDC.CreateCompatibleDC(pDC); CBitmap *pOldBmp = MemDC.SelectObject(&m_Bmp); pDC->BitBlt(0,0,Rect.Width(),Rect.Height(),&MemDC,0,0,SRCCOPY); MemDC.SelectObject(pOldBmp); } return TRUE; }
void CSplitterControl::MoveWindowTo(CPoint pt) { CRect rc; GetWindowRect(rc); CWnd* pParent; pParent = GetParent(); if (!pParent || !::IsWindow(pParent->m_hWnd)) return; pParent->ScreenToClient(rc); if (m_nType == SPS_VERTICAL) { int nMidX = (rc.left + rc.right) / 2; int dx = pt.x - nMidX; rc.OffsetRect(dx, 0); } else { int nMidY = (rc.top + rc.bottom) / 2; int dy = pt.y - nMidY; rc.OffsetRect(0, dy); } MoveWindow(rc); }
bool CExtAviLabel::AviSizeFromContent( CSize & sizeBefore, CSize & sizeAfter, bool bMoveWindow // = true ) { ASSERT_VALID( this ); if( GetSafeHwnd() == NULL ) return false; if( AviIsEmpty() ) return false; CWnd * pWndParent = GetParent(); if( pWndParent == NULL ) return false; bool bChildMode = ( ( GetStyle() & WS_CHILD ) != 0 ) ? true : false; CRect rcWnd; GetWindowRect( &rcWnd ); if( bChildMode ) pWndParent->ScreenToClient( &rcWnd ); CRect rcClient; GetClientRect( &rcClient ); CSize sizePrevious = rcWnd.Size(); CSize sizeClient = rcClient.Size(); CSize sizeNonClient = sizePrevious - sizeClient; CSize sizeAviFrame = AviFrameGetSize(); CRect rcDst( rcWnd.left, rcWnd.top, rcWnd.left + sizeNonClient.cx + sizeAviFrame.cx, rcWnd.top + sizeNonClient.cy + sizeAviFrame.cy ); CSize sizeDst = rcDst.Size(); sizeBefore = sizePrevious; sizeAfter = sizeDst; if( sizeDst == sizePrevious ) return false; if( bMoveWindow ) MoveWindow( &rcDst ); return true; }
void CTitleTip::OnMouseMove(UINT nFlags, CPoint point) { if (!m_rectHover.PtInRect(point)) { Hide(); // Forward the message ClientToScreen( &point ); CWnd *pWnd = WindowFromPoint( point ); if ( pWnd == this ) pWnd = m_pParentWnd; int hittest = (int)pWnd->SendMessage(WM_NCHITTEST, 0, MAKELONG(point.x, point.y)); if (hittest == HTCLIENT) { pWnd->ScreenToClient( &point ); pWnd->PostMessage( WM_MOUSEMOVE, nFlags, MAKELONG(point.x, point.y) ); } else { pWnd->PostMessage( WM_NCMOUSEMOVE, hittest, MAKELONG(point.x, point.y) ); } } }
BOOL CWndImage::CreateFromStatic(CWnd * sc) { // _ASSERTE(!::IsWindow(m_hWnd)); // image control already created if (!sc || !::IsWindow(sc->m_hWnd)) return false; CWnd * dlg = sc->GetParent(); if (!dlg || !::IsWindow(dlg->m_hWnd)) return false; CRect r; sc->GetWindowRect(&r); dlg->ScreenToClient(&r); CString s; DWORD style = sc->GetStyle(); DWORD exstyle = sc->GetExStyle(); sc->GetWindowText(s); UINT dlgID = sc->GetDlgCtrlID(); HBITMAP bmp = (HBITMAP) sc->SendMessage(STM_GETIMAGE, IMAGE_BITMAP, 0); if (bmp) sc->SendMessage(STM_SETIMAGE, IMAGE_BITMAP, 0); sc->DestroyWindow(); CreateEx(exstyle, NULL, s, style, r, dlg, dlgID); if (bmp) { SetImg(bmp, false); SetBltMode(bltFitXY); } return true; }
void CSnapView::OnSize(UINT nType, int cx, int cy) { if (nType != SIZE_MINIMIZED && cx != 0 && cy != 0 && m_pPropSheet != NULL) { if (m_bSizedBefore == FALSE) { m_bSizedBefore = TRUE; // get the size of the property sheet CRect rectSized; m_pPropSheet->GetWindowRect(rectSized); // calculate the size of the frame CFrameWnd* pFrame = GetParentFrame(); if (pFrame != NULL) { pFrame->CalcWindowRect(rectSized); CWnd* pParent = pFrame->GetParent(); if (pParent != NULL) pParent->ScreenToClient(rectSized); // resize and reposition the frame pFrame->MoveWindow(rectSized); } } } }
/** * * \param nFlags * \param point */ void CUnitListBox::OnMouseMove(UINT nFlags, CPoint point) { if (m_bDragging && m_pDragImage != NULL) { CPoint cPt(point); ClientToScreen(&cPt); m_pDragImage->DragMove(cPt); m_pDragImage->DragShowNolock(false); CWnd* pDropWnd = WindowFromPoint (cPt); if (pDropWnd) { pDropWnd->ScreenToClient(&cPt); if(pDropWnd->IsKindOf(RUNTIME_CLASS (CView))) { SetCursor(LoadCursor(NULL, IDC_ARROW)); } else { SetCursor(LoadCursor(NULL, IDC_NO)); } m_pDragImage->DragShowNolock(true); } } }
void CColourPicker::SetWindowSize() { // Get size dimensions of edges CSize MarginSize(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE)); // Get size of dropdown arrow int nArrowWidth = max(::GetSystemMetrics(SM_CXHTHUMB), 5*MarginSize.cx); int nArrowHeight = max(::GetSystemMetrics(SM_CYVTHUMB), 5*MarginSize.cy); CSize ArrowSize(max(nArrowWidth, nArrowHeight), max(nArrowWidth, nArrowHeight)); // Get window size CRect rect; GetWindowRect(rect); CWnd* pParent = GetParent(); if (pParent) pParent->ScreenToClient(rect); // Set window size at least as wide as 2 arrows, and as high as arrow + margins int nWidth = max(rect.Width(), 2*ArrowSize.cx + 2*MarginSize.cx); MoveWindow(rect.left, rect.top, nWidth, ArrowSize.cy+2*MarginSize.cy, TRUE); // Get the new coords of this window GetWindowRect(rect); ScreenToClient(rect); // Get the rect where the arrow goes, and convert to client coords. m_ArrowRect.SetRect(rect.right - ArrowSize.cx - MarginSize.cx, rect.top + MarginSize.cy, rect.right - MarginSize.cx, rect.bottom - MarginSize.cy); }
void CDocumentPreview::SizePreviewWindow(int nWidth, int nHeight) { m_crPreview.left = (m_crFullPreview.left+m_crFullPreview.right-nWidth)/2; m_crPreview.top = (m_crFullPreview.top+m_crFullPreview.bottom-nHeight)/2; m_crPreview.right = m_crPreview.left + nWidth; m_crPreview.bottom = m_crPreview.top + nHeight; CRect r = m_crPreview; // We can't both set and show the window at the same time // with SetWindowPos. So, we call it twice as needed. CWnd* pPreviewWnd = GetPreviewWnd(); pPreviewWnd->SetWindowPos(NULL, r.left-1, r.top-1, nWidth+2, nHeight+2, SWP_NOZORDER | SWP_NOREDRAW); pPreviewWnd->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW | SWP_SHOWWINDOW); // Invalidate ourselves to avoid background draw. CWnd* pDialog = GetDialog(); pDialog->ClientToScreen(&m_crPreview); pPreviewWnd->ScreenToClient(&m_crPreview); r = m_crPreview; r.left--; r.top--; r.right++; r.bottom++; pPreviewWnd->InvalidateRect(&r, FALSE); }
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 ); }
BOOL CElcSkinFrameBase::IsCtrlInPane(CWnd* pWnd) { if (!m_bDrawClientBackgnd) return FALSE; if (!m_skin.client.pane.image.pImage) return FALSE; CWnd* pThis = CWnd::FromHandle(m_hDerive); if (!pThis) return FALSE; CRect rcThis, rcPane, rcCtrl; CPoint pt; pThis->GetClientRect(rcThis); pWnd->GetWindowRect(rcCtrl); pThis->ScreenToClient(&rcCtrl); pt.x = rcCtrl.left + rcCtrl.Width() / 2; pt.y = rcCtrl.top + rcCtrl.Height() / 2; for (CClientImagePosArray::iterator it = m_arrClientImagePos.begin(); it != m_arrClientImagePos.end(); it ++) { rcPane = CalcRect(rcThis, &(it->pos.point), &(it->pos.size)); if (rcPane.PtInRect(pt)) return TRUE; } return FALSE; }
void CRoundButton::PreSubclassWindow() { CButton::PreSubclassWindow(); ModifyStyle(0, BS_OWNERDRAW); CRect rect; GetClientRect(rect); // Resize the window to make it square rect.bottom = rect.right = min(rect.bottom,rect.right); // Get the vital statistics of the window m_ptCentre = rect.CenterPoint(); m_nRadius = rect.bottom/2-1; // Set the window region so mouse clicks only activate the round section // of the button m_rgn.DeleteObject(); SetWindowRgn(NULL, FALSE); m_rgn.CreateEllipticRgnIndirect(rect); SetWindowRgn(m_rgn, TRUE); // Convert client coords to the parents client coords ClientToScreen(rect); CWnd* pParent = GetParent(); if (pParent) pParent->ScreenToClient(rect); // Resize the window MoveWindow(rect.left, rect.top, rect.Width(), rect.Height(), TRUE); }
void CExportDialog::OnInitDone() { CRect rct; // Used to move/resize controls CWnd *pp; // Parent = the dialog window itself VERIFY(pp = GetParent()); ASSERT(pp->GetDlgItem(cmb1) != NULL && pp->GetDlgItem(IDOK) != NULL); // Create a new button below the "Type" drop down list pp->GetDlgItem(cmb1)->GetWindowRect(rct); // Get button rectangle pp->ScreenToClient(rct); rct.InflateRect(0, 4, -(rct.Width()/2), 4); // make higher for 2 lines of text and half the width rct.OffsetRect(0, 30); m_discon_hl.Create(_T("Export (non-adjoining)\r\nhighlighted areas only"), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX | BS_MULTILINE, rct, pp, IDC_DISCON); m_discon_hl.SetFont(pp->GetDlgItem(IDOK)->GetFont()); m_discon_hl.SetCheck(theApp.import_discon_); FILE_ADDRESS start, end; m_pview->GetSelAddr(start, end); if (start >= end) m_discon_hl.SetCheck(1); if (!m_pview->HasHighlights()) { // If no highlights disable the checkbox m_discon_hl.SetCheck(0); m_discon_hl.EnableWindow(FALSE); } CHexFileDialog::OnInitDone(); }
////////////////// // Handle button-up: drop the data and return to home state (NONE). // BOOL CDragDropMgr::OnButtonUp(const MSG& msg) { if (!IsDragging()) { SetState(NONE); return FALSE; } if (IsTargetWnd(m_ddi.hwndTarget)) { CPoint pt = GETPOINT(msg.lParam); CWnd* pWndSource = CWnd::FromHandle(m_ddi.hwndSource); CWnd* pWndTarget = CWnd::FromHandle(m_ddi.hwndTarget); pWndSource->ClientToScreen(&pt); pWndTarget->ScreenToClient(&pt); m_ddi.pt = pt; SendDragMessage(WM_DD_DRAGDROP); } else { SendDragMessage(WM_DD_DRAGABORT); } SetState(NONE); return TRUE; }
BOOL CXTThemeManagerStyle::TakeSnapShot(CWnd* pWndOwner) { CWnd *pWndParent = pWndOwner->GetParent(); if (::IsWindow(pWndParent->GetSafeHwnd())) { if (m_bmpSnapShot.GetSafeHandle() != NULL) m_bmpSnapShot.DeleteObject(); //convert our coordinates to our parent coordinates. CXTPWindowRect rc(pWndOwner); pWndParent->ScreenToClient(&rc); //copy what's on the parents background at this point CDC *pDC = pWndParent->GetDC(); CDC memDC; memDC.CreateCompatibleDC(pDC); m_bmpSnapShot.CreateCompatibleBitmap(pDC, rc.Width(), rc.Height()); CXTPBitmapDC bitmapDC(&memDC, &m_bmpSnapShot); memDC.BitBlt(0, 0, rc.Width(), rc.Height(), pDC, rc.left, rc.top, SRCCOPY); pWndParent->ReleaseDC(pDC); return TRUE; } return FALSE; }
LRESULT COleIPFrameWnd::OnResizeChild(WPARAM, LPARAM lParam) { // notify the container that the rectangle has changed! COleServerDoc* pDoc = (COleServerDoc*)GetActiveDocument(); if (pDoc == NULL) return 0; ASSERT_KINDOF(COleServerDoc, pDoc); // get new rect and parent CRect rectNew; rectNew.CopyRect((LPCRECT)lParam); CWnd* pParentWnd = GetParent(); ASSERT_VALID(pParentWnd); // convert rectNew relative to pParentWnd ClientToScreen(&rectNew); pParentWnd->ScreenToClient(&rectNew); // adjust the new rectangle for the current control bars CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST); ASSERT(pLeftOver != NULL); CRect rectCur = m_rectPos; pLeftOver->CalcWindowRect(&rectCur, CWnd::adjustOutside); rectNew.left += m_rectPos.left - rectCur.left; rectNew.top += m_rectPos.top - rectCur.top; rectNew.right -= rectCur.right - m_rectPos.right; rectNew.bottom -= rectCur.bottom - m_rectPos.bottom; OnRequestPositionChange(rectNew); return 0; }
// 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(); }
BOOL CEditButton::Create(CWnd* pWnd, SEARCH_TYPE eType, UINT nMenu) { ASSERT(eType != -1); ASSERT_VALID(pWnd); m_eType = eType; m_nMenu = nMenu; m_pWnd = pWnd; CWnd* pWndParent = m_pWnd->GetParent(); ASSERT_VALID(pWndParent); CRect rc; m_pWnd->GetWindowRect(&rc); m_pWnd->SetWindowPos(NULL, 0, 0, rc.Width()-23, rc.Height(), SWP_NOZORDER|SWP_NOMOVE); pWndParent->ScreenToClient(&rc); rc.left = rc.right-18; DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_CENTER|BS_VCENTER; switch (m_eType) { case SEARCH_DIRECTORY: case SEARCH_FILE: { if (CButton::Create(_T("..."), dwStyle, rc, pWndParent, GetNextID(pWndParent))) { SetWindowPos(m_pWnd, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE); EnableWindow(m_pWnd->IsWindowEnabled()); SetFont(&m_Font); return TRUE; } } case SEARCH_POPUP: { if (CButton::Create(_T("..."), dwStyle|BS_ICON, rc, pWndParent, GetNextID(pWndParent))) { SetWindowPos(m_pWnd, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE); EnableWindow(m_pWnd->IsWindowEnabled()); SetFont(&m_Font); CImageList imageList; CBitmap bitmap; bitmap.LoadBitmap(IDB_BTN_ARROW); imageList.Create(15, 17, ILC_COLORDDB|ILC_MASK, 1, 1); imageList.Add(&bitmap, RGB(255,0,255)); SetIcon(imageList.ExtractIcon(0)); imageList.Detach(); bitmap.Detach(); return TRUE; } } } return FALSE; }
BOOL CTitleTip::PreTranslateMessage(MSG* pMsg) { CWnd *pWnd; int hittest; switch (pMsg->message) { case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: POINTS pts = MAKEPOINTS( pMsg->lParam ); POINT point; point.x = pts.x; point.y = pts.y; ClientToScreen( &point ); pWnd = WindowFromPoint( point ); if( pWnd == this ) pWnd = m_pParentWnd; hittest = (int)pWnd->SendMessage(WM_NCHITTEST,0,MAKELONG(point.x,point.y)); if (hittest == HTCLIENT) { pWnd->ScreenToClient( &point ); pMsg->lParam = MAKELONG(point.x,point.y); } else { switch (pMsg->message) { case WM_LBUTTONDOWN: pMsg->message = WM_NCLBUTTONDOWN; break; case WM_RBUTTONDOWN: pMsg->message = WM_NCRBUTTONDOWN; break; case WM_MBUTTONDOWN: pMsg->message = WM_NCMBUTTONDOWN; break; } pMsg->wParam = hittest; pMsg->lParam = MAKELONG(point.x,point.y); } Hide(); pWnd->PostMessage(pMsg->message,pMsg->wParam,pMsg->lParam); return TRUE; case WM_KEYDOWN: case WM_SYSKEYDOWN: Hide(); m_pParentWnd->PostMessage( pMsg->message, pMsg->wParam, pMsg->lParam ); return TRUE; } if( GetFocus() == NULL ) { Hide(); return TRUE; } return CWnd::PreTranslateMessage(pMsg); }
BOOL CSkinScrollWnd::SkinWindow(CWnd* pWnd, HBITMAP hBmpScroll) { ASSERT(m_hWnd == NULL); m_hBmpScroll = hBmpScroll; BITMAP bm; GetObject(hBmpScroll, sizeof(bm), &bm); m_nScrollWid = bm.bmWidth/9; CWnd* pParent = pWnd->GetParent(); ASSERT(pParent); RECT rcFrm, rcWnd; pWnd->GetWindowRect(&rcFrm); pParent->ScreenToClient(&rcFrm); rcWnd = rcFrm; OffsetRect(&rcWnd, -rcWnd.left, -rcWnd.top); UINT uID = pWnd->GetDlgCtrlID(); DWORD dwStyle = pWnd->GetStyle(); DWORD dwFrmStyle = WS_CHILD | SS_NOTIFY; DWORD dwFrmStyleEx = 0; if (dwStyle&WS_VISIBLE) dwFrmStyle |= WS_VISIBLE; if (dwStyle&WS_BORDER) { dwFrmStyle |= WS_BORDER; pWnd->ModifyStyle(WS_BORDER, 0); int nBorder = GetSystemMetrics(SM_CXBORDER); rcWnd.right -= nBorder * 2; rcWnd.bottom -= nBorder * 2; } DWORD dwExStyle = pWnd->GetExStyle(); if (dwExStyle&WS_EX_CLIENTEDGE) { pWnd->ModifyStyleEx(WS_EX_CLIENTEDGE, 0); int nBorder = GetSystemMetrics(SM_CXEDGE); rcWnd.right -= nBorder * 2; rcWnd.bottom -= nBorder * 2; dwFrmStyleEx |= WS_EX_CLIENTEDGE; } this->CreateEx(dwFrmStyleEx, AfxRegisterWndClass(NULL), "SkinScrollBarFrame", dwFrmStyle, rcFrm, pParent, uID); m_WndLimit.Create(NULL, "LIMIT", WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), this, 200); m_sbHorz.Create(WS_CHILD, CRect(0, 0, 0, 0), this, 100); m_sbVert.Create(WS_CHILD | SBS_VERT, CRect(0, 0, 0, 0), this, 101); m_sbHorz.SetBitmap(hBmpScroll); m_sbVert.SetBitmap(hBmpScroll); pWnd->SetParent(&m_WndLimit); SetWindowLong(pWnd->m_hWnd, GWL_USERDATA, (LONG)this);/* m_funOldProc = (WNDPROC)SetWindowLong(pWnd->m_hWnd, GWL_WNDPROC, (LONG)ScrollHookWndProc);*/ SetTimer(TIMER_UPDATE, 500, NULL); return TRUE; }
// Set new position for splitter void CSplitterFrame::SetAbsPosition(CPoint pt) { CWnd *pParent = GetParent(); ASSERT(pParent!=NULL); pParent->ScreenToClient(&pt); SetWindowPos(&wndTop,pt.x,pt.y,0,0,SWP_NOSIZE); }