Solved

Resize Control (for Answers2000)

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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 55
How to know only "File created" with EventLog 3 35
sumNumber challenge 16 140
pre4 challenge 19 110
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

763 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