Forum > Win32/64
[SOLVED] How to get the width for the size grip on TStatusBar?
dsiders:
My google-fu is weak..
I have been scouring Win32 API docs and google to find a way to get the dimensions for the size grip on a status bar. I cannot find it.
Is it a matter of getting the Text metrics for the symbol used in the Marlette(sp?) font or some other SPI_ value?
Any advice appreciated...
440bx:
--- Quote from: dsiders on March 01, 2024, 06:17:43 am ---Any advice appreciated...
--- End quote ---
What follows really qualifies as "any" advice, i.e, not particularly easy nor straightforward... (and in addition to that, it is likely Windows specific)
Windows determines the height of the status bar based on the vertical size of the selected font. IOW, the size of the status bar is determined indirectly, which means that the size of its size grip is also determined indirectly and there does not seem to be a message that can be sent to the status bar to retrieve the grip size.
if you don't mind being "tricky" I believe there is a way to coerce that information out of the status bar. The trick consists of moving the Windows cursor vertically across the status bar in the area where the size grip is. When the cursor is over the size grip it will get a WM_NCHITTEST message. if you trap the status bar window message handler you can track the mouse coordinates that resulted in the status bar getting that message. Knowing the bottommost and topmost coordinates will allow you to calculate the grip size. Unless the status bar is really high, it shouldn't take very many calls to SetCursorPos to figure it out.
Conceptually, that method works BUT, there is a problem when Windows is running in a VM (at least on VMware workstation), some VM software traps (VMware) the calls to SetCursorPos in a way that nullifies it, i.e, like the call never happened. I know that for a fact because my copy of VMware does it. I have not found a way around that problem but, maybe using SendMessage WM_MOUSEMOVE (to the status bar) instead of SetCursorPos to trigger the WM_NCHITTEST might work (I don't know I haven't tried that but, it's worth a shot.)
HTH.
dsiders:
--- Quote from: 440bx on March 01, 2024, 07:07:23 am ---
--- Quote from: dsiders on March 01, 2024, 06:17:43 am ---Any advice appreciated...
--- End quote ---
What follows really qualifies as "any" advice, i.e, not particularly easy nor straightforward... (and in addition to that, it is likely Windows specific)
--- End quote ---
The question was windows-specific too. :)
--- Quote from: 440bx on March 01, 2024, 07:07:23 am ---Windows determines the height of the status bar based on the vertical size of the selected font. IOW, the size of the status bar is determined indirectly, which means that the size of its size grip is also determined indirectly and there does not seem to be a message that can be sent to the status bar to retrieve the grip size.
if you don't mind being "tricky" I believe there is a way to coerce that information out of the status bar. The trick consists of moving the Windows cursor vertically across the status bar in the area where the size grip is. When the cursor is over the size grip it will get a WM_NCHITTEST message. if you trap the status bar window message handler you can track the mouse coordinates that resulted in the status bar getting that message. Knowing the bottommost and topmost coordinates will allow you to calculate the grip size. Unless the status bar is really high, it shouldn't take very many calls to SetCursorPos to figure it out.
Conceptually, that method works BUT, there is a problem when Windows is running in a VM (at least on VMware workstation), some VM software traps (VMware) the calls to SetCursorPos in a way that nullifies it, i.e, like the call never happened. I know that for a fact because my copy of VMware does it. I have not found a way around that problem but, maybe using SendMessage WM_MOUSEMOVE (to the status bar) instead of SetCursorPos to trigger the WM_NCHITTEST might work (I don't know I haven't tried that but, it's worth a shot.)
HTH.
--- End quote ---
Thanks for that. I was hoping for something a little more mundane. ;)
I'll keep tinkering...
440bx:
--- Quote from: dsiders on March 01, 2024, 08:12:08 am ---Thanks for that. I was hoping for something a little more mundane. ;)
--- End quote ---
You're welcome and, now you know why I said it qualified as "any" ;)
d7_2_laz:
@dsiders, i think the answer would point to Windows ThemeServices (within uxtheme).
I once had a similar demand regarding the metadarkstyle component (uwin32widgetsetdark.pas here).
Accepted approach here to determine the gripsize and it's position::
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---gripSize: TSize;...GetThemePartSize(TWin32ThemeServices(ThemeServices).Theme[teStatus], LCanvas.Handle, SP_GRIPPER, 0, @Rect, TS_DRAW, gripSize);Rect.Left:=Rect.Right - gripSize.cx;Rect.top:=Rect.Bottom - gripSize.cy;
I’d guess that might give an idea how to apply it analogously outside this context.
Navigation
[0] Message Index
[#] Next page