Reusing a dialog box
snkavuri@amoco.com
Thursday, January 04, 1996
A couple of questions:
(1) I have a dialog box that has list boxes with a *lot* of entries.
It takes time to create and display them. In X (Xt) I could
manage and unmanage the dialog box and reuse it. Can we do this
in Windows too ? Is there a nice way to do this in MFC (using
VC++ framework) ?
(2) I have an arrangement of control elements that repeats in
many dialog boxes. I wish to create a class which encapsulates
the behavior of this arrangement. It is not clear, however,
how I can do this nicely in the dialog box editor ? At the
time of creation of the dialog box, what does it need to know
about the control elements in the arrangement ?
Thanks
Surya N. Kavuri
dhylands@creo.bc.ca
Thursday, January 04, 1996
[Mini-digest: 3 responses]
> A couple of questions:
>
> (1) I have a dialog box that has list boxes with a *lot* of entries. It takes
> time to create and display them. In X (Xt) I could
> manage and unmanage the dialog box and reuse it. Can we do this in Windows
> too ? Is there a nice way to do this in MFC (using VC++ framework) ?
You could create an owner-draw listbox. Then you would have some underlying data
structure which you shared between the ListBox controls on the various dialogs.
I think that you still need to add elements individually though. You should make
sure that the ListBox redraw is turned off while adding the items, and then when
you turn it on you have to invalidate the listbox window (if memory serves me
correctly). If you really need the extra performance you'll prbably need to
implement your own custom control which can read your data structure without
having to add the items individually. Once you've got the owner-draw part
happening you've already done alot of the work.
> (2) I have an arrangement of control elements that repeats in many dialog
> boxes. I wish to create a class which encapsulates the behavior of this
> arrangement. It is not clear, however, how I can do this nicely in the dialog
> box editor ? At the time of creation of the dialog box, what does it need to
> know about the control elements in the arrangement ?
You can do this by using "Dynamic" dialogs. These are basically windows where
you add the controls after the fact. I used dialog resources as templates for
where the controls would go and then read the template myself and constructed
the windows (controls) as part of creating the dialog. This works pretty slick,
although there is some effort required to get it all working properly.
> Thanks
>
> Surya N. Kavuri
Dave Hylands Email: (dhylands@creo.bc.ca) 3700 Gilmore Way
Software Developer Tel: (604) 451-2700 (ext. 2329) Burnaby B.C. (Canada)
CREO Products Inc. Fax: (604) 437-9891 V5G 4M1
-----From: bibhas@hermes (Bibhas Bhattacharya)
Content-Type: text/plain; charset=US-ASCII
| Вернуться в корень Архива
|