Discussion:
Virtual list control
(too old to reply)
Ronny
2010-01-04 20:56:52 UTC
Permalink
Hello,

I'm creating virtual list control in CWnd and CDialog class ( using the same
way to create virtual list control and
message handling for LVN_GETDISPINFO notification ).
I use ON_NOTIFY(LVN_GETDISPINFO, IDC_LISTCTRL, OnGetDispInfo) to handle the
message notification.

The LVN_GETDISPINFO works fine in CWnd class ( notification received ) but
never received in CDialog class.

Any help would be greatly appreciated.


Thanks.
Ronny.
AliR
2010-01-04 22:04:14 UTC
Permalink
As far as I know there is nothing different between putting a virtual list
control on a CWnd and CDialog.

Are you sure your message handler is correct?

ON_NOTIFY(LVN_GETDISPINFO, IDC_LIST, OnGetdispinfoList)

AliR.
Post by Ronny
Hello,
I'm creating virtual list control in CWnd and CDialog class ( using the
same way to create virtual list control and
message handling for LVN_GETDISPINFO notification ).
I use ON_NOTIFY(LVN_GETDISPINFO, IDC_LISTCTRL, OnGetDispInfo) to handle
the message notification.
The LVN_GETDISPINFO works fine in CWnd class ( notification received ) but
never received in CDialog class.
Any help would be greatly appreciated.
Thanks.
Ronny.
Ronny
2010-01-05 17:38:56 UTC
Permalink
Hi AliR, thanks for your response.

Yes, I'm sure my message handler is correct because after successfully
tested on a CWnd,
I putting the virtual list control code using copy-paste to a CDialog.

Ronny
Tom Serface
2010-01-06 18:43:28 UTC
Permalink
I use this sort of thing all the time and it works OK for me. Have you
tried setting up the list control in the dialog using the resource editor
rather than cut and past to see if maybe some setting is being done
automatically. As Ali says, it shouldn't make any difference who the parent
window is... to be honest I've only used them in views and dialogs.

Tom
Post by Ronny
Hello,
I'm creating virtual list control in CWnd and CDialog class ( using the
same way to create virtual list control and
message handling for LVN_GETDISPINFO notification ).
I use ON_NOTIFY(LVN_GETDISPINFO, IDC_LISTCTRL, OnGetDispInfo) to handle
the message notification.
The LVN_GETDISPINFO works fine in CWnd class ( notification received ) but
never received in CDialog class.
Any help would be greatly appreciated.
Thanks.
Ronny.
Ronny
2010-01-08 17:19:46 UTC
Permalink
Hi Tom, thanks for your response.

I have solve the problem.
I already do as your suggestion , create the virtual list control through
the resource editor , but it's not working.
Then, I try to move the control creation code from inside OnCreate message
handle into OnInitDialog message handle, and it's work !!!
Is it normal ? Or I doing something wrong ?

Ronny.
AliR
2010-01-08 17:59:28 UTC
Permalink
That is normal if you are creating your list control dynamically, all
control creation code should be called after CDialog::OnInitDialog is
called.

Why don't you simplya put a List Control on the dialog in the resource
editor and attach a variable to it?

AliR.
Post by Ronny
Hi Tom, thanks for your response.
I have solve the problem.
I already do as your suggestion , create the virtual list control through
the resource editor , but it's not working.
Then, I try to move the control creation code from inside OnCreate message
handle into OnInitDialog message handle, and it's work !!!
Is it normal ? Or I doing something wrong ?
Ronny.
Tom Serface
2010-01-08 18:09:02 UTC
Permalink
If you are creating the control using the resource editor (as a standard
control on a dialog) you shouldn't have to do any calls to Create because
that will be done automatically when the dialog template is loaded. If you
want to add a control that is not already on the dialog then you will have
to use that method. I would do the following:

1. Add a list control to your dialog.
2. Set up the virtual list control OnGetDispInfo() functionality.
3. Set up how you want each column to display on the control (what data is
put into each field).
4. Maintain the data separate from the control in its own object.

You can also set up the size of the list control based on the size of the
object array (where the actual data is stored) so that you don't have to add
anything to the list control (you just tell it how big it is) with the call:

http://msdn.microsoft.com/en-us/library/xb95w29a(VS.80).aspx

I think this is the easiest and most efficient way to work with a list
control.

Tom
Post by Ronny
Hi Tom, thanks for your response.
I have solve the problem.
I already do as your suggestion , create the virtual list control through
the resource editor , but it's not working.
Then, I try to move the control creation code from inside OnCreate message
handle into OnInitDialog message handle, and it's work !!!
Is it normal ? Or I doing something wrong ?
Ronny.
Ronny
2010-01-12 17:51:07 UTC
Permalink
I don't like to use resource editor because I don't know exactly the
mechanism of code execution and the code generated by visual studio.
Do you know where I can find more info about how the CDialog class work and
best practice using CDialog ?

