Re: Display a CListCtrl in a CScrollView
From: Scott McPhillips [MVP] (org-dot-mvps-at-scottmcp)
Date: 08/26/04
- Next message: Andrew Fedoniouk: "Re: XP Theme tab pane color scheme"
- Previous message: Joseph M. Newcomer: "Re: How to close app and reopen it again"
- In reply to: Richard Rauch: "Display a CListCtrl in a CScrollView"
- Next in thread: Richard Rauch: "Re: Display a CListCtrl in a CScrollView"
- Reply: Richard Rauch: "Re: Display a CListCtrl in a CScrollView"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 25 Aug 2004 19:17:01 -0500
Richard Rauch wrote:
> Hello All,
>
> I created a CScrollView (as pane from a CSplitterWnd, perhaps that's the
> problem?)
> In this view, I want to display a CListCtrl. But the ListCtrl is not
> displayed. Why not?
> Perhaps the nID in the Create Call is the problem, I do not unterstand, what
> the parameter is for!
>
> I wrote this code:
>
> void CPaneView::OnInitialUpdate()
> {
> CScrollView::OnInitialUpdate();
> CSize sizeTotal;
> // TODO: calculate the total size of this view
> sizeTotal.cx = sizeTotal.cy = 100;
> SetScrollSizes(MM_TEXT, sizeTotal);
>
> CListCtrl m_List;
>
> CRect rect(0,0,sizeTotal.cx,sizeTotal.cy);
> m_List.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_LIST,rect,this,1);
>
> LV_COLUMN lvC;
> lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
> // Insert Columns and Items
> .....
> m_List.ShowWindow(SW_SHOW);
>
>
It looks like you are doing the wrong thing and doing it the wrong way.
The "wrong way" part is that your m_List object is created on the
stack. Therefore it will be destroyed when OnInitialUpdate returns. To
make this work m_List will have to be a member variable.
But you almost certainly should to use CListView or CFormView instead of
CScrollView. Use CFormView if you want the list at a fixed size, and/or
if you want to put other controls on this view. Use CListView if you
want the list to fill the view pane when things are resized. In either
case, the list control will be created for you by the view: You don't
need to create it dynamically.
The nID parameter is the control's ID. When the control sends you
messages they include the control's ID. That is how your code (or MFC's
class wizard and message map) will know which control the message came from.
-- Scott McPhillips [VC++ MVP]
- Next message: Andrew Fedoniouk: "Re: XP Theme tab pane color scheme"
- Previous message: Joseph M. Newcomer: "Re: How to close app and reopen it again"
- In reply to: Richard Rauch: "Display a CListCtrl in a CScrollView"
- Next in thread: Richard Rauch: "Re: Display a CListCtrl in a CScrollView"
- Reply: Richard Rauch: "Re: Display a CListCtrl in a CScrollView"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|