Thread: Variable window placement with resources

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    68

    Variable window placement with resources

    Hi all,
    I've centered my main window (with the DS_CENTER style) and want to dock a child window together with the main window at the right main windows border.
    But using resources (an .rc file) for declaring the window dialog parameters I am unable to include variables for the resolution-dependant xy child window placement.
    Is there a way to make this possible, even with resources or do I have to use another function than CreateDialog to make it work?

    TIA for help,
    Hawk

  2. #2
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    Since you're window is dynamically positioned,. a value cant be hardcoded for it into the resource file, but you can just use GetWindowRect to obtain the windows dimensions and then use SetWindowPos to set the dialog's x to the initial window's x + width.

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    You can hardcode it if you use it as a preprocessor constant!

    eg,
    Code:
    #include "dialogsiz.h"  // contains #define RES_DIALOG_WIDTH 250
    // ...
    
    IDD_MAIN DIALOGEX DISCARDABLE 6, 18, RES_DIALOG_WIDTH, 346
    
    // ...
    for example

  4. #4
    Registered User
    Join Date
    Aug 2006
    Posts
    68
    Preprocessor defines are the only kind of 'variables' I may use in resource files. But I can't hardcode the x-y-values themselves because they're not constant, they depend on the screen metrics. The x value of my childwindow would be resolution/2+mainwindow_width/2 (to the right of the main window), the easiest way would be @nthony's, it's also pretty simple because the child window doesn't show before I want it too, so I am going to reposition my child windows and then just show them (if there is really no way to do it with the resources)

    Thanks for the answers!
    Hawk

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Capture Window
    By lord mazdak in forum Windows Programming
    Replies: 0
    Last Post: 04-09-2007, 08:51 AM
  2. how i create a window whith all it's elements
    By rasheed in forum Windows Programming
    Replies: 1
    Last Post: 05-31-2006, 06:53 PM
  3. Problem with creating new window, from another window
    By Garfield in forum Windows Programming
    Replies: 6
    Last Post: 01-11-2004, 02:10 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. Invoking MSWord
    By Donn in forum C Programming
    Replies: 21
    Last Post: 09-08-2001, 04:08 PM