Thread: Noob question - Dialogs and controls - Sorry for the long post

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    52

    Noob question - Dialogs and controls - Sorry for the long post

    Hi all,

    I've come from years of programming on Linux and decided to try my luck with windows. I've looked at a few sites (MSDN and winprog.org) and they werd great but I was wondering if it was possible to do a dynamic dialog type thing.

    Basically, I would like a main window with a few pictures on the left hand side for navigation and when I click on one, the right hand side "frame" (if you will) would load dialog A, when you click on the second icon in the menu, the right "frame" will have a different dialog.

    This is purely theoretical but I was wondering if it was possible to do, ie, load co-ordinates and types (button, combo, etc, as plaintext) into memory and "draw" them when you click on the corresponding menu item. The only problem I would imagine would be to "undraw" or "erase" the items currently on the screen and "redraw" the ones oyu want. Or can you have multiple files with the dialogs pre-made and you just load them into memory and "hide" the dialogs you dont want and just create a child process to display the dialog you want in a child window?

    Sorry for the long post and what might seem like a stupid quesoin, but if someone could point me in the right direction (if this is at all possible) I would very much appreciate it.

    Oh, one other thing which someone suggested to me after looking at a web page. Is it possible to "shift" dialog items down a page, so say you have two buttons at the bottom, co-ordinates being 100, 100 (x, y) but then have them "moved" to 100, 200 (100 pixels lower)? I don't think it would be, but like I said, I haven't done GUI programming before but am quite fluent in the backend.

    It might seem like I'm jumping in the deep end a little too quickly, but if you could, please answer these. I'm not after source code as I would prefer to write it myself, what I am after is a point in the right direction. Too bad windows doesn't have man pages
    - Daniel Wallace

  2. #2
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Or can you have multiple files with the dialogs pre-made and you just load them into memory and "hide" the dialogs you dont want and just create a child process to display the dialog you want in a child window?
    Dialog boxes are really just child windows to the parent window, same thing applies to all the other controls such as buttons. You can create dialog boxes using a resource script file that contains everything in the dialog box including its initial x and y coordinates. Thus you could make your dialog box appear at a certain area in the screen.

    You really just need to hop onto MSDN or get a book on windows programming. This is all really easy, especially for what you want to do.

    So basically you want to learn:
    1. How to create dialog boxes using a resource script
    2. Load a dialog box using the DialogBox() function.
    3. Using the DialogBox Callback procedure
    4. Maybe want to look at MoveWindow() function

    If you look for those things that should get you going in the right direction, and you will soon be able to do what you want.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    Thank you very much for that, that was exactly what I was looking for.

    Though, with the MoveWindow() function, if i wanted to add extra dropdowns in hte top half of the child window and shift all buttons and such underneath it, would I have to redraw the whole thing? Because basically, I want to have three combo boxes at the top with a listbox on the right hand side and some extra information underneath it. But when I choose three things from the combo boxes, I would like two more to "appear" underneath it, so moving the entire window wouldn't be what I want, as you can only move the HWND, is that at all possible?

    I noticed MapDialogRect() which might be useful, I'm hoping this is the way to go
    Last edited by Longie; 02-20-2005 at 07:56 AM.
    - Daniel Wallace

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Windows has a very rich API. Within reason, if you can imagine it, you can do it.

    The kind of UI you describe is very much like the UI for the AdAware spyware killer which I'd just run before coming back onto the board. Very possible.

    Andy has the line for more sophisticated dialogs, depends what you want. Another approach for simple dialogs is to place all of the controls for all of the dialogs on your main window. Then depending on the option selected by your navigation controls, you show the relevent group of controls whilst hiding the others.

    Another popular method is to use a tabbed page where the tabs run across the top and you open and close the dialogs by selecting the relevent tabs - a lot of browsers and other stuff are going that way at the moment. The Visual Studio.NET editor for example.

    Rich API = many ways to achieve things. Which is best depends on what you want.

    *** EDIT ***

    We were typing at the same time. Using the "drawn but not displayed" trick you could have your additional controls "appear" whenever you like.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    Well, I'm making a point of sales program, which contains the list of products in the ocmbo boxes and the listbox on the right contains the products I have added to my "cart". But as I have hundreds of products, I would like to have more combo boxes show underneath when the current ones get full instead of adding more items to the cart when the list boxes get full.

    Underneath everything is method of payment, credit card, cash, etc, which is the stuff I want to shift down

    I'd prefer not to use tabs as I don't like the looks of them really, hence me icon menu type thing on the left
    - Daniel Wallace

  6. #6
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    adrainxw has it all wrapped up. The drawn but not displayed thing is the way to go with what you are talking about. However do note that you can obtain the hwnd for buttons, they are after all just child windows. This thread explains buttons a little bit, maybe it will clear up some more questions for you.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    Yeah, I was thinking about doing something like that, I just have to find somewhere where I can look up options and such, like with the combo boxes I can't rememebr the CB_OPTION to have it dropdown or simple.

    I don't want to go fishing around the header files to find it so I'm going to have to do some more searching on MSND I think.

    Would I be right in assuming there is a simple (in)visbile option in the declaration of the controls and I can use something like SendDlgMEssage (or whatever the exact function is) to change it (the same way you use it to check a checkbox)?

    And can I add you to my MSN or something instead of chatting on here? heh
    - Daniel Wallace

  8. #8
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    With a tab control, you can, of course, put the tabs on the side if you so wish. You can also customise their appearance, and ultimately, use "owner drawing" to have complete control over then, but their behaviour remains the same as far as their message generation and processing, so you code doesn't get messy.

    Just suggesting possibilities.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    Thanks heaps. Sorry for me replying after you answered, I just wrote my replies when you were replying.

    I really appreciate your help
    - Daniel Wallace

  10. #10
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> I just wrote my replies when you were replying.

    Nothing to apologise for, happens to us all in this medium.

    And, yes, you can show or hide controls at will.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  11. #11
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    Beautiful, I'm playing with it now and lets hope it works
    - Daniel Wallace

  12. #12
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    Windows button types:

    Code:
    CBS_SIMPLE                  Simple combo boxes
    CBS_DROPDOWN                Drop down combo box
    CBS_DROPDOWNLIST            Drop Down list box
    BS_PUSHBUTTON               Pushbutton
    BS_DEFPUSHBUTTON            Default Push Button
    BS_CHECKBOX                 check box
    BS_AUTOCHECKBOX             auto check box
    BS_RADIOBUTTON              radio button
    BS_3STATE                   3 state control
    BS_AUTO3STATE               ""
    BS_GROUPBOX                 group box
    BS_AUTORADIOBUTTON          radio button
    BS_OWNERDRAW                basically define your own image
    Hopefully this will serve as a good starting reference.
    Last edited by andyhunter; 02-20-2005 at 09:45 PM.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

  13. #13
    Registered User
    Join Date
    Sep 2002
    Posts
    52
    Excellent, just what I wanted
    - Daniel Wallace

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. edit controls in dialogs
    By Homunculus in forum Windows Programming
    Replies: 10
    Last Post: 02-23-2006, 03:38 PM
  2. Question about dialogs and displaying/hiding controls
    By Longie in forum Windows Programming
    Replies: 2
    Last Post: 05-11-2005, 05:26 PM