Make a CListCtrl expand with window size

I've got an MDI app with 1 main view and a bunch of others possible.  In these other views, I am reading the contents of database files and presenting it to the user.  When I create these views in VC++, I get most of the records to fit.  The problem is when the user resizes the window, the list control stays the same size.

I have tried an OnSize function, but this causes my app to crash whenever it is encountered:

{
CFormView::OnSize(nType, cx, cy);
      
CRect rect;
GetClientRect(rect);
m_Table.SetWindowPos(&wndTop, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_SHOWWINDOW);

}

I'm not sure where this &wndTop comes from, but it causes an assert exception everytime.

Anyone have any ideas?  All I really want to do is have the list control increase in size with the window, since this is the only control in the view.
kmurphy99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kmurphy99Author Commented:
Edited text of question.
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Do this
if(m_OfflineList.m_hWnd)
{
CRect mrect;
m_OfflineList.GetWindowRect(&mrect);
ScreenToClient(&mrect);
            m_OfflineList.SetWindowPos(&m_OfflineList.wndTop,10,mrect.top,cx-115, cy-85,SWP_SHOWWINDOW |SWP_NOZORDER);
}

here m_OfflineList is the CListCtrl object associated with GUI.

It is crashing as u r not checking for m_OfflineList.m_hWnd exists or not.

Hope this helps.
VinExpert
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vinayak KumbarSr Program ManagerCommented:
Hi,

here I have done some maths in doing cx-115 king of stuff, u can insert ur own logic to set the width and height of the list control.

Cheers,
VinExpert
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

kmurphy99Author Commented:
Thanks for the fast response.  I found that this will work too.

if( NULL != m_Table.GetSafeHwnd())
   m_Table.SetWindowPos(&wndTop, 0, 0,
          rect.right, rect.bottom,
          SWP_SHOWWINDOW);


Which, in your opinion would be considered more acceptable by say a college professor?
0
kmurphy99Author Commented:
Thanks for the fast response.  I found that this will work too.

if( NULL != m_Table.GetSafeHwnd())
   m_Table.SetWindowPos(&wndTop, 0, 0,
          rect.right, rect.bottom,
          SWP_SHOWWINDOW);


Which, in your opinion would be considered more acceptable by say a college professor?
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

That means u r a college professor?(simply guessing ;-)).

VinExpert
0
kmurphy99Author Commented:
Far from it.  Coding for a project in school -- I need to get every point possible.
0
kmurphy99Author Commented:
Far from it.  Coding for a project in school -- I need to get every point possible.
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Oh, With that kind of experience, who knows !!!. What all u can be?(Now it is Ur turn to Guess!!!).

VinExpert

 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.