Thread: Dialogs and resources

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    29

    Question Dialogs and resources

    I was just wondering if it is possible to make dialog boxes without using resources. All the windows API tutorials I have read always show using resources. And while we're on the subject, how much are resources really needed? I prefer doing things by hand as much as possible, and it would be nice if I didn't need a resource editor to do all this stuff.

    Thanks for any comments.

  2. #2
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hey,

    You can make dialogs without using resources, but its hard you have to write the code for them in your main cpp file.

    I have not tried this before but if i recall correctly i think that there is some stuff on it in Petzolds book, Programming Windows 5th Edition... i think i read it in there anyway

    Sorry i cant help more
    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    All ctrls, dialogs and windows can be made on the fly.

    Use CreateWindow() and sepecify the type of ctrl (look in the help for the codes). Remember to cast the HMENU param as the ctrl/dlg ID number

    ie
    #define IDC_MYCTRL 10001
    and in CreateWindow
    (HMENU)IDC_MYCTRL

    The resource editor is good if you have lots of ctrls, on the fly is good for single ctrls or ctrls on a window.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    you can't use createwindow to create a dialog box on the fly!!! that creates a window.. he wants to build a dialog box in memory and use that.

    I have attached a file that is an example of something i made that does what you are looking for... i wanted a function that i could pass an array of strings to and it would create a dialog box that had a radio button for each item, and it would return the index of the button that was clicked... i hope you find it useful.

    building dialog boxes in memory is a pain in the arse!

    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    What is the difference between a dialog with no ctrls (created on the fly) and a window?

    Except that the dialog is probably not full screen and a child window can't have a menu. (Also the icon in the systray.)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    Dialog resource is, in fact, set of DLGTEMPLATE and DLGITEMTEMPLATE structures. The first in memory is DLGTEMPLATE, which describes dialog window itself. It is followed subsequently by DLGITEMTEMPLATEs. These are for child controls, one struct for each control. After dialog resource script is compiled you get this attached to your exe file. You may choose if to use resource or create template in memory and pass its address to CreateDialogIndirect (). MSDN has good examples on it.

    To Urador again: Dialogs are ordinary windows with some easier management. CreateWindow (I believe) is used internally on dialog creation.

    To novacain: Use CreateWindow if you want your hair got white . Resource editor is the best possible way when creating dialogs.

  7. #7
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    That's right - CreateWindow/CreateWindowEx are ultimately called to create dialogs (normally). The system classname for the dialogbox is '#32770'. Never tried using it with CreateWindow though...

    If you are unhappy using a resource editor - presumably GUI - why not just use a text editor if you are looking for more 'control'?

    I'd really have to go along with:
    building dialog boxes in memory is a pain in the arse!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resource's in an executable
    By mrafcho001 in forum Windows Programming
    Replies: 1
    Last Post: 07-17-2006, 01:59 PM
  2. Dialogs in dos window?
    By Blackroot in forum C++ Programming
    Replies: 5
    Last Post: 01-24-2006, 07:04 PM
  3. Transforming dialogs to MDI
    By publikum in forum Windows Programming
    Replies: 5
    Last Post: 09-01-2005, 03:37 AM
  4. Question about dialogs and displaying/hiding controls
    By Longie in forum Windows Programming
    Replies: 2
    Last Post: 05-11-2005, 05:26 PM
  5. Copying the resources between projects
    By axr0284 in forum Windows Programming
    Replies: 3
    Last Post: 01-20-2005, 11:24 PM