Author Topic: How to create a window with panes  (Read 4001 times)

HSE

  • Member
  • *****
  • Posts: 2501
  • AMD 7-32 / i3 10-64
Re: How to create a window with panes
« Reply #15 on: February 06, 2022, 12:42:39 PM »
Also there is an Splitter example in Masm32 SDK, inside exampl03 directory.
Equations in Assembly: SmplMath

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: How to create a window with panes
« Reply #16 on: February 06, 2022, 01:24:39 PM »
So the "splitter" is really just that little slice of the underlying parent window that shows through between the child windows, because the only time the parent window will get mouse messages is when the mouse is over that little sliver; all other messages will go to the children. Neat. And I was wondering how the application I was looking at got a special cursor to move the splitter, but that's just a matter of loading that cursor for the underlying window.

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: How to create a window with panes
« Reply #17 on: February 06, 2022, 08:48:59 PM »
Exactly. And while user passes the mouse from left to right, from one control to the neighbouring one, the main WndProc receives a bunch of messages:

Code: [Select]
msg     1285    WM_SETCURSOR
msg     1286    WM_SETCURSOR
msg     1287    WM_SETCURSOR
msg     1288    WM_SETCURSOR
msg     1289    WM_GETICON
msg     1290    WM_GETICON
msg     1291    WM_SETCURSOR
msg     1292    WM_NCHITTEST
msg     1293    WM_SETCURSOR
msg     1294    WM_MOUSEFIRST
msg     1295    WM_NCHITTEST
msg     1296    WM_SETCURSOR
msg     1297    WM_MOUSEFIRST
msg     1298    WM_NCHITTEST
msg     1299    WM_SETCURSOR
msg     1300    WM_MOUSEFIRST
msg     1301    WM_SETCURSOR
msg     1302    WM_SETCURSOR

WM_SETCURSOR looks promising ;-)

TimoVJL

  • Member
  • *****
  • Posts: 1320
Re: How to create a window with panes
« Reply #18 on: February 06, 2022, 09:08:46 PM »
A splitter without own window / control have some flickery in slow PC, but not an problem anymore, but i was somewhere at 2003.
wjr examples might work in that principle, a parent window work as splitter.

EDIT:
Code: [Select]
//these are for splitter, begin
case WM_SIZE:
MoveWindow(hWndTV, 0, 0, uDrag-1, HIWORD(lParam), TRUE);
MoveWindow(hWndLV, uDrag+1, 0, LOWORD(lParam)-101, HIWORD(lParam), TRUE);
return 0;
case WM_LBUTTONDOWN:
SetCapture(hWnd);
bDrag = TRUE;
return 0;
case WM_LBUTTONUP:
ReleaseCapture();
bDrag = FALSE;
return 0;
case WM_MOUSEMOVE:
if (bDrag) {
GetClientRect(hWnd, &rect);
if ((LOWORD(lParam)>50) && (LOWORD(lParam)<(rect.right)-50)) {
MoveWindow(hWndTV, 0, 0, LOWORD(lParam)-1, rect.bottom, TRUE);
MoveWindow(hWndLV, LOWORD(lParam)+1, 0,
rect.right-LOWORD(lParam)+1, rect.bottom, TRUE);
uDrag = LOWORD(lParam);
}
}
return 0;
//these was for splitter, end
Interesting:
What’s the point of DeferWindowPos?
« Last Edit: February 06, 2022, 10:48:20 PM by TimoVJL »
May the source be with you

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: How to create a window with panes
« Reply #19 on: February 06, 2022, 09:15:10 PM »
One of the toys in MASM32 is "qetb.exe" and that uses a 3 window design, the middle one being the splitter and as a separate window, you can change the splitter colour on mouse click. All done via MoveWindow().
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: How to create a window with panes
« Reply #20 on: February 07, 2022, 08:59:49 AM »
Next question: let's say you have an app with 3 control windows, say one on the left and two stacked up vertically on the right. How to differentiate between landing on the vertical and horizontal splitters? (Because you want different cursors for them to guide the user.)

Maybe it's simple: if the cursor position is to the right of the vertical split, then load the vertical (north-south) cursor, else load the horizontal (east-west) one. Because if it's to the right of the vertical split, it must be somewhere over the horizontal split.

daydreamer

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Re: How to create a window with panes
« Reply #21 on: February 07, 2022, 07:08:47 PM »
You can probably solve it with code inside Wm_SetCursor message
https://docs.microsoft.com/en-us/windows/win32/learnwin32/setting-the-cursor-image
my none asm creations
http://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

