Solved

Resize Control (for Answers2000)

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 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

16 Experts available now in Live!

Get 1:1 Help Now