Solved

Resize Control (for Answers2000)

Posted on 1999-01-21
2
305 Views
Last Modified: 2013-11-20
Dear Answers2000,

I have used the method suggested by you to resize each component in the dialog before.

void CMyFormView::OnSize(UINT nType, int cx, int cy)
{
   CFormView::OnSize(nType, cx, cy);

   CRect rcClient;
   GetClientRect(&rcClient);

   CRect rcListCtrl;
   m_list1.GetWindowRect(&rcListCtrl);           ScreenToClient((LPPOINT)(&rcListCtrl.left));
   ScreenToClient((LPPOINT)(&rcListCtrl.right));
 m_list1.MoveWindow(rcListCtrl.left,rcListCtrl.top,rcClient.right-rcListCtrl.left-10,rcClient.bottom-rcListCtrl.top);


}

When I was running my application in debug mode, the assertion fail occured:

_AFXWIN_INLINE void CWnd::GetWindowRect(LPRECT lpRect) const
{ ASSERT(::IsWindow(m_hWnd)); ::GetWindowRect(m_hWnd, lpRect); }

But there is no problem in resizing the listCtrl in release mode. What is the reason about this?

Thanks!!!
0
Comment
Question by:kkuu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
piano_boxer earned 70 total points
ID: 1328102
OnSize() is initially called *before* any childwindows are created.

Modify as follows:

void CMyFormView::OnSize(UINT nType, int cx, int cy)
{
   CFormView::OnSize(nType, cx, cy);

   if(::IsWindow(m_list1.m_hWnd)
   {
      CRect rcClient;
      GetClientRect(&rcClient);

      CRect rcListCtrl;
      m_list1.GetWindowRect(&rcListCtrl);      ScreenToClient((LPPOINT)(&rcListCtrl.left));
      ScreenToClient((LPPOINT)(&rcListCtrl.right));
      m_list1.MoveWindow(rcListCtrl.left,rcListCtrl.top,rcClient.right-rcListCtrl.left-10,rcClient.bottom-rcListCtrl.top);
   }
}
 
0
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1328103
Sorry missed a ending brace:

if(::IsWindow(m_list1.m_hWnd)

Change to:

if(::IsWindow(m_list1.m_hWnd))
{
   [....]
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question