Resizing a CListBox>>>>>>>>>>>>>>>>>>>>>>>>>>>

Resizing a CListBox>>>>>>>>>>>>>>>>>>>>>>>>>>>

Post by bang.. » Thu, 25 Nov 1993 04:58:05



I have created a CListBox on a view...Now how can I make the listbox always
cover the entire client area of the view, even on resizing.

At the moment im overriding OnSize:-

void CMyView::OnSize(UINT nType, int cx, int cy)
{
        myListBox.MoveWindow(0,0,cx,xy,TRUE);

Quote:}

It doesnt do the trick. Help!!

--
================================================================================
Mr Abtar Bangar          | EMAIL ADDRESS:       |

Southbank University     |                      |  something about EVERYTHING
103 Borough Road         |                      |      but definately not    
LONDON SE1 0AA           |                      |  EVERYTHING about something'
United Kingdom.          |                      |
================================================================================

 
 
 

Resizing a CListBox>>>>>>>>>>>>>>>>>>>>>>>>>>>

Post by Phillip Coop » Wed, 08 Dec 1993 03:44:01



>I have created a CListBox on a view...Now how can I make the listbox always
>cover the entire client area of the view, even on resizing.

>At the moment im overriding OnSize:-

>void CMyView::OnSize(UINT nType, int cx, int cy)
>{
>    myListBox.MoveWindow(0,0,cx,xy,TRUE);
>}

>It doesnt do the trick. Help!!

One problem is that you are not calling the base class implementation
of CView::OnSize().

Another potential problem here is that a view can recieve WM_SIZE
messages before the controls located on it are created.  I usually
work around this by doing something like:

void CMyView::OnSize(UINT nType, int cx, int cy)
{

        CView::OnSize(nType, cx, cy);

        if (myListBox.GetDlgCtrlID())
        {
                CRect ClientRect;
                GetClientRect(&ClientRect);
                myListBox.MoveWindow(ClientRect, TRUE);
        }

Quote:}

Hope this helps!
Phil
--
===================================================================
Phillip Cooper                 Microsoft Developer Support Services
These opinions are mine alone.  I am *not* speaking for Microsoft.