Splitting the Window

This is a discussion on Splitting the Window within the Windows Programming forums, part of the Platform Specific Boards category; How do I split a window up (without using MFC) like HTML's frames option?...

  1. #1
    Amateur Programmer
    Join Date
    Nov 2003
    Posts
    11

    Splitting the Window

    How do I split a window up (without using MFC) like HTML's frames option?

  2. #2
    Amateur Programmer
    Join Date
    Nov 2003
    Posts
    11
    nevermind, I figured it out. Thanks anyways though.

  3. #3
    Amateur Programmer
    Join Date
    Nov 2003
    Posts
    11
    OK, I figured out how to do it, but now I have another problem... I'm trying to figure out what to make of this code:
    Code:
    int nSplitterPos = 100;
    int nSplitterBorder = 2;
    
    void SizeWindowContents(int nWidth, int nHeight)
    {
     MoveWindow(hEdit1, 0, 0, nWidth, nSplitterPos, TRUE);
     MoveWindow(hEdit2, 0, nSplitterPos + nSplitterBorder, nWidth,
                nHeight - nSplitterPos - nSplitterBorder, TRUE);
    }
    It's really only the height that I'm having trouble with (the 5th parameter)... it seems that no matter how I mess with it, something messes up. All I want is to have the top window taller than the bottom window... Anyone?

    Many thanks

    Chris

  4. #4
    uh oh
    Join Date
    Jan 2005
    Location
    Ontario, CA
    Posts
    66
    It will take a little more math then whats in the SizeWindowContents() function you posted above... you could use something like this:

    Code:
    void SizeWindowContents(HWND hParent, int tRatio)
    {
         RECT wRect;
         int tHeight, bHeight;
    
         GetWindowRect(hParent, &wRect);
         tHeight = (wRect.bottom - wRect.top) * (tPerc - 100);
         bHeight = (wRect.bottom - wRect.top) - tHeight;
         MoveWindow(hEdit1, 0, 0, wRect.right - wRect.left, tHeight, TRUE);
         MoveWindow(hEdit2, 0, tHeight + nSplitterBorder, wRect.right - wRect.left, bHeight - nSplitterBorder, TRUE);
    }
    Might be a simpler way of doing the code except I don't care to think about it right now lol. I used some of the variables from your example just because I figure you already have them setup as globally (assuming of course).

    Hope this helps,
    cyreon

  5. #5
    Amateur Programmer
    Join Date
    Nov 2003
    Posts
    11
    Thanks cryeon - but I think I figured out an easier way. It was actually simpler without rect. Although that would be for dynamic sizing, no? Right now I have it static - i.e. they're the same size no matter if the window is maximized or minimized. But thanks for the other example.

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. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  3. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM

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