0

Using Win32 not MFC, how would I create a resizable or split controls?

As an example, a window with two edit controls side by side with the ability to resize them with a common divider. In the same way this dialog box can resized.

Not necessarily after a full example just a point in the right direction. Everything I lookup is about resizing entire windows not single controls (windows) inside the parent window.

Edit

Added image is show my example.

enter image description here

Bradmage
  • 1,233
  • 1
  • 15
  • 41
  • You will need to write an appropriate window procs handling WM_SIZE / WM_MOVE and related messages. Typically each control has a corresponding window (HWND or logical) – user7860670 Jul 25 '19 at 08:45
  • I have separate win procs for each window, I'm just not sure how to detect the click, drag, and associate it to the resizing of the two edit controls. – Bradmage Jul 25 '19 at 08:54
  • If you associate window processing for each edit control, you can manipulate the edit control as you do for the main window. – Strive Sun Jul 25 '19 at 08:59
  • Click and drag can be detected by handling mouse move and button messages. – user7860670 Jul 25 '19 at 09:04
  • @VTT I was after more than, can be detected by messages.. Being able to click and drag a handle is a bit more than that. – Bradmage Jul 25 '19 at 09:39
  • 1
    Windows doesn't provide this sort of control for you. You need to write it yourself. – Jonathan Potter Jul 25 '19 at 11:41
  • @JonathanPotter Obviously, that is why I have asked for some direction on how to do it. – Bradmage Jul 25 '19 at 12:17
  • Your question is too general for Stack Overflow really. You need code that can draw the splitter. You need code that detects the mouse click, tracks mouse movement while the button is held down, and calculates the relative sizes of the two windows. You need code that can lay out the two windows to arbitrary sizes. If that's not enough direction then please be more specific about what your problem is. – Jonathan Potter Jul 25 '19 at 22:36

1 Answers1

1

Everything I lookup is about resizing windows not controls.

Well, suddenly controls are, in fact, a windows as well, just visually little bit different.

Resizing controls is the same as resizing the window. In Win API it's handled by SetWindowPos function.

To properly resize controls when your window is resized you have to handle WM_SIZE Windows message in your main window and then resize/move your controls accordingly.

Updated:

After looking at your image:
Basically, if i understand your intentions, you need some custom divider/control, dragging which will eventually resize/move corresponding edit controls. Right?

In terms of pure Win API you will have to implement such control/divider in form of... another window.
In this window you will have to handle mouse clicks/moves and then do whatever you want with the (somehow) linked edit controls (basically implement all the logic).

Frankly saying this is not a very trivial task and that is what frameworks are here for (MFC, etc...).

Jovibor
  • 759
  • 2
  • 6
  • 16
  • This is the responses that always come up. I know controls are "windows". I worded it that way to help explain my example. I'll edit my question with more clarity. – Bradmage Jul 25 '19 at 09:10
  • thanks for an awesome edit :) I kind of figured I'd actually need 3 controls, edit | resizer | edit. I just don't know what kind of control to use for the divider or how to read the change. As for framework, it's been over 10 years since I used C++ so I'm interested in relearning winapi before using a framework. – Bradmage Jul 25 '19 at 09:55
  • I'll also add I've never created windows "windows ui" apps. Only OpenGL, so up until a couple weeks back WinApi is mostly new to me. – Bradmage Jul 25 '19 at 09:57
  • 1
    @Bradmage Not actually 3 controls. This all can be implemented in one control, some kind of ExtendedEditControl. But still, you will have to **draw** this control yourself, draw divider, response on divider mouseclicks, handle text input, etc... Not trivial task. – Jovibor Jul 25 '19 at 10:08