• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

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.
0
kmurphy99
Asked:
kmurphy99
  • 5
  • 4
1 Solution
 
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
 
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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
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

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now