Automatically Focus a GUI On Mouseover? Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
MaxAstro
Posts: 381
Joined: 05 Oct 2016, 13:00

Automatically Focus a GUI On Mouseover?

13 Nov 2017, 15:53

Off Topic: The new help database is fantastic. However, no longer using Google search does make it harder to find some things - used to be old forum posts with similar issues could relatively easily be tracked down, now that feature is sadly lacking. Obviously unless I just go to Google, yes, I know. :)

On Topic: Alright here's the situation. I have a GUI that I've embedded into another window, by using DllCall("SetParent", "ptr", hChild1, "ptr", hParent) in order to make it seem like the GUI is a natural part of the parent window.

Unfortunately, the GUI has buttons that have tooltips, and these tooltips will only display if the GUI, not the parent window, has focus. Is there a clean way to bring the GUI into focus when it is moused over, but only if the parent window is active? I suppose I could do it with something like a SetTimer loop that constantly checks the mouse position, I'm just wondering if there is a solution smoother then that. Alternatively, if there is a way for the buttons (they are toolbar buttons from Pulover's toolbar library) to show their tooltips when the parent window has focus, that would work, too.
just me
Posts: 4862
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Automatically Focus a GUI On Mouseover?  Topic is solved

14 Nov 2017, 04:30

Try to use the Parent option instead of SetParent() or
SetParent wrote:Remarks

An application can use the SetParent function to set the parent window of a pop-up, overlapped, or child window.

If the window identified by the hWndChild parameter is visible, the system performs the appropriate redrawing and repainting.

For compatibility reasons, SetParent does not modify the WS_CHILD or WS_POPUP window styles of the window whose parent is being changed. Therefore, if hWndNewParent is NULL, you should also clear the WS_CHILD bit and set the WS_POPUP style after calling SetParent. Conversely, if hWndNewParent is not NULL and the window was previously a child of the desktop, you should clear the WS_POPUP style and set the WS_CHILD style before calling SetParent.

When you change the parent of a window, you should synchronize the UISTATE of both windows. For more information, see WM_CHANGEUISTATE and WM_UPDATEUISTATE.

Source: SetParent
Remaining with AHK 1.1.25.02 until v2 will become beta.
MaxAstro
Posts: 381
Joined: 05 Oct 2016, 13:00

Re: Automatically Focus a GUI On Mouseover?

14 Nov 2017, 12:53

So if I understand correctly I need to call WM_UPDATEUISTATE with a new state of UISF_ACTIVE on the parent window, and that should synchronize the child window?

I'm already clearing WS_CHILD and WS_POPUP; that was in the block of code I borrowed for this trick. I'm still pretty new to using messages and DLL calls, though.

EDIT: Setting Parent in the GUI parameters instead of using a DllCall seems to work, so I'm just going to go with that instead of messing about with messages.

Return to “Ask For Help”

Who is online

Users browsing this forum: Capn Odin, scrivock, TAC109 and 51 guests