Window Resize question (MFC)

This is a discussion on Window Resize question (MFC) within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I want to make a window resizable, but I want to limit exactly how it can be resized. For ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446

    Window Resize question (MFC)

    Hi,

    I want to make a window resizable, but I want to limit exactly how it can be resized. For instance, I am drawing a game board and the board is exactly a square. So when the user resizes horizontally, I want the window to also grow vertically by the same amount. Also, I don't want the board to be less than some minimum size, so I want to disallow resizing if the window is getting too small.

    My first guess is to handle WM_SIZE, and then use some Win32 API call to resize the window (based on input params) if they doesn't conform to my liking. Does this sound right or is there some other approach? And what would that API call be?

    Thanks.
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Look into WM_SIZING and WM_GETMINMAXINFO. I'm not sure if there are MFC equivalents for these messages.

  3. #3
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    Thanks for the hint. I was trying to use WM_SIZING, and I ran into some problems, so much so that I decided to scrap this particular feature of the app until later.

    Here were my problems:
    WM_SIZING only works when the message handler is attached to the frame class. Ideally I would like it attached to the View, because then (presumably) the RECT that I will get passed will be the client area that I am about to resize. As it is, I have to deal with the whole window size--including the title bar, menu, and status bar. Now it turns out that I could care less about these other things; what I really want to do is resize the client portion of the window to be some certain size.
    What I ended up doing was looking up the size of the client area, subtracting the height of the status bar if visible, then using subtracting the total height of the menu and status bar based on the difference between the input param to OnSizing and GetClientRect. The width was easy because it was always the width of the client area.
    But then I was getting choppy resizing when I did this, presumably because I need to be aware of if the user is sizing the window to be larger or smaller, so that I know if I should round up to the next reasonable size window, or down.

    And at that point I said to myself "This is BS. It should be easier than this..."

    Am I missing something, or is this basically the way it's done?
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Window menu question
    By axr0284 in forum Windows Programming
    Replies: 0
    Last Post: 03-08-2005, 08:01 AM
  2. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03:49 PM
  3. dont want to use all params
    By stallion in forum Windows Programming
    Replies: 2
    Last Post: 02-18-2003, 07:10 AM
  4. How do I display data in the Right Window in MFC.
    By Jasonc in forum Windows Programming
    Replies: 2
    Last Post: 09-07-2002, 06:31 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

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