void CCommentsDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); CWnd *pEdit = GetDlgItem(IDC_COMMENTS); CWnd *pOk = GetDlgItem(IDC_OK); CWnd *pCancel = GetDlgItem(IDC_CANCEL); CWnd *pCheckBox = GetDlgItem(IDC_SHOWONOPEN); CRect dlgRect; GetClientRect(dlgRect); if (pEdit != NULL) { dlgRect.bottom -= 39; pEdit->MoveWindow(dlgRect); CRect buttonRect; pOk->GetClientRect(buttonRect); buttonRect.MoveToY(dlgRect.bottom + 8); buttonRect.MoveToX(dlgRect.right - buttonRect.Width() * 2 - 10); pOk->MoveWindow(buttonRect); pCancel->GetClientRect(buttonRect); buttonRect.MoveToY(dlgRect.bottom + 8); buttonRect.MoveToX(dlgRect.right - buttonRect.Width() - 7); pCancel->MoveWindow(buttonRect); pCheckBox->GetClientRect(buttonRect); buttonRect.MoveToY(dlgRect.bottom + 14); buttonRect.MoveToX(8); pCheckBox->MoveWindow(buttonRect); } }
void CIpoDlg::OnSize(UINT nType, int cx, int cy) { CDialogBar::OnSize(nType, cx, cy); // TODO: 在此处添加消息处理程序代码 if( NULL != GetSafeHwnd() ) { CRect rc ; GetClientRect( rc ) ; CWnd *pst = GetDlgItem( IDC_STATIC_ADDR ) ; if ( NULL != pst ) { CRect rect ; pst->GetClientRect( rect ) ; pst->SetWindowPos( NULL , (rc.Width()/100)*3, (rc.Height()/100)*5+4 , rect.Width(), rect.Height() ,SWP_SHOWWINDOW ) ; } pst = GetDlgItem( IDC_EDIT_ADDR ) ; if ( NULL != pst ) { CRect rect ; pst->GetClientRect( rect ) ; pst->SetWindowPos( NULL ,(rc.Width()/100)*8 ,(rc.Height()/100)*5 , (rc.Width()/100)*40, (rc.Height()/100)*7 ,SWP_SHOWWINDOW ) ; } pst = GetDlgItem( IDC_STATIC_AMOUNT ) ; if ( NULL != pst ) { CRect rect ; pst->GetClientRect( rect ) ; pst->SetWindowPos( NULL ,(rc.Width()/100)*48 ,(rc.Height()/100)*6 , (rc.Width()/100)*20, (rc.Height()/100)*5 ,SWP_SHOWWINDOW ) ; } pst = GetDlgItem( IDC_BUTTON_QUERY ) ; if ( NULL != pst ) { pst->SetWindowPos( NULL ,(rc.Width()/100)*60 ,(rc.Height()/100)*5 , (rc.Width()/100)*13-2, (rc.Height()/100)*9 ,SWP_SHOWWINDOW ) ; } // // pst = GetDlgItem( IDC_BUTTON_DRAWAL ) ; if ( NULL != pst ) { CRect rect ; pst->GetClientRect( rect ) ; pst->SetWindowPos( NULL ,(rc.Width()/100)*85 ,(rc.Height()/100)*5 ,(rc.Width()/100)*13-2, (rc.Height()/100)*9 ,SWP_SHOWWINDOW ) ; } pst = GetDlgItem( IDC_LIST_SHOW ) ; if ( NULL != pst ) { CRect rect ; pst->GetClientRect( rect ) ; pst->SetWindowPos( NULL ,(rc.Width()/100)*3 ,(rc.Height()/100)*16 , rc.Width()-(rc.Width()/100)*5+2, (rc.Height()/100)*97+2 ,SWP_SHOWWINDOW ) ; } } }
void CDlgWingspanAdjacancyConstraints::RefreshLayout( int cx /*= -1*/, int cy /*= -1*/ ) { if (cx == -1 && cy == -1) { CRect rectClient; GetClientRect(&rectClient); cx = rectClient.Width(); cy = rectClient.Height(); } CWnd* pWndSave = GetDlgItem(IDC_BUTTON_SAVE); CWnd* pWndOK = GetDlgItem(IDOK); CWnd* pWndCancel = GetDlgItem(IDCANCEL); if (pWndSave == NULL || pWndOK == NULL || pWndCancel == NULL) return; CRect rcCancel; pWndCancel->GetClientRect(&rcCancel); pWndCancel->MoveWindow(cx - rcCancel.Width() - 10, cy - rcCancel.Height() - 10, rcCancel.Width(), rcCancel.Height()); CRect rcOK; pWndOK->GetClientRect(&rcOK); pWndOK->MoveWindow(cx - rcCancel.Width() - rcOK.Width() - 20, cy - rcOK.Height() - 10, rcOK.Width(), rcOK.Height()); CRect rcSave; pWndSave->GetClientRect(&rcSave); pWndSave->MoveWindow(cx - rcCancel.Width() - rcOK.Width() - rcSave.Width() - 30, cy - rcSave.Height() - 10, rcSave.Width(), rcSave.Height()); CWnd* pGroupBox = GetDlgItem(IDC_STATIC_FRAME); if (pGroupBox == NULL) return; pGroupBox->MoveWindow(10, 5, cx - 20, cy - rcOK.Height() - 27); m_wndListCtrl.MoveWindow(10, 35, cx - 20, cy - rcOK.Height() - 57); if (!::IsWindow(m_wndToolBar.m_hWnd)) return; m_wndToolBar.MoveWindow(11, 11, cx - 25, 22); Invalidate(); }
void MBMessageBoxImpl::resizeControls() { CRect okrect,cancelrect,crect,mrect; if (!::IsWindow(m_hWnd)) { return; } GetClientRect(crect); CWnd * wok = GetDlgItem(IDC_MESSAGEBOX_OK); if (!wok) { return; } CWnd * wc = GetDlgItem(IDC_MESSAGEBOX_CANCEL); if (!wc) { return; } if (!::IsWindow(wok->m_hWnd)) { return; } if (!::IsWindow(wc->m_hWnd)) { return; } wok->GetClientRect(okrect); wc->GetClientRect(cancelrect); int x,y; x = (crect.Width() / 2) - (okrect.Width() + 20); y = crect.Height() - (okrect.Height() + 10); wok->MoveWindow(x,y,okrect.Width(),okrect.Height()); x = (crect.Width() / 2) + (20); wc->MoveWindow(x,y,okrect.Width(),okrect.Height()); wok->GetWindowRect(okrect); ScreenToClient(okrect); mrect.left = 10; mrect.right = crect.Width() - 10; mrect.top = 20; mrect.bottom = crect.bottom - (okrect.Height() + 10); mrect.bottom = okrect.top - 20; m_MessageBox.MoveWindow(mrect); m_MessageBox2.MoveWindow(mrect); int numlines = m_MessageBox.GetLineCount(); CRect calcRect; CalcMsgRect(calcRect); if (calcRect.Height() > mrect.Height() || calcRect.Width() > mrect.Width()) { m_MessageBoxPtr = &m_MessageBox; m_MessageBox.ShowWindow(SW_NORMAL); m_MessageBox2.ShowWindow(SW_HIDE); } else { m_MessageBoxPtr = &m_MessageBox2; m_MessageBox.ShowWindow(SW_HIDE); m_MessageBox2.ShowWindow(SW_NORMAL); } }
BOOL CDlgPointThre::OnInitDialog() { // 调用默认OnInitDialog函数 CDialog::OnInitDialog(); // 获取绘制直方图的标签 CWnd* pWnd = GetDlgItem(IDC_COORD); // 计算接受鼠标事件的有效区域 pWnd->GetClientRect(m_MouseRect); pWnd->ClientToScreen(&m_MouseRect); CRect rect; GetClientRect(rect); ClientToScreen(&rect); m_MouseRect.top -= rect.top; m_MouseRect.left -= rect.left; // 设置接受鼠标事件的有效区域 m_MouseRect.top += 25; m_MouseRect.left += 10; m_MouseRect.bottom = m_MouseRect.top + 255; m_MouseRect.right = m_MouseRect.left + 256; // 初始化拖动状态 m_bIsDraging = FALSE; // 返回TRUE return TRUE; }
void CTextureTool::CreateColorCtrl (CWnd *pWnd, int nIdC) { CWnd *pParentWnd = GetDlgItem (nIdC); CRect rc; pParentWnd->GetClientRect (rc); pWnd->Create (NULL, NULL, WS_CHILD | WS_VISIBLE, rc, pParentWnd, 0); }
void COleControl::DestroyTracker() { ASSERT(!m_bOpen); ASSERT(m_bUIActive); if (m_pRectTracker == NULL) return; UINT nHandleSize = m_pRectTracker->m_nHandleSize - 1; // Destroy the tracker. delete m_pRectTracker; m_pRectTracker = NULL; // Restore window to its original (pre-UIActive) size. CWnd* pWndOuter = GetOuterWindow(); CWnd* pWndParent = pWndOuter->GetParent(); CRect rectWindow; CRect rectParent; pWndOuter->GetWindowRect(rectWindow); pWndParent->GetClientRect(rectParent); pWndParent->ClientToScreen(rectParent); rectWindow.OffsetRect(-rectParent.left, -rectParent.top); rectWindow.InflateRect(-(int)nHandleSize, -(int)nHandleSize); ::MoveWindow(pWndOuter->m_hWnd, rectWindow.left, rectWindow.top, rectWindow.Width(), rectWindow.Height(), TRUE); }
BOOL CGetURL::OnInitDialog() { CDialog::OnInitDialog(); IUnknown *pUnk; CWnd *pWnd = GetDlgItem(IDC_EXPLORER); pUnk = NULL; if(pWnd) m_spBrowser = pWnd->GetControlUnknown(); pWnd = NULL; CRect rcItem; pWnd = GetDlgItem(IDC_PHSTATIC); if(pWnd) { pWnd->GetClientRect(rcItem); pWnd->ClientToScreen(rcItem); pWnd->DestroyWindow(); ScreenToClient(rcItem); rcItem.bottom += 150; if(m_AddrCombo.Create(WS_VSCROLL|WS_CHILD|WS_VISIBLE|CBS_DROPDOWN|CBS_AUTOHSCROLL,rcItem,this,IDC_ADDRCOMBO)) { m_AddrCombo.SetCurSel(0); m_AddrCombo.GetWindowText(m_szCurAddr); if(m_spBrowser && m_szCurAddr.GetLength()) m_spBrowser->Navigate(m_szCurAddr.AllocSysString(),NULL,NULL,NULL,NULL); } } return TRUE; }
CIEHostWindow* CPlugin::CreateIEHostWindow(HWND hParent, DWORD dwId) { CIEHostWindow *pIEHostWindow = NULL; CWnd parent; if (!parent.Attach(hParent)) { return FALSE; } try { pIEHostWindow = CIEHostWindow::CreateNewIEHostWindow(dwId); if (pIEHostWindow == NULL) { throw CString(_T("Cannot Create CIEHostWindow!")); } pIEHostWindow->SetPlugin(this); pIEHostWindow->SetParent(&parent); CRect rect; parent.GetClientRect(rect); pIEHostWindow->MoveWindow(rect); pIEHostWindow->ShowWindow(SW_SHOW); } catch (CString strMessage) { if (pIEHostWindow) { delete pIEHostWindow; pIEHostWindow = NULL; } TRACE(_T("[CPlugin::CreateIEHostWindow] Exception: %s\n"), (LPCTSTR)strMessage); } parent.Detach(); return pIEHostWindow; }
HBRUSH CMainTestView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: 在此更改 DC 的任何属性 // TODO: 如果默认的不是所需画笔,则返回另一个画笔 CRect rect; //CWnd* hWndChild = ::GetWindow(m_hWnd, GW_CHILD); CWnd* hWndChild = GetWindow(GW_CHILD); while(hWndChild) { if(hWndChild->GetDlgCtrlID()==331 && nCtlColor== CTLCOLOR_STATIC) { COLORREF backColor = RGB(236, 233, 216);//这个颜色为Formview默认的面板颜色 hWndChild->GetClientRect(&rect); pDC->FillSolidRect(&rect,backColor); pDC->SetBkColor(backColor); return CreateSolidBrush(backColor);//创建背景刷子 } hWndChild = hWndChild-> GetNextWindow(); } return hbr; }
LRESULT OnPaint( HWND hWnd ) { CWnd* pWnd = CWnd::FromHandle(hWnd); CPaintDC dc(pWnd); CString Text; CRect RC; CFont Font; CFont *pOldFont; CBrush Brush; CBrush *pOldBrush; CPoint PT(2,2); dc.SetBkMode( TRANSPARENT ); Font.CreateFont( 12, 0, 0, 0, FW_HEAVY, 0, 0, 0, ANSI_CHARSET, \ OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, \ VARIABLE_PITCH | FF_SWISS, "MS Sans Serif" ); pOldFont = dc.SelectObject( &Font ); if( m_State == bsNormal) { if (m_Style==2) { CBitmap bmp; bmp.LoadBitmap(IDB_BKBUTTON); Brush.CreatePatternBrush(&bmp); } else Brush.CreateSolidBrush( RGB( 200, 200, 200 ) ); dc.SetTextColor( RGB( 80, 80, 80) ); } else if( m_State == bsDown ) { Brush.CreateSolidBrush( RGB( 160, 160, 160 ) ); dc.SetTextColor( RGB( 50, 50, 250 ) ); } else if( m_State == bsHot ) { Brush.CreateSolidBrush( RGB( 100, 100, 180 ) ); dc.SetTextColor( RGB( 250, 250, 0 ) ); } pOldBrush = dc.SelectObject( &Brush ); pWnd->GetClientRect( &RC ); dc.RoundRect( &RC, PT ); HRGN hRgn = CreateRectRgn( RC.left, RC.top, RC.right, RC.bottom ); pWnd->SetWindowRgn( hRgn, TRUE ); DeleteObject( hRgn ); pWnd->GetWindowText(Text ); dc.DrawText( Text, &RC, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); dc.SelectObject( pOldFont ); dc.SelectObject( pOldBrush ); return TRUE; }
BOOL CPlayerStatusBar::OnEraseBkgnd(CDC* pDC) { for (CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) { if (!pChild->IsWindowVisible()) { continue; } CRect r; pChild->GetClientRect(&r); pChild->MapWindowPoints(this, &r); pDC->ExcludeClipRect(&r); } CRect r; GetClientRect(&r); CMainFrame* pFrame = ((CMainFrame*)GetParentFrame()); if (pFrame->m_pLastBar != this || pFrame->m_fFullScreen) { r.InflateRect(0, 0, 0, 1); } if (pFrame->m_fFullScreen) { r.InflateRect(1, 0, 1, 0); } pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); r.DeflateRect(1, 1); pDC->FillSolidRect(&r, 0); return TRUE; }
void CInteractionAreaDialog::CreateSlidePopup(int nAction, int nButtonId, int nEditId) { CRect rcButton; CWnd *pWndButton = GetDlgItem(nButtonId); pWndButton->GetClientRect(rcButton); pWndButton->ClientToScreen(&rcButton); m_wndMenu.CreatePopupMenu(); CArray<CPage *, CPage *> caPages; m_pEditorDoc->project.GetPages(caPages, 0, m_pEditorDoc->m_docLengthMs); for (int i = 0; i < caPages.GetSize(); ++i) { CString csPageTitle; csPageTitle = caPages[i]->GetTitle(); m_wndMenu.AppendMenu(MF_STRING, i+1, csPageTitle); } BOOL bRet = m_wndMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, rcButton.left, rcButton.bottom, this); CWnd *pEdit = GetDlgItem(nEditId); // if bRet is zero the menu was cancelled // or an error occured if (bRet != 0) { CString csItem; m_wndMenu.GetMenuString(bRet, csItem, MF_BYCOMMAND); pEdit->SetWindowText(csItem); m_nMarkOrPageId[nAction] = caPages[bRet-1]->GetJumpId(); } caPages.RemoveAll(); m_wndMenu.DestroyMenu(); }
void CPreviewView::CalcWindowRect(LPRECT lpClientRect) { CView::CalcWindowRect(lpClientRect); // The preview view is created with the WS_BORDER style, and when // the view is repositioned, these borders will by default be placed // outside the main monitor. If there are other monitors adjacent to // the main monitor, the border shows up on those monitors, which looks // sloppy. To prevent this we resize the window rect as necessary to // keep the borders inside the MDI parent frame window's client area. // Also note that we can't just get rid of the borders entirely because // this looks bad on a PowerBook where the edges of the screen are // white instead of black - if there aren't any borders, there's no // dividing line between the edge of the preview view's scrollbars // and the non-drawing areas of the screen. CWnd* pParent = GetParent(); if (pParent->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd))) { RECT rect; pParent->GetClientRect(&rect); if (lpClientRect->left < rect.left) lpClientRect->left = rect.left; if (lpClientRect->right > rect.right) lpClientRect->right = rect.right; if (lpClientRect->bottom > rect.bottom) lpClientRect->bottom = rect.bottom; // top not needed because it will be adjacent to the print // preview toolbar } }
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 CObjectRightView::OnSize(UINT nType, int cx, int cy) { SetScrollSizes( MM_TEXT, CSize(cx, cy) ); CFormView::OnSize(nType, cx, cy); if (initialized) { CRect rc; m_iWidth = cx; m_iHeight = cy; // Save static reference to the render window CWnd* pGroup = GetDlgItem(IDC_RENDERWINDOW); pGroup->SetWindowPos(NULL, 0, 0, cx, cy, SWP_NOZORDER); pGroup->GetClientRect(&rc); pGroup->MapWindowPoints(this, &rc); m_hwndRenderWindow = GetDlgItem(IDC_RENDERWINDOW)->GetSafeHwnd(); InitializeDevice(); InitializeDeviceBuffer(); Render(); } }
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); }
void CShowModelPanel::GetPanelSize(int &nWidth, int &nHeight) { CWnd *pDlgWnd = this; CRect rcPanel; ; pDlgWnd->GetClientRect(&rcPanel); nWidth = rcPanel.Width(); nHeight = rcPanel.Height(); }
void CUserOptions::addToolTip( int no, int id, CString str ) { CWnd* wnd = GetDlgItem( id ); CRect rect; wnd->GetClientRect( rect ); m_tToolTip[no].Create( wnd ); m_tToolTip[no].AddTool( wnd, str, rect, TOOLTIP_ID ); }
bool Project::InitEngine() { using namespace ld3d; CWnd* pWnd = util_get_rendering_wnd(); CRect rc; pWnd->GetClientRect(rc); int w = rc.Width(); int h = rc.Height(); m_pCore = CoreApiPtr(new CoreApi()); CoreApi::SetLogger(util_log_info); SysSetting setting; setting.graphics.sysMod = L"./d11graphics.dll"; setting.graphics.backBufferCount = 2; setting.graphics.depthStencilFormat = G_FORMAT_D24_UNORM_S8_UINT; setting.graphics.frameBufferFormat = G_FORMAT_R8G8B8A8_UNORM; setting.graphics.frameBufferHeight = h; setting.graphics.frameBufferWidth = w; setting.graphics.multiSampleCount = 1; setting.graphics.multiSampleQuality = 0; setting.graphics.windowed = true; setting.graphics.wnd = pWnd->m_hWnd; setting.input.sysMod = L""; setting.input.wnd = pWnd->m_hWnd; setting.sound.maxChannels = 100; setting.sound.sysMod = L"./fmod_sound.dll"; setting.physics.sysMod = L""; #ifdef _DEBUG if(false == m_pCore->Initialize(setting)) { return false; } #else if(false == s_pCore->Initialize(setting, &g_Allocator)) { return false; } #endif m_pCore->GetGameObjectManager()->LoadPackage(L"./extensions/ext_dt.dll"); m_pCore->GetGameObjectManager()->LoadPackage(L"./extensions/ext_voxel.dll"); m_pCore->GetRenderSystem()->SetClearColor(math::Color4(0.3f, 0.2f, 0.4f, 1.0f)); return true; }
// ============================================= // 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; }
void CaptureGraph::OnSize() { HWND hwnd; CWnd *pcwnd; CRect rect; mVideoWindow->get_Owner((OAHWND*)&hwnd); pcwnd=CWnd::FromHandle(hwnd); pcwnd->GetClientRect(&rect); mVideoWindow->SetWindowPosition(rect.left ,rect.top , rect.right ,rect.bottom ); }
/* * Set new child's configuration */ void CChildFrame::RememberChildConfiguration( INDEX iViewConfiguration) { INDEX i, j; // get client size CRect rectClient; GetClientRect( &rectClient); PIX pixClientWidth, pixClientHeight; pixClientWidth = rectClient.Width(); pixClientHeight = rectClient.Height(); // create reference to choosed view configuration CChildConfiguration &CC = theApp.m_ccChildConfigurations[ iViewConfiguration]; // look for numbers of vertical splitter windows CC.m_iVerticalSplitters = m_wndSplitter.GetColumnCount(); ASSERT( CC.m_iVerticalSplitters <= 2); // look for numbers of horizontal splitter windows CC.m_iHorizontalSplitters = m_wndSplitter.GetRowCount(); ASSERT( CC.m_iHorizontalSplitters <= 2); // here we will receive splitter's sizes int iCurWidth, iCurHeight; // get width and height of splitter windows CWnd *pWnd = m_wndSplitter.GetPane( 0, 0); CRect rectLU; pWnd->GetClientRect( &rectLU); iCurWidth = rectLU.Width(); iCurHeight = rectLU.Height(); // if window is splitted vericaly if( CC.m_iVerticalSplitters != 1) { // calculate percentages of left window CC.m_fPercentageLeft = ((FLOAT)iCurWidth)/pixClientWidth; } // if window is splitted horizontaly if( CC.m_iHorizontalSplitters != 1) { // calculate percentages of top window CC.m_fPercentageTop = ((FLOAT)iCurHeight)/pixClientHeight; } // remember grid on/off flag CC.m_bGridOn = m_bGridOn; // remember rendering preferences of all views for( j=0; j<CC.m_iVerticalSplitters; j++) { for( i=0; i<CC.m_iHorizontalSplitters; i++) { CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( j, i); ASSERT( pWEDView != NULL); CC.m_vpViewPrefs[ j*2 + i] = pWEDView->m_vpViewPrefs; CC.m_ptProjectionType[ j*2 + i] = pWEDView->m_ptProjectionType; } } }
UINT ThreadDraw(PVOID pParam) { static int snCount = 0; snCount++; TRACE(TEXT("- ThreadDraw %d: started...\n"), snCount); THREADINFO *pInfo = reinterpret_cast<THREADINFO *> (pParam); CWnd *pWnd = CWnd::FromHandle(pInfo->hWnd); CClientDC dc(pWnd); int x = pInfo->point.x; int y = pInfo->point.y; srand((UINT)time(NULL)); CRect rectEllipse(x - 25, y - 25, x + 25, y + 25); CSize sizeOffset(1, 1); CBrush brush(RGB(rand() % 256, rand() % 256, rand() % 256)); CBrush *pOld = dc.SelectObject(&brush); while (WAIT_TIMEOUT == ::WaitForSingleObject(g_eventEnd, 0)) { CRect rectClient; pWnd->GetClientRect(rectClient); if (rectEllipse.left < rectClient.left || rectEllipse.right > rectClient.right) { sizeOffset.cx *= -1; } if (rectEllipse.top < rectClient.top || rectEllipse.bottom > rectClient.bottom) { sizeOffset.cy *= -1; } dc.FillRect(rectEllipse, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH))); rectEllipse.OffsetRect(sizeOffset); dc.Ellipse(rectEllipse); Sleep(25); } dc.SelectObject(pOld); delete pInfo; TRACE(TEXT("- ThreadDraw %d: exiting.\n"), snCount--); return 0; }
LRESULT CDlgAddItem::OnCaptureLBtnUp( WPARAM wParam, LPARAM lParam ) { // 根据坐标获取窗体 [7/10/2014 Brilliance] POINT pot; GetCursorPos(&pot); CWnd* pWnd = WindowFromPoint(pot); // 获取标题 [7/10/2014 Brilliance] pWnd->GetWindowText(m_csTitle); // 获取类名 [7/10/2014 Brilliance] TCHAR sClass[128] = {0}; GetClassName(pWnd->GetSafeHwnd(), sClass, sizeof(sClass)/sizeof(TCHAR)); m_csClass = sClass; // 获取大小 [7/10/2014 Brilliance] CRect rt; pWnd->GetClientRect(&rt); ClientToScreen(&rt); //m_csRect.Format(_T("(%d,%d),%d*%d"), rt.left, rt.top, rt.Width(), rt.Height()); m_csRect.Format(_T("%d,%d"), rt.Width(), rt.Height()); // 获取进程ID [7/10/2014 Brilliance] DWORD dwProcessId = 0; GetWindowThreadProcessId(pWnd->GetSafeHwnd(), &dwProcessId); m_csProcessId.Format(_T("%d"), dwProcessId); // 获取进程名 [7/10/2014 Brilliance] HANDLE hProcess = OpenProcess(/*PROCESS_ALL_ACCESS*/PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, dwProcessId); TCHAR sProcessName[MAX_PATH] = {0}; TCHAR sProcessPath[MAX_PATH] = {0}; if (NULL != hProcess ) { HMODULE hMod; DWORD cbNeeded; if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) ) { GetModuleBaseName( hProcess, hMod, sProcessName, sizeof(sProcessName)/sizeof(TCHAR) ); GetModuleFileName(hMod, sProcessPath, sizeof(sProcessPath)/sizeof(TCHAR)); } } m_csProcessName = sProcessName; m_csProcessPath = sProcessPath; // 获取线程ID [7/10/2014 Brilliance] // DWORD dwThreadId = 0; // dwThreadId = GetThreadId(pWnd->m_hWnd); CString csText; csText.Format(_T("左键弹起,x=%d,y=%d,Title:%s,Class:%s\r\n"), pot.x, pot.y, m_csTitle, m_csClass); TRACE(csText); //m_csOutput = m_csOutput + csText; //UpdateData(FALSE); UpdateData(FALSE); return 0; }
void CFileAndFolder::resizeControls() { if (!IsWindow(m_hWnd)) return; CRect crect,trect,okrect,cancelrect,msgrect,refresh; GetClientRect(crect); if (!IsWindow(m_Tree.m_hWnd)) return; m_Tree.GetClientRect(trect); CWnd * wok = GetDlgItem(IDOK); CWnd * c*k = GetDlgItem(IDCANCEL); m_Msg.GetClientRect(msgrect); CWnd * wnd = GetDlgItem(IDC_REFRESH_DRIVES); wnd->GetClientRect(refresh); wok->GetClientRect(okrect); int okh = okrect.Height(); int okw = okrect.Width(); trect = crect; trect.top = trect.top + (msgrect.Height() + 10 + refresh.Height() + 10); trect.bottom -= (okh + 10); m_Tree.MoveWindow(trect,TRUE); int okx = ((crect.Width() - (okw * 3)) / 2); okrect.left = okx; okrect.right = okrect.left + okw; okrect.top = trect.bottom + 5; okrect.bottom = okrect.top + okh; wok->MoveWindow(okrect,TRUE); cancelrect = okrect; cancelrect.left = okrect.left + (okrect.Width() * 2); cancelrect.right = cancelrect.left + okrect.Width(); c*k->MoveWindow(cancelrect,TRUE); }
BOOL CEnrollDlg::OnInitDialog() // 每次DoModal之前都会执行 { CDialog::OnInitDialog(); faceSz = g_faceMngr->m_faceSz; showSz = faceSz; if (showSz.height != 160) // (160*130)是预定显示大小,如果归一化大小不是则进行调整 showSz *= (160.0/showSz.height); if (showSz.width > 130) showSz *= (130.0/showSz.width); EmbedCvWindow(GetDlgItem(IDC_FACE)->m_hWnd, "face", showSz.width, showSz.height); if (noface) cvShowImage("face", noface); RECT rc; GetWindowRect(&rc); SetWindowPos(NULL, rc.left + 15, rc.top + 300, 0,0, SWP_NOSIZE | SWP_NOZORDER); m_nShootNum = 0; m_strName = ""; UpdateData(FALSE); CWnd *pBtn = GetDlgItem(IDC_SHOOT); RECT rc1; pBtn->GetClientRect(&rc1); pBtn->SetWindowText("拍摄"); pBtn->SetWindowPos(NULL, 0,0, 35, rc1.bottom-rc1.top, SWP_NOMOVE | SWP_NOZORDER); GetDlgItem(IDC_DEL_SHOOT)->ShowWindow(SW_HIDE); GetDlgItem(IDC_ENROLL_PIC)->ShowWindow(SW_SHOW); GetDlgItem(IDC_IMPORT_MODELS)->ShowWindow(SW_SHOW); if (g_bHasWebcam) { m_frame = cvCreateImage(g_webcam.GetFrameSize(), IPL_DEPTH_8U, 3); SetDlgItemText(IDC_SHOOT_GUIDE, "若要从摄像头注册,请等画面较正时点“拍摄”。\n" "如果画面定住,说明人脸检测及对准未成功,请改善姿势、光照。\n" "为保证识别率,建议以正常表情拍摄3~4张。"); m_bFaceStarted = true; m_thrdFace = ::AfxBeginThread(ShowFaceProc, this); } else { m_frame = NULL; SetDlgItemText(IDC_SHOOT_GUIDE, ""); CWnd *pWnd = GetDlgItem(IDC_SHOOT); pWnd->EnableWindow(FALSE); } return TRUE; }
// CHANGE! 04/03/97 John Moore // First create the tab bar and initialize the tab controls... BOOL CMainFrame::CreateTabBar() { if (!m_wndTabBar.Create(this, IDD_TABDIALOG, WS_CHILD | CBRS_RIGHT | CBRS_TOOLTIPS | CBRS_FLYBY, IDD_TABDIALOG) ) { TRACE0("Failed to create tab bar\n"); return FALSE; // fail to create } // Create the property sheet and its pages... m_wndTabControls = new CFusionTabControls( &m_wndTabBar ); // Now set the area for our tabs... RECT rect; CWnd* WndPtr = m_wndTabBar.GetDlgItem( IDC_GROUP1 ); WndPtr->GetClientRect( &rect ); if (!m_wndTabControls->Create( WS_CHILD|WS_VISIBLE|TCS_MULTILINE, rect, &m_wndTabBar, 0 )) { TRACE0( "CFusionTabControls: Create(...) Failed\n" ); return FALSE; } TabFont.CreateFont ( 12, 0, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "MS Sans Serif" ) ; m_wndTabControls->SetFont( &TabFont ) ; // Now let's set the position of our tabs... WINDOWPLACEMENT WndPlace; WndPtr->GetWindowPlacement( &WndPlace ); m_wndTabControls->SetWindowPos( NULL, WndPlace.rcNormalPosition.left, WndPlace.rcNormalPosition.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER ); m_wndTabControls->m_WindowPlacement = WndPlace; m_wndTabControls->CreateTabs(); return TRUE; }
void CStaffManageView::ClearPhotoView() { CWnd *pPictureWnd = GetDlgItem(IDC_STATIC_PHOTO); if (!pPictureWnd) return; CRect rect; pPictureWnd->GetClientRect(rect); CDC *pDC = pPictureWnd->GetDC(); CBrush brush(RGB(255,255,255)); CBrush * pOldBrush = (CBrush*)pDC->SelectObject(&brush); pDC->Rectangle(rect); pDC->SelectObject(pOldBrush); }
BOOL MyMFCDialog::OnInitDialog() { CDialog::OnInitDialog(); // we need to read in the photoshop data for our proxy view CWnd* pWnd = GetDlgItem(IDC_PROXY); if (pWnd == NULL) throw((char*)"No pWnd in MyMFCDialog::OnInitDialog()"); pWnd->GetClientRect(&m_ProxyRect); SetupFilterRecordForProxy(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }