Solved

Resize Control (for Answers2000)

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 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.

808 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