Solved

Resize Control (for Answers2000)

Posted on 1999-01-21
2
292 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now