GetWindowRect problem in CFormView::OnInitialUpdate()
-
void CMyView::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); RECT rect; GetWindowRect(&rect); // rect.top is 227 } void CMyView::OnBnClickedBtnTest() { RECT rect; GetWindowRect(&rect); // rect.top is 30, why? }
After OnInitialUpdate() until I clicked test button(run OnBnClickedBtnTest() ), nothing to do. -
void CMyView::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); RECT rect; GetWindowRect(&rect); // rect.top is 227 } void CMyView::OnBnClickedBtnTest() { RECT rect; GetWindowRect(&rect); // rect.top is 30, why? }
After OnInitialUpdate() until I clicked test button(run OnBnClickedBtnTest() ), nothing to do. -
void CMyView::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); RECT rect; GetWindowRect(&rect); // rect.top is 227 } void CMyView::OnBnClickedBtnTest() { RECT rect; GetWindowRect(&rect); // rect.top is 30, why? }
After OnInitialUpdate() until I clicked test button(run OnBnClickedBtnTest() ), nothing to do.Hi, The MSDN says that "The GetWindowRect function retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen." So may be(am not sure) the window is created (0,0) as top left. Then it is moved to new Co Ordinates When it is displayed. that is why you are getting different co ordinates. My suggestion is that no need to bother about this co ordinates u just use rect. top, rect.left etc. so that your drawing or anything will positioned based on the parent window. thanks Nitheesh