TimoVJL

  • Member
  • *****
  • Posts: 1320
Re: How to create a window with panes
« Reply #22 on: February 07, 2022, 07:24:48 PM »
TLODBC_sHell had this kind of code with 3 panes:
dx and dy are just delta of mouse positions against drag X Y positions.
Code: [Select]
void OnLButtonDown(HWND hWnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
{
int dx, dy;
SetCapture(hWnd);

dx = x - uDragX;
if (dx > - 10 && dx < 10)
bDragX = TRUE;

dy = y - uDragY;
if (dy > - 10 && dy < 10)
bDragY = TRUE;
}

void OnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags)
{
ReleaseCapture();
bDragX = FALSE;
bDragY = FALSE;
}

void OnMouseMove(HWND hWnd, int x, int y, UINT keyFlags)
{
RECT rc;
BOOL bMove;

int dx = x - uDragX;
int dy = y - uDragY;
if (dx > -5 && dx < 5)
SetCursor(LoadCursor(NULL, IDC_SIZEWE));
else if (dy > -5 && dy < 5)
SetCursor(LoadCursor(NULL, IDC_SIZENS));
else
SetCursor(LoadCursor(NULL, IDC_ARROW));

bMove = FALSE;
GetClientRect(hWnd, &rc);
if (bDragX && !bDragY) // X
{
if (x > 50 && x < (rc.right - 50))
{
uDragX = x;
bMove = TRUE;
}
}

if (bDragY && !bDragX) // Y
{
if ((y > 50) && y < (rc.bottom - 50))
{
uDragY = y;
bMove = TRUE;
}
}
if (bMove)
{
ReSizeWindows(hWnd);
}
}
May the source be with you

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: How to create a window with panes
« Reply #23 on: February 07, 2022, 07:40:54 PM »
Yes, I think that confirms what I speculated about above.
Back to the laboratory!

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: How to create a window with panes
« Reply #24 on: February 08, 2022, 06:53:32 AM »
My first attempt, but I'm not satisfied - it's slow and flickery.

Extract files to a folder and launch the exe.

Biterider

  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: How to create a window with panes
« Reply #25 on: February 08, 2022, 07:41:56 AM »
Hi
Maybe you can get inspiration from one of the ObjAsm examples.  :cool:

Regards, Biterider

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: How to create a window with panes
« Reply #26 on: February 08, 2022, 08:14:53 AM »
Maybe you can get inspiration from one of the ObjAsm examples.  :cool:

Thanks, it works fine, and no flicker, but in contrast to mine you don't update the controls while you are dragging.

I'll have to study \Masm32\examples\exampl03\splitter\splitter.asm, it updates while dragging but more smoothly than mine :cool:

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: How to create a window with panes
« Reply #27 on: February 08, 2022, 04:35:40 PM »
JJ, the problem I have with your example is not so much flicker as the annoyance that I have to drag the splitter really S-L-O-W-L-Y or else it escapes my grip. Reminds me of a program I wrote that moves things (control windows) around in a parent window and lets you resize them: really flaky behavior; sometimes things jump erratically, etc. Apparently this is more of an art than a science.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10583
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: How to create a window with panes
« Reply #28 on: February 08, 2022, 06:07:00 PM »
The notation is PowerBASIC but you do the same thing in assembler.

        MoveWindow hSplitter,splitr-2,rbh,5,Rct.nBottom-(rbh+sbh),%TRUE
        MoveWindow hEdit,splitr+1,rbh,Rct.nRight-splitr-1,Rct.nBottom-(rbh+sbh),%TRUE
        MoveWindow hList,0,rbh,splitr-1,Rct.nBottom - (rbh + sbh), %TRUE

Flickering.
    wcex.hbrBackground = %NULL   ' set the background brush to 0 or NULL

hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: How to create a window with panes
« Reply #29 on: February 08, 2022, 08:26:24 PM »
JJ, the problem I have with your example is not so much flicker as the annoyance that I have to drag the splitter really S-L-O-W-L-Y or else it escapes my grip.

I know. I've tried with WM_MOUSEMOVE instead of WM_SETCURSOR, no change. I need to rethink the logic a little bit (if I find the time).

Attached a C source from an obscure web location. It's 140 lines short, but my three C compilers bark at them, for various reasons. C/C++ is a waste of time.