• Advertisement

Archived

This topic is now archived and is closed to further replies.

CListCtrl preparations

This topic is 5730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there any way to fill a CListCtrl class with it''s list, before it appears on screen? There seems to be an ASSERT(::IsWindow(m_hWnd)) at every turn, which aside from being inconvenient is really damned annoying.

Share this post


Link to post
Share on other sites
Advertisement
That ensures the window handle is valid - it doesn''t have to be visible for that to hold true.

There may be an optional parameter to control whether it''s visible or not upon construction.

There should also be a ->ShowWindow(SW_HIDE) method.

Share this post


Link to post
Share on other sites
Hmmm. Re reading my post it does seem a little vague...

(assume) I have a dialog assigned to CDlgClass. It contains a CListCtrl with ID IDC_FILELIST. It is assigned (through the class wizard) to have a member variable (control) of type CListCtrl called fileList.

So in another function I call the Dialog as so:

{
CDlgClass myDlg;
int result = myDlg.DoModal();
}

which has no problems. However, if i try to initialise the list so it contains some data to begin with, as follows:

{
CDlgClass myDlg;
myDlg.fileList.InsertColumn(0, "First Col");
myDlg.fileList.InsertItem(0, "Blah");
int result = myDlg.DoModal();
}

the program fails in one of the ASSERT''s becuase m_hwnd of the CListCtrl is 0x0. (ie NULL)

Is there any way to navigate around this apparent shortfall?


- Magmai Kai Holmlor: The window is visible by default, but the dialog not shown (as it is through a DoModal()) yet.

Thanks,
TheHermit

Share this post


Link to post
Share on other sites
you can't operate on a control before it is created. move the init code into WM_INITDIALOG handler for your dialog, at which point the dialog and controls already exist but are not yet visible.

edit: i believe dialog's constructor won't create the dialog (in mfc generally constructors seldom create things). DoModal will not only run a modal loop for the dialog, that call will also set up and tear down the dialog before showing it.

[edited by - niyaw on August 14, 2002 4:04:31 AM]

Share this post


Link to post
Share on other sites
niyaw - Responding to the suggestion of WM_IN...

It worked. For columns. Right up until I tried to put any data into the table.

Turns out somebody (curse) had (curse) changed (curse) a property in the dialog properties. For no reason (curse).

Anyway, now fixed, Thanks for the help...

Share this post


Link to post
Share on other sites

  • Advertisement