dynamically build dialog box 
Author Message
 dynamically build dialog box

how can this be done in code. what i want to do is build a simple one
without using a static dialog resource, but by making a dialog template in
memory and creating the dialog itself. any code examples?


Wed, 09 Jul 2003 02:41:33 GMT  
 dynamically build dialog box
Search for examples using "DialogBoxIndirect" API  in vc++ help.

Cheers
Check Abdoul
-------------------


Quote:
> how can this be done in code. what i want to do is build a simple one
> without using a static dialog resource, but by making a dialog template in
> memory and creating the dialog itself. any code examples?



Wed, 09 Jul 2003 01:45:02 GMT  
 dynamically build dialog box
Must it be a dailog? It might be easier to make it a window using CWnd,
CFrameWnd or CMiniFrameWnd or such.


Quote:
> how can this be done in code. what i want to do is build a simple one
> without using a static dialog resource, but by making a dialog template in
> memory and creating the dialog itself. any code examples?



Wed, 09 Jul 2003 06:04:52 GMT  
 dynamically build dialog box
Why don't you want to use a dialog resource? 95% of the time I hear
someone object to using a dialog resource, they've missed a dozen
techniques of using one that would simply their lives. Yes, I've
created dialogs from templates, but the more I learn about Windows,
the less I do this (the last time I did it was when I wrote the dialog
box macros for Win32 Programming, now about 4 years ago). There's very
little you lose by using a dialog template, even an empty one, and
there's a lot of hassle using in-memory templates. Can you state what
you are trying to accomplish, and I may be able to suggest some better
ways of approaching the problem (although I'm going to be out of
contact for a week, so if it is a crisis I can't help much since I
won't be back on the newsgroup for a week or so).
                        joe

On Fri, 19 Jan 2001 18:41:33 -0000, "Martin Knott"

Quote:

>how can this be done in code. what i want to do is build a simple one
>without using a static dialog resource, but by making a dialog template in
>memory and creating the dialog itself. any code examples?

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Thu, 10 Jul 2003 15:58:38 GMT  
 dynamically build dialog box
first, thanks for your and the other replies.

i have about 20 applications that have been developed separately using "cut
and paste" development. this means there's lots of scope for factoring
common code into classes and reusing these classes in each application. one
of the classes that's replicated is the aboutbox. i realise that i could
create one CMyAbout class and reuse this in all the aps. i also considered
building it in memory though, since it's quite a simple class and there's no
complicated user interaction needed except having it close when the ok
button is pushed. this way the whole class is hidden from view and the apps
seem less complicated (marginally). i tried to use some code i got off the
web and it didn't work. the other poster has pointed me toward another
example which i wil try out later.

My reluctance to go down 'normal' route involving a dialog template and a
class htat calls it relates to a previous post of mine which has gone
unanswered. the other post relates to multi-language support. if you don't
mind, i'll re ask here because i've got some nagging doubts that i'm going
about it the wrong way which perhaps a fresh mindset might spot where:

POST BEGINS

subject: multi language support

i want to implement an app in variuos languages. so, i extracted all the
literals to a string table then copied this to several DLL projects, one for
each language. (then someone else translated them!) so, on app start i can
use afxsetresourcehandle to the right dll and the strings load fine using
mystring.loadstring(IDS_MYVALUE).

the problem is that as well as string resources, my project has other
resources that are not language dependent, for example bitmaps, icons and
dialogs. i'm faced with the following dillema. i can either:
1) make copies of the dialogs and place them in the same dll resource. this
means maintenance will be irksome becuase even minor cosmetic changes will
require changing x dialogs (x being num of languages)
2) i can keep the dialogs in the main aps' resources, declare another
resource handle
and swap back and forth between local resources and main resources at
runtime. this means introducing more code and constantly having to think
"which resources do i need for the following action?"

is there a good turorial on the web to give advice on such matters?

thanks in advance

martin

POST ENDS

