Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CListBox items based on dialog resources.

12 views
Skip to first unread message

Beaumont@discussions.microsoft.com Louis-Pierre Beaumont

unread,
Nov 3, 2009, 11:35:01 AM11/3/09
to
Hello,

I would like to know if it is possible to customize a CListBox to base it's
items on child dialog resources (like CPaneDialog does, or better, like
ListBox ItemDataTemplate in WPF).

I find custom draw or owner draw too painfull to implement, and hard to
extend and reuse.

Regards,

Louis-Pierre Beaumont

Tom Serface

unread,
Nov 3, 2009, 6:15:16 PM11/3/09
to
I'm not sure exactly what you're looking for, but perhaps an article like:

http://www.codeproject.com/KB/combobox/xlistbox.aspx
http://www.codersource.net/mfc_clistbox_owner_draw_picture.html

Could help get you started...

Tom

"Louis-Pierre Beaumont" <Louis-Pierre Beau...@discussions.microsoft.com>
wrote in message news:216F03AA-57FF-44F8...@microsoft.com...

Joseph M. Newcomer

unread,
Nov 3, 2009, 8:25:27 PM11/3/09
to
Well, I find custom draw/owner draw rather trivial most of the time. Once you get the
template for doing it, you just repeat-as-necessary. Getting the template right the first
time can be a struggle, but I've basically written only one owner-draw listbox/combobox,
and find copy-and-paste a fine technology for dealing with it.

That said, you can put child controls in a listbox; I've done it several times. It is a
bit tricky, and a bit painful, and a good deal more painful than owner-draw nearly all the
time.

The trick is partly in designating the listbox as a control parent (WS_EX_CONTROLPARENT),
and partly in how you handle the messages from the children. Alas, most of the code I
have that does this is proprietary and I can't give out samples. You have to do a lot of
SetWindowPos calls to handle the scrolling. But it is doable; I've put edit controls,
radio buttons, check boxes, and combo boxes into list boxes.

But I'm not sure a listbox is your best choice. Using a grid control might be a better
choice because these features are built into grid controls. So I'd look into a grid
control instead of trying to re-invent the technique (my technique was invented in the
late 1990s)
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Tom Serface

unread,
Nov 3, 2009, 8:59:55 PM11/3/09
to
It's also really easy to put controls into "cells" in list controls. There
are tons of examples of doing it. A grid is more geared toward doing this,
but more trouble to manage as well.

I wasn't exactly sure what OP was looking for ...

As you know, but for OPs benefit in case they are reading this post as well,
there are tons of articles on extending or adding controls to the CListCtrl,
for example:

http://www.codeproject.com/KB/list/Extended_List_Control.aspx

Tom

"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:fll1f59vddimpeo2b...@4ax.com...

Louis-Pierre Beaumont

unread,
Nov 5, 2009, 7:30:03 AM11/5/09
to
Thanks you for the links Tom,

I already found the second one you gave me. For now, thats what im doing.
But i would really like an "easy way" to integrate dialogs into listboxes.

Thank you :)

Louis-Pierre Beaumont

unread,
Nov 5, 2009, 7:36:01 AM11/5/09
to
Thank you Joseph,

That answers my question. Im going to use a grid instead of a Listbox as you
advised. I really don't want to handle repositioning + the repainting the
controls myself.

"Joseph M. Newcomer" wrote:

> .
>

Louis-Pierre Beaumont

unread,
Nov 5, 2009, 7:39:01 AM11/5/09
to
Wow Tom,

That sample exactly doest what i want to do, it hosts a CDialog into a cell!
:)

Thank you for all this precious help!


"Tom Serface" wrote:

> .
>

0 new messages