Solved

Dynamic Dialog Box Creation

Posted on 1998-08-31
4
567 Views
Last Modified: 2013-12-26
My application has a main window that occupies about a eighth of the screen.  This contains several Owner Drawn option buttons which trap a left double click.  Is there a way of creating a dialog box dynamically ( ie not based on a resource script ) when the button is double clicked.  The reason for this is that the number of controls that appear in the dialog box will vary.  If a dialog box can not be used, is it possible to create another window outside of the main window's client area ?
0
Comment
Question by:hnc5013
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
duneram earned 60 total points
ID: 1299767
Yes you can, but did you know you can do some tricks that are pretty cool with resources that are prebuilt?

One trick you can do is to pre-create all the controls you expect to see in all permutations of your dialog and move them off of the actual dialog.  Make your dialog small.  click on a control in the resource editor and then click on the area outside of boundaries of your dialog. the control will appear there.

At SetupWindow time, you size your dialog using SetWindowPos api and GetSystemMetrics using SM_CXSCREEN and SM_CYSCREEN.

When a button is 'double clicked' you invoke a TDialog *x = new TDialog(....333...) /* assuming 333 was your resource id */

When various events occur in your dialog, you just
1) hide the old controls (turn off the visible flag)
2) move the new controls onto the proper position in your dialog
3) make the new controls visible

and you are done.

Its very painless.   VC won't let you do this very easily.  Using Borland's method, its painless and works quite well.

You can change the size of  your dialog with the SetWindowPos API.

Good Luck!!
0
 

Expert Comment

by:MostlyWater
ID: 1299768
There is one problem to dunerams answer :
Editing the controls painted in the resource editor can be quite painful if the elements are on top of each other.
If you do not wish to do that, you will need the new TStatic() , Create() and ShowWindow() (possibly also MoveWindow() functions to place your dialog elements.
0
 
LVL 2

Expert Comment

by:duneram
ID: 1299769
Mostlywater, true,  but the resource editor lets you associate controls with a dialog but you don't have to place them on the dialog.  For design, just make the dialog huge.  place all the controls in separate places.  When done with design, shrink the dialog to your desired size (or do that at run time too).
0
 

Author Comment

by:hnc5013
ID: 1299770
Thanks for your responses.  I created a blank Dialog and adjusted the size of this at runtime using SetWindowPos.  Instead of creating a number of controls and placing them outside of the dialog box I used a linked list to fill the dialog with a number of TGauges.  This works well however there are situations where it is not possible to display all the gauges in one dialog.  I have also trapped the EvPaint messages to enable the printing of text within the dialog.  

Could you tell me how to use a vertical scroll bar within a dialog box and which class to use ( TScroller, TScrollBar ) ?

Do I have to include the vertical scroll bar within the dialog resource script and hide it when the child controls fit within the dialog box or do I create a new scroll bar when required ?

Finally what messages should I trap and what functions do I need in order for the dialog contents to scroll ( do I adjust the positions of the gauges by altering the Y-Pos value which is decided by the position of the scroll bar thumb ) ?

Thanks again for your help !
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question