Sign in to follow this  
Followers 0
AndyS01

How to make 2 list boxes stretchable

11 posts in this topic

I'm trying to create a GUI with 2 list boxes, one above the other, and I want the user to be able to drag the horizontal line between them to make one list smaller and the other list larger (like Notepad++'s (F8) Output list )
 
Is there a way to do this?
 
Here is my test code that displays 2 lists, but with no provision to drag and resize them:
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
Opt("GUICloseOnESC", 1) ; ESC closes GUI
OnAutoItExitRegister("ExitStageLeft")

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <ListBoxConstants.au3>
#include <EditConstants.au3>

Global $iID_list1, $iID_list2

_Main()
Exit (1)

Func _Main()
    GUICreate("Listbox test", 500, 500)

    GUICtrlCreateButton("Test", 1, 1, 50, 25)

    $iID_list1 = createAndFillList("List 1", 10, 30, 475, 200)
    $iID_list2 = createAndFillList("List 2", 10, 240, 475, 200)

    GUISetState()
    GUISetOnEvent($GUI_EVENT_CLOSE, 'ExitStageLeft')

    While (1)
        Sleep(250)
    WEnd
EndFunc   ;==>_Main

Func createAndFillList($title, $x, $y, $w, $h)
    Local $id, $id_1, $id_2, $id_3, $hWnd, $str

    $id = GUICtrlCreateEdit($title & @CRLF, $x, $y, $w, $h, $WS_VSCROLL)
    $hWnd = GUICtrlGetHandle($id)
    GUICtrlSetFont($id, 9, 400, 0, "Courier New")

    For $cnt = 0 To 15
        $str = $cnt & " - " & $id & " - 1234567890"
        GUICtrlSetData($id, $str & @CRLF, 1)
    Next

    Return ($id)
EndFunc   ;==>createAndFillList

Func ExitStageLeft()
    Exit (0)
EndFunc   ;==>ExitStageLeft

 

Share this post


Link to post
Share on other sites



AndyS01,

You need my GUIFrame UDF - it does exactly what you want. The link is in my sig. :)

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

Great UDF M23!

However, when I put together a test that uses it, I ran into this problem:

If I comment out the call to GUISetOnEvent($GUI_EVENT_CLOSE, ...), nothing gets displayed and I have to do  CTRL-BREAK to get out of it.

If I uncomment this call, my GUI displays correctly.

Note that my code is set up to register handler code, instead of entering a polling loop (I don't know if it's part of the problem or not).

Here is my test code.

Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
Opt("GUICloseOnESC", 1) ; ESC closes GUI
OnAutoItExitRegister("ExitStageLeft")

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

#include "GUIFrame.au3"

;Global $iSep_Pos

_Main()
Exit (1)

Func _Main()
    Local $hGUI, $iFrame_A

    $hGUI = GUICreate("GUI_Frame Example 3", 500, 500, -1, -1, _
            BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))

    ; Register WM_SIZE to simulate the script requiring it
    ;GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

    ; Create a 1st level frame
    $iFrame_A = _GUIFrame_Create($hGUI, 1)

    ; This line sets the minima as absolute values
    ;_GUIFrame_SetMin($iFrame_A, 50, 125, True)

    _GUIFrame_Switch($iFrame_A, 1) ; Switch to the top frame

    ;local $aWinSize
   ; $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_A, 1))
    ;gUICtrlCreateLabel("Green", 5, 45, $aWinSize[0] - 10, $aWinSize[1] - 10)
    ;GUICtrlSetBkColor(-1, 0x00FF00)
    ;GUICtrlCreateLabel("Blue", 70, 220, 50, 50)
    ;GUICtrlSetBkColor(_GUIFrame_GetHandle($iFrame_A, 1), 0x0000FF)
    ;GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    ;GUICtrlSetState(-1, $GUI_DISABLE)

    addButtons("A")

    _GUIFrame_Switch($iFrame_A, 2) ; Switch to the bottom frame
    ;$aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_A, 2))
    ;GUICtrlCreateLabel("Red", 5, 5, $aWinSize[0] - 10, $aWinSize[1] - 10)
    ;GUICtrlSetBkColor(-1, 0xFF0000)
    ;GUICtrlSetState(-1, $GUI_DISABLE)

    addButtons("B")

    GUISetOnEvent($GUI_EVENT_CLOSE, 'ExitStageLeft', $hGUI)

    GUISetState()

    While 1
        Sleep(250)
    WEnd
EndFunc   ;==>_Main

Func addButtons($which)
    Local $x, $id

    For $x = 1 To 5
        $id = GUICtrlCreateButton("Button" & $which & $x, 10, $x * 25)
        GUICtrlSetOnEvent($id, "handle_button_press")
    Next
EndFunc   ;==>addButtons

; This is the already registered WM_SIZE handler
Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    ; Just call the GUIFrame resizing function here - do NOT use the _GUIFrame_ResizeReg function in the script
    _GUIFrame_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam)
    Return "GUI_RUNDEFMSG"

EndFunc   ;==>_WM_SIZE

Func ExitStageLeft()
    Exit
EndFunc   ;==>ExitStageLeft

Func handle_button_press()
    ConsoleWrite("+++: Button pressed" & @CRLF)
    Exit
EndFunc   ;==>handle_button_press

Share this post


Link to post
Share on other sites

AndyS01,

The problem is that you are not defining the GUI when you use GUISetState - leaving it blank as you do means that it refers to the last created GUI (the bottom frame). ;)

Either display the main GUI immediately:

$hGUI = GUICreate("GUI_Frame Example 3", 500, 500, -1, -1, _
    BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState()
Or add a handle to the command if you want to leave it where it is:

GUISetState(@SW_SHOW, $HGUI)
Both of those work fine for me. :)

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

Nope, that didn't work.  I changed the line to read "GUISetState(@SW_SHOW, $HGUI)", but when I commented out the "GUISetOnEvent" line, I still couldn't make the 'x' work.

This may seem to be a trivial issue, but that's because I've isolated the problem to a single test code file.

In actuality, I'm trying to integrate the GUIFrame UDF into a working script that currently has many on-screen controls, and a listbox (my 'console' output) below them.  I want to be able to view/hide the console listbox usung a menu checkbox.  When I hide it, I want to stretch the top part down to the bottom of the GUI.

When I integrated the GUIFrame UDF into this script, I had 2 immediate problems:

1) The 'x' button issue

2) When I click on my Exit button, all of my controls disappear, but I'm left with a blank 2-frame GUI.

I can send you me script if you want me to.

Andy

 

Share this post


Link to post
Share on other sites

AndyS01,

 

when I commented out the "GUISetOnEvent" line, I still couldn't make the 'x' work

That is hardly surprising - if there is no event attached to the GUI [X] how do you expect the script to react when the $GUI_EVENT_CLOSE message is fired? :huh:

I suggest you post your script - or send it to me via PM - and I will investigate further. :)

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

Duh!!  I was too close to the trees  (!)

I don't know how to send a zip file via PM.  I'll try to send the .zip file using attachments

Share this post


Link to post
Share on other sites

Did you get the attachment?

Share this post


Link to post
Share on other sites

Updated my main script to make the inclusion of GUIFrame stuff optional, depending on a boolean in the Global variables section.

Share this post


Link to post
Share on other sites

AndyS01,

I received no PM from you - so certainly no attachment. :(

If you want to attach something to a PM, you need to use the "Attach Files" button which is underneath the editor itself. But you need to have selected the "Full Editor" option for it to appear. ;)

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