Sign in to follow this  
Followers 0
Rad

_GUICtrlListView_Create() cannot be resized by GUICtrlSetPos

2 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


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
Sign in to follow this  
Followers 0