Thanks for both of you ( AliR and Tom ) for explanation.

Ronny.
Tom Serface
2010-01-12 18:01:02 UTC
Permalink
You can find lots of articles about dialog box creation like:

http://functionx.com/visualc/controls/dialogbox.htm

But the workings are a little mysterious. However, that is part of the
beauty of MFC. You just create the resource in the resource editor and the
dialog manager code creates it from the template for you. I've never had a
problem with this mechanism and it allows you to set up a lot of things that
are maddening to do without it (like control ordering, positioning, etc.) I
would venture to guess that it's safe to say that most of the people using
MFC use this mechanism.

Tom
Post by Ronny
I don't like to use resource editor because I don't know exactly the
mechanism of code execution and the code generated by visual studio.
Do you know where I can find more info about how the CDialog class work
and best practice using CDialog ?
Thanks for both of you ( AliR and Tom ) for explanation.
Ronny.
Stephen Myers <""StephenMyers\"@">
2010-01-12 21:40:05 UTC
Permalink
Post by Tom Serface
http://functionx.com/visualc/controls/dialogbox.htm
But the workings are a little mysterious. However, that is part of the
beauty of MFC. You just create the resource in the resource editor and
the dialog manager code creates it from the template for you. I've
never had a problem with this mechanism and it allows you to set up a
lot of things that are maddening to do without it (like control
ordering, positioning, etc.) I would venture to guess that it's safe to
say that most of the people using MFC use this mechanism.
Tom
Post by Ronny
I don't like to use resource editor because I don't know exactly the
mechanism of code execution and the code generated by visual studio.
Do you know where I can find more info about how the CDialog class
work and best practice using CDialog ?
Thanks for both of you ( AliR and Tom ) for explanation.
Ronny.
I have to agree with Tom. If you're not using the resource editor,
you've missed out on a big part of MFC. A dialog design, starts with
the resource and you then add functionality as needed.

Steve
Ronny
2010-01-15 17:03:28 UTC
Permalink
Ok, thanks for sharing. I will try using resource editor in my next
application.

Ronny.
Post by Tom Serface
http://functionx.com/visualc/controls/dialogbox.htm
But the workings are a little mysterious. However, that is part of the
beauty of MFC. You just create the resource in the resource editor and
the dialog manager code creates it from the template for you. I've never
had a problem with this mechanism and it allows you to set up a lot of
things that are maddening to do without it (like control ordering,
positioning, etc.) I would venture to guess that it's safe to say that
most of the people using MFC use this mechanism.
Tom
Post by Ronny
I don't like to use resource editor because I don't know exactly the
mechanism of code execution and the code generated by visual studio.
Do you know where I can find more info about how the CDialog class work
and best practice using CDialog ?
Thanks for both of you ( AliR and Tom ) for explanation.
Ronny.
I have to agree with Tom. If you're not using the resource editor, you've
missed out on a big part of MFC. A dialog design, starts with the
resource and you then add functionality as needed.
Steve
Tom Serface
2010-01-15 23:46:14 UTC
Permalink
I think you will find that it will be a rewarding experience. It's not as
nice as the editor for WinForms (e.g., when using C#), but it has a lot of
advantages over doing it by hand.

That said, I seldom use the wizards to create events or variables. I may do
it once in a project to get one set up, but then I mostly do that coding by
hand. It's pretty easy to do with cut and paste.

Tom
Post by Ronny
Ok, thanks for sharing. I will try using resource editor in my next
application.
Ronny.
Post by Stephen Myers <""StephenMyers\"@">
Post by Tom Serface
http://functionx.com/visualc/controls/dialogbox.htm
But the workings are a little mysterious. However, that is part of the
beauty of MFC. You just create the resource in the resource editor and
the dialog manager code creates it from the template for you. I've
never had a problem with this mechanism and it allows you to set up a
lot of things that are maddening to do without it (like control
ordering, positioning, etc.) I would venture to guess that it's safe to
say that most of the people using MFC use this mechanism.
Tom
Post by Ronny
I don't like to use resource editor because I don't know exactly the
mechanism of code execution and the code generated by visual studio.
Do you know where I can find more info about how the CDialog class work
and best practice using CDialog ?
Thanks for both of you ( AliR and Tom ) for explanation.
Ronny.
I have to agree with Tom. If you're not using the resource editor,
you've missed out on a big part of MFC. A dialog design, starts with the
resource and you then add functionality as needed.
Steve
Loading...