Jump to content

WinAPI Control hwnd to pseudo AutoIt hwnd?

Recommended Posts

So I just noticed that AutoIt uses a sort of pseudo ctrl handle when creating GUI controls after attempting to manipulate a control via a hwnd from an API call, is there any way of working with these handles with native autoit functions without having to do everything with API calls?

For instance, I ran up on this while inserting a list view item at a position in a list view control when I noticed that the handle to manipulate the control returned by the API call was invalid for manipulation through the AutoIt native functions, such as GUICTRLDelete(), rendering me with only an option to continue manipulating the control via API calls which is not very nice at all.

Any work around on this? :‏)

Link to post
Share on other sites

I'm not sure if I get the question right. Control's are either identifed by their control ID (unique to the program) or their handle (unique for all windows).

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WinApi.au3>
#include <WindowsConstants.au3>
Local $msg
$hGUI = GUICreate("Parent GUI")
$c_Label_1 = GUICtrlCreateLabel("TestMessageBox #1", 10, 10, 100)
$c_Label_2 = GUICtrlCreateLabel("TestMessageBox #2", 10, 40, 100)
GUISetState(@SW_SHOW) ; will display an empty dialog box
ConsoleWrite($c_Label_1 & @crlf)
ConsoleWrite(ControlGetHandle($hGUI,"",$c_Label_1) & @crlf)
ConsoleWrite(_WinAPI_GetWindowLong(ControlGetHandle($hGUI,"",$c_Label_1), $GWL_ID) & @crlf)
ConsoleWrite($c_Label_2 & @crlf)
ConsoleWrite(ControlGetHandle($hGUI,"",$c_Label_2) & @crlf)
ConsoleWrite(_WinAPI_GetWindowLong(ControlGetHandle($hGUI,"",$c_Label_2), $GWL_ID) & @crlf)
While 1
 $msg = GUIGetMsg()
 If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Link to post
Share on other sites

This guy was having the same problem as me, thanks for the help KaFu, but as it seems, you cannot interact with control handles returned by an api call using a native autoit control handling function. I guess my options are to rewrite a lot of code since this seems to be the case :)

Link to post
Share on other sites
  • Developers

Anyway, I'd also like to know how I can set the dock auto state to a control created with an API call.

Would be helpful when you read our rules and stop creating extra work for us by quoting Spam posts in replies. Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
Live for the present,
Dream of the future,
Learn from the past.

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...