window position on startup

This is a discussion on window position on startup within the Windows Programming forums, part of the Platform Specific Boards category; you know how you first create the main window with CreateWindow and two of the params have to do with ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    157

    window position on startup

    you know how you first create the main window with CreateWindow and two of the params have to do with where the window is to be placed on the screen. well, whats your input on what you should do? should you give an immediate pixel value for that, shoudl you work with GetSystemMetrics(SM_CXSCREEN) and SM_CYSCREEN or do you just use CW_USEDEFAULT and let windows decide?

    right now i use CW_USEDEFAULT but i'm not really sure i like this way. mainly because the positioning on the screen seems sort of random.

    what do you use?

    thanks!

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    I use GetSystemMetrics and use some relation of that so that it is standard on all comps.

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    You could center you window on the desktop, but what I normally do (and this is pretty standard behaviour) is save the size and position of the window and open it back up to where the user had it the previous time.
    Just handle the WM_SIZE and WM_MOVE messages and save the size and position of the window respectively, then when you exit the app, write it to an .ini file or the system registry. When starting the app read in the values and pass them to CreateWindowEx.

    -Futura
    If you speak or are learning Spanish, check out this Spanish and English Dictionary, it is a handy online resource.
    What happens is not as important as how you react to what happens. -Thaddeus Golas

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    157
    that's a good idea. how could i possibly save this in the registry file? or would it be better to just write the values to that file? but would that be good to have an extra file for that alone? i guess i could also fit some other save-able options from the app also in that file, too.

    thanks!

  5. #5
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    I prefer keeping a program's settings in an ini file because I don't like cluttering up the sys registry. But, as they say, that is what the registry is for. To use the Registry, look up the Win32 API functions RegOpenKey, RegCreateKey RegDeleteKey. I would, however just write to a file in your program's directory. Make the file something like this:
    Code:
    [my prog's setup]
    left=529
    top=120
    width=540
    height=231
    add any other configuration & preferences here...
    Then just read in the file, parse it & you have your info.

  6. #6
    Registered User deltabird's Avatar
    Join Date
    Jan 2003
    Posts
    73
    If you're gonna mess with the registry functions, make sure you know what you're doing !

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    there is a style

    DS_CENTER

    In MSVC you can select this in the resource editor.
    "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

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    157
    okay, thanks all! i'm just going to use the file idea. seems to be best.

    so thats what the registry is for? just for that sort of thing, or other functions/options?

    thanks!

  9. #9
    vn1
    vn1 is offline
    Registered User vn1's Avatar
    Join Date
    Jun 2002
    Posts
    13
    I see that many big commercial programs use registry for saving its configuration settings (for internal use and for windows-wide use). For instance, read
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\App Paths\AcroRd32.exe
    value "Path" and you will know where last installed version of AcrobatReader resides.
    For your program it should be handy, but in general, big registry burdens system.
    Vaidotas.Vilnius.lt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  2. input/output
    By dogbert234 in forum Windows Programming
    Replies: 11
    Last Post: 01-26-2005, 05:57 AM
  3. no errors but still errors
    By Megatron in forum Windows Programming
    Replies: 7
    Last Post: 01-12-2003, 10:21 PM
  4. Winamp Vis if anyone can help
    By Unregistered in forum Windows Programming
    Replies: 6
    Last Post: 01-26-2002, 11:43 PM
  5. run a program
    By goodmonkie in forum Windows Programming
    Replies: 2
    Last Post: 10-07-2001, 11:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21