Are there any scripts/functions for measuring a GUI window before it is shown.
E.g. the ToolTip command or the Menu command.
For example, so you can centre the ToolTip, or decide whether
to place a menu above/below the cursor etc.
I tried DrawText on ToolTips, to measure the text dimensions,
versus the ToolTip window size, but when I increased
the ToolTip font via WM_SETFONT, the number of extra 'border' pixels did not stay constant.
Btw what font does ToolTip use?
On my system it was: Segoe UI, size 9, regular,
which I found out via WM_GETFONT and GetObject.
It doesn't seem to be:
- the icon label font (SPI_GETICONTITLELOGFONT)
- or one of Caption,SmCaption,Menu,Status,Message (SPI_GETNONCLIENTMETRICS) (see NONCLIENTMETRICS structure)
- or SYSTEM_FONT (System, size 12?, bold) (it returned a height of positive 16, when the height is usually given as a negative number)
- or DEFAULT_GUI_FONT (MS Shell Dlg, size 8, regular) (see (GetStockObject for DEFAULT_GUI_FONT/SYSTEM_FONT).
I checked in the source code, and just me's ToolTipEx, and Lexikos's ToolTipFont, but didn't find the answer.
Thank you for reading.
measure Menu/ToolTip/GUI dimensions before showing
measure Menu/ToolTip/GUI dimensions before showing
Last edited by jeeswg on 18 Feb 2017, 15:44, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: measure GUI dimensions before showing
See, Gui,Show, Hide, WinGetPos, DetectHiddenWindowsjeeswg wrote:Are there any scripts/functions for measuring a GUI window before it is shown.
Re: measure Menu/ToolTip/GUI dimensions before showing
Some problems with workaround attempts for Menu/ToolTip commands,
to show a Menu/ToolTip offscreen, and retrieve dimensions, prior to showing onscreen:
@Helgef Thanks
to show a Menu/ToolTip offscreen, and retrieve dimensions, prior to showing onscreen:
Code: Select all
q::
;PROBLEM: attempt to show ToolTip offscreen but appears in bottom-left corner
ToolTip, HELLO, 0, % A_ScreenHeight
WinGet, hWnd, ID, ahk_class tooltips_class32
WinGetPos, , , vPosW, vPosH, ahk_id %hWnd%
Sleep 1000
WinMove, ahk_id %hWnd%, , % (A_ScreenWidth-vPosW)/2, % (A_ScreenHeight-vPosH)/2
MsgBox % vPosW " " vPosH
ToolTip
Menu, EditMenu, Add, &My Item, MyItem
Menu, EditMenu, Add ;------------------------------
Menu, EditMenu, Add, &Undo, EditUndo
Menu, EditMenu, Add ;------------------------------
Menu, EditMenu, Add, Cu&t, EditCut
Menu, EditMenu, Add, &Copy, EditCopy
Menu, EditMenu, Add, &Paste, EditPaste
Menu, EditMenu, Add, &Delete, EditDelete
Menu, EditMenu, Add ;------------------------------
Menu, EditMenu, Add, Select &All, EditSelectAll
;PROBLEM: it seems that while the Menu is showing SetTimer doesn't work
SetTimer, GetMenuPos, -1
;PROBLEM: attempt to show Menu offscreen but appears in bottom-left corner
Menu, EditMenu, Show, 0, % A_ScreenHeight
WinMove, ahk_id %hWnd%, , % (A_ScreenWidth-vPosW)/2, % (A_ScreenHeight-vPosH)/2
Sleep 1000
MsgBox % vPosW " " vPosH
JEE_RetX()
GetMenuPos:
ToolTip GetMenuPos
WinGet, hWnd, ID, ahk_class #32768
WinGetPos, , , vPosW, vPosH, ahk_id %hWnd%
Return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: measure Menu/ToolTip/GUI dimensions before showing
Sadly, I see it blinkjeeswg wrote:Some problems with workaround attempts for Menu/ToolTip commands,
to show a Menu/ToolTip offscreen, and retrieve dimensions, prior to showing onscreen:
Code: Select all
#singleinstance force
#warn
Coordmode Tooltip, Screen
Tooltip % "Hello World!`nMultiline", 0, 0
WinGet hwnd, ID, ahk_class tooltips_class32
DllCall("ShowWindow", "Ptr", hwnd, "Uint", 0) ; SW_HIDE
VarSetCapacity(rec,4*A_PtrSize)
res := DllCall("GetWindowRect", "Ptr", hwnd, "Ptr", &rec)
posX := NumGet(rec, 0, "UInt")
posY := NumGet(rec, 4, "UInt")
width := NumGet(rec, 8, "UInt") - posX
height := NumGet(rec, 12, "UInt") - posY
msgbox % "Width -> " . width . "`nHeight -> " . height
Return
F1::reload
Esc::
ExitApp
Re: measure Menu/ToolTip/GUI dimensions before showing
One useful Winapi function is AdjustWindowRect/AdjustWindowRectEx, mentioned here:
slightly-improved dialogs - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 86#p208686
slightly-improved dialogs - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 86#p208686
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Who is online
Users browsing this forum: No registered users and 153 guests