Jump to content

[SOLVED] ControlFocus() + _WinAPI_CallWindowProc() = unexpected window resize


Recommended Posts

Hello.

When both ControlFocus() and _WinAPI_CallWindowProc() used, Autoit window get's resized to full height of the monitor when it's not in focus and click on the bottom or top edge of the window, while cursor is changed to resize:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $hGUI = GUICreate("test", 400, 200, 200, 200, $WS_SIZEBOX)
Global $hLabel = GUICtrlGetHandle(GUICtrlCreateLabel("test", 0, 0))
ControlFocus($hGUI, "", $hLabel)
GUISetState()

$wProcHandle = DllCallbackRegister("_WindowProc", "int", "hwnd;uint;wparam;lparam")
$wProcOld = _WinAPI_SetWindowLong($hLabel, $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle))

While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

_WinAPI_SetWindowLong($hLabel, $GWL_WNDPROC, $wProcOld)
DllCallbackFree($wProcHandle)
GUIDelete($hGui)
Exit

Func _WindowProc($hWnd, $Msg, $wParam, $lParam)
    Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $Msg, $wParam, $lParam)
EndFunc

Just click outside of "test" window so it's no longer active, then move cursor to the bottom edge until it changes to arrow up/down and click, the window stretches all across the screen.

If any of these two lines removed, it fixes the issue. Any ideas why this happening?

Windows 10 x64 1909, Autoit 3.3.14.5

[EDIT]

this issue has been fixed in Autoit v3.3.15.1

 

 

Edited by VAN0
Link to post
Share on other sites
  • Moderators

VAN0,

I am afraid i cannot reproduce the effect on my Win10 x64 machine with v3.3.14.5. The cursor certainly changes (as I would expect) but clicking merely activates the GUI - there is no change in size.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
  • Moderators

VAN0,

Yes.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Yes,  I minimized every windows.   Then I clicked your window to make it focus.  Then I clicked on the desktop a few times to make sure your window was out of focus.  Then I went to the bottom edge and clicked it, and nothing happened (except usual behavior).

Edited by Nine
Link to post
Share on other sites

Well, not sure than. That video I recorded on freshly installed Windows 10, all default settings, only freshly downloaded and installed Autoit, SciTE and CamStudio.

Also tested it on not-so-fresh Windows 7 32bit - same issue.

At the moment my theory is somehow that window is treating single click on the edge as double click when it get focused (I bet not many people know this Windows feature, when you can double click on top/bottom edge of a window to stretch it vertically). If it doesn't for you, perhaps there is some kind of setting disabled in Windows itself, that would explain why this issue doesn't reproduce.

Link to post
Share on other sites

After further investigation I can confirm it's in fact the double click issue.

However ControlFocus() doesn't seem to play any role in this.

Here is another example:
 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $hGUI = GUICreate("test", 400, 200, 0, 0, $WS_SIZEBOX)
GUISetState()

$wProcHandle = DllCallbackRegister("_WindowProc", "int", "hwnd;uint;wparam;lparam")
$wProcOld = _WinAPI_SetWindowLong($hGUI, $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle))

While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

_WinAPI_SetWindowLong($hGUI, $GWL_WNDPROC, $wProcOld)
DllCallbackFree($wProcHandle)
GUIDelete($hGUI)
Exit

Func _WindowProc($hWnd, $iMsg, $wParam, $lParam)
    If $iMsg = $WM_LBUTTONDBLCLK Then MsgBox("", "Double Click!", "You double clicked!")
    Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $iMsg, $wParam, $lParam)
EndFunc

To confirm it's working: double click inside the window, it should show a message box. Than as before, single click inside the window while it was NOT in focus, it still shows message box for me.

Link to post
Share on other sites
  • Moderators

VAN0,

Nope, single clicking in the non-focused window still just activates it for me - no MsgBox appears. There must be something very strange going on in your setup.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

Very strange indeed. And just to confirm, actual double click inside the window does produce message box? and double click on bottom edge stretches it across the screen, on your system?

And I've tested so far on 3 different physical computers and 2 virtual, same reproducible result everywhere.

P.S.

Well, at least I'm not alone on this one:

 

Edited by VAN0
Link to post
Share on other sites

Hello.

I get the issue using AutoIt 3.3.14.5

No issue using Beta AutoIt 3.3.15.1

 

Try using Beta and check if you get the issue.

Saludos

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...