Clip windows horizontally?

I have multiple horizontally adjacent windows inside the program's main window; they are all for text editing (CreateWindow("EDIT", ... with WS_THICKFRAME):

1. How do I make it so that only the left and right borders of each window are movable (not the top and bottom)?

2. The right border of one window should be the left border of the window that's to the right of it. So when I make one window narrower, an adjacent window should become wider. How do I do this?

I have experience with C++ and OpenGL, but not much with Win32; I can't seem to find the right commands for this.

Any help is welcome.
Last edited on
Hi,

First of all the usage of commands is not correct in this context it should rather be functions, but as far as I know there is no readymade function which can accomplish such an act but there could be some sort of technique maybe it requires you to redraw the windows border anyway I suggest you try look at forgers windows API, it contains almost all Windows graphics related functions :
http://www.winprog.org/tutorial/

If that does not work read: http://www.amazon.co.uk/Windows-Via-C-5th/dp/0735663777

It is quite a commendable book.

Good Luck!
Thanks for the links.

I'm thinking of doing everything in OpenGL anyway, since it's probably easier to use after all. Just for the text editing, I can use CreateWindow("EDIT", ... and then alter that window's RECT's coordinates when dragging the border that is drawn by OpenGL.
What you're talking about sounds like the kind of situation where you'd use a splitter window.

Rather than give the Edit controls a thick frame and hosting them directly in the main windows, you create them without a frame and host them in a splitter window which is the direct child of the main window.

With the splitter approach the thick frame would be provided by the splitter, round the outside, plus the splitter bars, between the child windows. When the splitter bars are moved it's the splitter which resizes the controls it holds.

The splitter window is responsible for drawing a splitter (or more than one) and filling in the background of any uboccupied space. It is also responsible for responding to messages that move the splitter and adjusting the size of it's children as required. While the standard splitter is for two child controls, but it should be easy enough to generalize.

(An API call which might be helpful when painting the splitter window is DrawEdge
http://msdn.microsoft.com/en-us/library/windows/desktop/dd162477%28v=vs.85%29.aspx
it know how to draw the standard edges of buttons and windows.)

I suppose you could get the Edit controls to work together, cooperatively, without the splitter if you subclassed them suitably. But I've never seen it done, and it would prob. be rather messier than the usual splitter approach.

When I've done this kind of thing I've used WTL, which provides a splitter class; and I know MFC provides a spliiter implementation. But neither WTL nor MFC's splitter's work with several controls in a row.

And there's this, which I've just found, which works with the WinAPI directly. Not sure how good it is, but it will help you identify which message you need to handle.

Win32 splitter window project
http://www.codeproject.com/Articles/19766/Win32-splitter-window-project

(I have downloaded and built the sample projects, and it does the normal splittery thing. It flickers as the painting code is rather basic, as it's just a a demo. But it is using WinAPI rather than MFC or WTL. You may well be able to find a better example, given a bit more time.)

Andy
Last edited on
That's exactly what I needed!

Thanks, Andy.
Topic archived. No new replies allowed.