A better CXTResizeFormView (code inside) |
Post Reply |
Author | |
ddyer
Groupie Joined: 01 December 2003 Location: United States Status: Offline Points: 40 |
Post Options
Thanks(0)
Posted: 09 December 2003 at 8:35am |
Im the last person to write better MFC code than these gurus, but I think this is probably an underutilized class so it fell through the cracks. The problem:
Now, slowly enlarge the window to the right until the horizontal scroll bar is no longer needed. VOOM! The form suddenly enlarged to fill the window. 1) Add two protected fields to your formview class: int lastCx, lastCy. Initialize them to 0 in your creation method. 2) Create an OnSize message handler that has two lines of code: CFormView::OnSize(nType, cx, cy); 3) Go to the CXTResize source code and add the following static method into your cpp file: static bool _IsGroupBox(HWND hWnd) 5) The following changes need to be made to the FormSize method:
Just AFTER the line "int dx = rcWindow.Width() - m_rcWindow.Width();" add if (cx < m_totalLog.cx) dx = 0;
Just AFTER the line "int dy = rcWindow.Height() - m_rcWindow.Height();" add if (cy < m_totalLog.cy) dy = 0;
Just PRIOR to the line "m_rcWindow = rcWindow;" add the following: if (cx >= m_totalLog.cx && cy >= m_totalLog.cy) { lastCx = cx;
Now resize the window as mentioned earlier. There are still problems if the formview is a tabbed view and it is not the active window, the window gets resized, then the view is made active. But its much better than before. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |