Jump to content

Recommended Posts

Posted (edited)

I am in need of a workaround, as the script does not support a few functions (especially _DeleteAllItems) if I use the classic function.

I've searched for a UDF version of GUICtrlSetPos but couldn't find one. Google and autoit forum search didn't help.

What can I do?

Here is an example, clearly they both should move together:

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

$gui = GUICreate("")

$w = 50
$list1 = _GUICtrlListView_Create($gui, "Lol", 0, 0, $w, 50)
$list2 = GUICtrlCreateListView("Lol", 0, 70, $w, 50)
$btn1 = GuiCtrlcreatebutton("-", 0, 50, 20, 20)
$btn2 = GuiCtrlcreatebutton("+", 20, 50, 20, 20)
guisetstate()

while 1
    $msg = GUIGetMsg()
    if $msg = $GUI_EVENT_CLOSE then Exit
    if $msg = $btn1 then 
        $w -= 10
        GUICtrlSetPos($list1, 0, 0, $w, 50)
        GUICtrlSetPos($list2, 0, 70, $w, 50)
    EndIf
    if $msg = $btn2 then 
        $w += 10
        GUICtrlSetPos($list1, 0, 0, $w, 50)
        GUICtrlSetPos($list2, 0, 70, $w, 50)
    EndIf
sleep(10)
WEnd

Also a video showing why this is so annoying! It appears to resize the control, but the visible frame is not resized.

http://www.screencast.com/users/RadGH/folders/Jing/media/9dea81df-23ab-4b66-aea2-be2a8c7e80d5

EDIT: Same result with GUI resizing mode

Edited by Rad
  • Moderators
Posted

Rad,

There is a fundamental difference between controls created by the native functions of AutoIt and those created by the UDFs. The former return a ControlID - which are actually index numbers to an internal AutoIt array which looks after them. UDFs return a handle - the unique windows ID for all things that Windows creates. Of course the native-created controls have handles too (that is why you have the GUICtrlGetHandle function :)) but AutoIt shields the user from them.

So you cannot use the standard Autoit GUICtrl* functions to interact with the UDF-created controls - they require a ControlID as a parameter which you do not have - you must use the Win* functions to interact as the following script shows. I also added a couple of lines to bring home the fact that the 2 Create functions return completely different types. Look for the <<<<<<<< lines: :P

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

$gui = GUICreate("")

$w = 50
$list1 = _GUICtrlListView_Create($gui, "Lol", 0, 0, $w, 50)
ConsoleWrite($list1 & @CRLF) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$list2 = GUICtrlCreateListView("Lol", 0, 70, $w, 50)
ConsoleWrite($list2 & @CRLF) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$btn1 = GuiCtrlcreatebutton("-", 0, 50, 20, 20)
$btn2 = GuiCtrlcreatebutton("+", 20, 50, 20, 20)
guisetstate()

while 1
    $msg = GUIGetMsg()
    if $msg = $GUI_EVENT_CLOSE then Exit
    if $msg = $btn1 then
        $w -= 10
        WinMove($list1, "", 0, 0, $w, 50) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        GUICtrlSetPos($list2, 0, 70, $w, 50)
    EndIf
    if $msg = $btn2 then
        $w += 10
        WinMove($list1, "", 0, 0, $w, 50) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        GUICtrlSetPos($list2, 0, 70, $w, 50)
    EndIf
sleep(10)
WEnd

All clear? Please ask if not. :)

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:

  Reveal hidden contents

 

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