I'm heading down route 2 at the moment and although i haven't hit any major
problems, i can't believe that there isn't more support for this kind of
things in vccp.

any thoughts would be much appreciated. also could you send them to:

much obliged,

martin

Quote:

> Joseph M. Newcomer [MVP]

> Web: http://www3.pgh.net/~newcomer
> MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm



Thu, 10 Jul 2003 20:08:45 GMT  
 dynamically build dialog box
Writing a generic about box is quite simple; in fact, I have a DDJ
article about it! Also, read my essay about subclassing dialog boxes.
Note that neither of these require constructing a template. Likewise
for internationalization; you don't have to construct the template in
memory; you can just set the strings you want, or clone the dialog,
either one. For example, if you put the strings in a DLL with the same
IDs as the controls, then a simple loop which iterates over the child
controls, doing a LoadString based on the dialog control ID, can
locate all the strings that need to be substituted (any control which
doesn't need substitution won't have a corresponding string).
                                joe

On Sun, 21 Jan 2001 12:08:45 -0000, "Martin Knott"

Quote:

>first, thanks for your and the other replies.

>i have about 20 applications that have been developed separately using "cut
>and paste" development. this means there's lots of scope for factoring
>common code into classes and reusing these classes in each application. one
>of the classes that's replicated is the aboutbox. i realise that i could
>create one CMyAbout class and reuse this in all the aps. i also considered
>building it in memory though, since it's quite a simple class and there's no
>complicated user interaction needed except having it close when the ok
>button is pushed. this way the whole class is hidden from view and the apps
>seem less complicated (marginally). i tried to use some code i got off the
>web and it didn't work. the other poster has pointed me toward another
>example which i wil try out later.

>My reluctance to go down 'normal' route involving a dialog template and a
>class htat calls it relates to a previous post of mine which has gone
>unanswered. the other post relates to multi-language support. if you don't
>mind, i'll re ask here because i've got some nagging doubts that i'm going
>about it the wrong way which perhaps a fresh mindset might spot where:

>POST BEGINS

>subject: multi language support

>i want to implement an app in variuos languages. so, i extracted all the
>literals to a string table then copied this to several DLL projects, one for
>each language. (then someone else translated them!) so, on app start i can
>use afxsetresourcehandle to the right dll and the strings load fine using
>mystring.loadstring(IDS_MYVALUE).

>the problem is that as well as string resources, my project has other
>resources that are not language dependent, for example bitmaps, icons and
>dialogs. i'm faced with the following dillema. i can either:
>1) make copies of the dialogs and place them in the same dll resource. this
>means maintenance will be irksome becuase even minor cosmetic changes will
>require changing x dialogs (x being num of languages)
>2) i can keep the dialogs in the main aps' resources, declare another
>resource handle
>and swap back and forth between local resources and main resources at
>runtime. this means introducing more code and constantly having to think
>"which resources do i need for the following action?"

>is there a good turorial on the web to give advice on such matters?

>thanks in advance

>martin

>POST ENDS

>I'm heading down route 2 at the moment and although i haven't hit any major
>problems, i can't believe that there isn't more support for this kind of
>things in vccp.

>any thoughts would be much appreciated. also could you send them to:

>much obliged,

>martin

>> Joseph M. Newcomer [MVP]

>> Web: http://www3.pgh.net/~newcomer
>> MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Thu, 17 Jul 2003 07:55:42 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Problems with List box in dynamically created dialog box

2. Problems with List box in dynamically created dialog box

3. Modeless dialog boxes in dynamically linked dll

4. subclassing controls in dynamically biult dialog box

5. How do I change the caption on an MFC Dialog box (dynamically)

6. Change title for dialog box dynamically

7. change title for dialog box dynamically

8. Add a button dynamically on the creation of a Dialog Box

9. Dynamically alter size of Dialog Box

10. Dynamically changing text of a menu in a Dialog box

11. dynamically modifying a dialog list box

12. Modeless dialog box together with modal dialog box

 

 
Powered by phpBB® Forum Software