Thread: Window Sizing Question

  1. #1
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195

    Window Sizing Question

    Im trying to have a window size be a constant ratio so that if the user tries to resize the width of a window, it will automatically resize the height and vice versa. Is there a way to do this - for example trapping the sizing messages etc??
    Last edited by Mastadex; 05-23-2006 at 02:06 PM.
    Founder and avid member of the Internationsl Typo Associateion

  2. #2
    Registered User
    Join Date
    Dec 2003
    Posts
    167
    The best way I think is to disable the maximize button when you create the window. Another option may be to set the window size you want when you receive the WM_SIZE message. The MoveWindow function should do it. I am not sure if there's a better function.
    silk.odyssey

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Handle the window's WM_GETMINMAXINFO message - search this board if you need an example of its use as there have been several posted here in past.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195
    WM_MINMAXINFO only allows me to set a lock for the current windows size. I have no idea if that helps me modify the width based on the height of the window....

    WM_SIZE seems to work but it does not allow me to control the size of the window while the user is tryint to resize it. Its not overriding user input, and thats what I want to do.
    Founder and avid member of the Internationsl Typo Associateion

  5. #5
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    WM_SIZE "is sent to a window after its size has changed". Instead, have you lookup or tried WM_SIZING? If that's not it, there's also WM_WINDOWPOSCHANGING. Not sure which one is better suited...
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Sorry, I misread the question. WM_SIZING, as Cactus_Hugger has suggested, will do what you need.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  7. #7
    Codebot
    Join Date
    Jun 2004
    Location
    Toronto
    Posts
    195
    Well this seems to trap the movement just fine. My problem is now, How do I resize the window based on what the use has done...I tried using SetWindowPos() but it didnt work as I planned. Any suggestions on what to use?
    Founder and avid member of the Internationsl Typo Associateion

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    WM_SIZING:
    Quote Originally Posted by msdn
    By processing this message, an application can monitor the size and position of the drag rectangle and, if needed, change its size or position .
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    Registered User
    Join Date
    Sep 2003
    Posts
    23
    Hi,

    in my code I handle WM_SIZING, I carefully supply correct values in WM_GETMINMAXINFO and in the end I double-check everything in WM_WINDOWPOSCHANGED and WM_SIZE for final corrections, and it all worked on both 9x and NTs, live dragging on or off, but still...

    ... few weeks ago I was showing my demo to some guy on HIS notebook and he seems to have XP with some skin-job or manager and he was able to maximize my window to full screen even though that window was supposed to occupy half of the screen when "maximized". Without debugger on that machine I can't tell anything, but as if my app never received some of the messages related to sizing.

    Or, I don't know...
    Last edited by Delf; 05-25-2006 at 09:23 AM.

  10. #10
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    If your friend is using some sort of custom window manager it may be that it doesn't properly implement the messages your application is handling.

    If you want to stop an application from being maximised don't create it with the WS_MAXIMIZEBOX window creation style.

    If neither of these seem likely, perhaps it might be an appropriate time to create a very simple application that reproduces the problem you are describing and post it for anyone interested enough to want to fiddle around with it.

    ****

    >>skin-job<<

    I thought replicants on earth were illegal.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  11. #11
    Registered User
    Join Date
    Sep 2003
    Posts
    23
    Quote Originally Posted by Ken Fitlike
    If your friend is using some sort of custom window manager....
    He's not my friend - he was just potential customer and I hope it stays that way. Who needs friends with custom window managers?!

    Quote Originally Posted by Ken Fitlike
    ... create a very simple application that reproduces the problem you are describing and post it for anyone interested enough to want to fiddle around with it.
    Good idea! Maybe this weekend if I find some extra time.

    ****
    Quote Originally Posted by Ken Fitlike
    >>skin-job<<

    I thought replicants on earth were illegal.
    Hell, I just returned from Tannhauser Gate and you'd never guess what I saw up there?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. creating a child window
    By rakan in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2007, 03:22 PM
  3. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  4. question about a window
    By Alsij in forum Windows Programming
    Replies: 5
    Last Post: 08-12-2004, 11:30 PM
  5. Winamp Vis if anyone can help
    By Unregistered in forum Windows Programming
    Replies: 6
    Last Post: 01-27-2002, 12:43 AM