Jump to content

Changing Window's on Button Click.


Recommended Posts

I am trying to get my gui to change the content displayed with a button click. I guess it could be described as changing the content of a category. I made a very basic illustration. Lol

Untitled.png

What I am basically trying to do, is that when a button is clicked in Window 1, Window 2 changes to whatever content I set to show. If button 2 is clicked, then it changes to other content. Kind of like the iFrame in HTML.

Link to comment
Share on other sites

  • Moderators

ReconX,

My GUIExtender UDF (look for the link in my sig) sounds like just what you need. :)

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 comment
Share on other sites

  • Moderators

ReconX,

I suggest you read the Adding UDFs to AutoIt and SciTE tutorial in the Wiki carefully and then, once you have done what it suggests in the first couple of paragraphs, download the UDF from the thread to which I linked, add it to your personal include folder, and add #include <GUIExtender.au3> to the top of your file. :)

If you still have doubts, ask again and we will go through it step by step. ;)

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 comment
Share on other sites

Thank's M23. I am looking at your "GUIExtender_Example_Object_Tab" file. It does look like what I am looking for, although, I would like to open up a script instead of the web page. How would I edit this script to do so?

Global $oIE_1 = _IECreateEmbedded()
Global $hIE_1 = GUICtrlCreateObj($oIE_1, 10, 50, 730, 350)
_IENavigate ($oIE_1, "http://www.autoitscript.com")
_GUIExtender_Obj_Data($hIE_1, $oIE_1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< New function
Link to comment
Share on other sites

  • Moderators

ReconX,

I think you have misunderstood the function of the UDF. You create a GUI which already holds all of the controls you need in the different sections and then just display the section(s) you need when required. No need to "open up a script" - everything is already in the original script. ;)

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 comment
Share on other sites

I think I am getting the hang of it. I just want to make sure if this seems like a legit format so I don't run into problems down the road.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <array.au3>
#include <MsgBoxConstants.au3>

#include "GUIExtender.au3"

; An array to hold the label ControlIDs
Global $aLabel[6]
; A variable to show the last label which changed colour
Global $iLastLabel = 0
Global $aText[6] = ["Virus Removal Tools", "Optimizations", "Third label", "Fourth label", "Fifth label", "Sixth label"]

$hGUI = GUICreate("Test", 900, 600)

_GUIExtender_Init($hGUI)

For $i = 0 To 5
    $aLabel[$i] = GUICtrlCreateLabel($aText[$i], 0, 0 + (75 * $i), 450, 70, BitOR($SS_CenterImage, $SS_Center))
    GUICtrlSetBkColor($aLabel[$i], $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont(-1, 16, 800)
    GUICtrlSetColor(-1, 0x000000)

Next

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $aLabel[0]
            ; Begin Label 0 Content

            _GUIExtender_Section_Start($hGUI, 100, 370)
            _GUIExtender_Section_Action($hGUI, 1)

            Global $wLabel = GUICtrlCreateLabel("Category 1", 600, 50, 100, 20)
            GUICtrlSetBkColor(-1, 0xFFFFFF)
            Global $oObj = GUICtrlCreateObj($wLabel, 10, 50, 730, 350)
            _GUIExtender_Obj_Data($oObj, $wLabel) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< New function

            _GUIExtender_Section_End($hGUI)

            ; End Label 0 Content
        Case $aLabel[1]
            ; Begin Label 1 Content

            _GUIExtender_Section_Start($hGUI, 100, 370)
            _GUIExtender_Section_Action($hGUI, 1)

            Global $wLabel = GUICtrlCreateLabel("Category 2", 600, 50, 100, 20)
            GUICtrlSetBkColor(-1, 0xFF0000)
            Global $oObj = GUICtrlCreateObj($wLabel, 10, 50, 730, 350)
            _GUIExtender_Obj_Data($oObj, $wLabel) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< New function

            _GUIExtender_Section_End($hGUI)

            ; End Label 1 Content
    EndSwitch

    ; Get cursor info
    $aCInfo = GUIGetCursorInfo($hGUI)
    ; loop through the label array to see which one is under the cursor
    For $i = 0 To 5
        ; If we are over a new label
        If $aCInfo[4] = $aLabel[$i] And $iLastLabel <> $i Then
            ; Recolour previos label
            GUICtrlSetBkColor($aLabel[$iLastLabel], $GUI_BKCOLOR_TRANSPARENT)
            ; colour current label
            GUICtrlSetBkColor($aLabel[$i], 0x0066FF)
            ; Store this label
            $iLastLabel = $i
            ; No point in looking further
            ExitLoop
        EndIf

    Next

WEnd

If I wanted to set a default one to load up when the program starts, I would just copy the first label content and add it to the beginning of the script, right?

Thank you for your help Melba23, you have really taught me a lot.

Edited by ReconX
Link to comment
Share on other sites

Hello, I am creating this GUI for myself, and I have been using Melba23's GUIExtender.au3. Everytime I click a button, the GUI that is scripted to that button appears, but if I click the next button, that script pops up over the first script and it stays. I guess what I am trying to ask, is there a way to clear the original buttons content before displaying another button? The code is listed below for reference. The first two buttons work, "Virus Removal Software" and "Optimizations". Thanks! 

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <array.au3>
#include <MsgBoxConstants.au3>

#include "GUIExtender.au3"

; An array to hold the label ControlIDs
Global $aLabel[6]
; A variable to show the last label which changed colour
Global $iLastLabel = 0
Global $aText[6] = ["Virus Removal Tools", "Optimizations", "Third label", "Fourth label", "Fifth label", "Sixth label"]

$hGUI = GUICreate("Test", 750, 444)
$hPic = GUICtrlCreatePic(@DesktopDir & "\GUI BG.jpg", 0, 0, 750, 444)
GUICtrlSetState($hPic, $GUI_DISABLE)


_GUIExtender_Init($hGUI)

For $i = 0 To 5
    $aLabel[$i] = GUICtrlCreateLabel($aText[$i], 1, 88 + (50 * $i), 203, 40, BitOR($SS_CenterImage, $SS_Center))
    GUICtrlSetBkColor($aLabel[$i], $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont(-1, 11, 800)
    GUICtrlSetColor(-1, 0x000000)

Next

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $aLabel[0]
            ; Begin Label 0 Content

            _GUIExtender_Section_Start($hGUI, 100, 370)
            _GUIExtender_Section_Action($hGUI, 1)

            Global $wLabel = GUICtrlCreateLabel("Category 1", 228, 46, 497, 372)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            Global $oObj = GUICtrlCreateObj($wLabel, 10, 50, 730, 350)
            _GUIExtender_Obj_Data($oObj, $wLabel) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< New function

            _GUIExtender_Section_End($hGUI)

            ; End Label 0 Content
        Case $aLabel[1]
            ; Begin Label 1 Content

            _GUIExtender_Section_Start($hGUI, 100, 370)
            _GUIExtender_Section_Action($hGUI, 1)

            Global $wLabel = GUICtrlCreateLabel("Category 2" & @CRLF & "Still here if button 1 is clicked", 228, 46, 497, 372)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            Global $oObj = GUICtrlCreateObj($wLabel, 10, 50, 730, 350)
            _GUIExtender_Obj_Data($oObj, $wLabel) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< New function

            _GUIExtender_Section_End($hGUI)

            ; End Label 1 Content
    EndSwitch

    ; Get cursor info
    $aCInfo = GUIGetCursorInfo($hGUI)
    ; loop through the label array to see which one is under the cursor
    For $i = 0 To 5
        ; If we are over a new label
        If $aCInfo[4] = $aLabel[$i] And $iLastLabel <> $i Then
            ; Recolour previos label
            GUICtrlSetBkColor($aLabel[$iLastLabel], $GUI_BKCOLOR_TRANSPARENT)
            ; colour current label
            GUICtrlSetBkColor($aLabel[$i], 0x0066FF)
            ; Store this label
            $iLastLabel = $i
            ; No point in looking further
            ExitLoop
        EndIf

    Next

WEnd
Link to comment
Share on other sites

  • Moderators

ReconX,

 

I think I am getting the hang of it.

Not at all I am afraid - as that does not look even close to the format of the UDF examples how do you expect it to work? :(

As I stated above, you create the whole GUI initially and then extend/retract sections as the script progresses. You are creating the additional sections within your While...WEnd loop - which will not work. Let me play with the code for a bit and see if I can come up with something for you. :)

M23

Edit: And I have merged your other thread with this one - let us stick to just the one at a time. ;)

Edited by Melba23

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 comment
Share on other sites

  • Moderators

ReconX,

Here is what I think you want - the first 3 "buttons" work:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <array.au3>
#include <MsgBoxConstants.au3>

#include "GUIExtender.au3"

; An array to hold the label ControlIDs
Global $aLabel[6]
; A variable to show the last label which changed colour
Global $iLastLabel = 0
Global $aText[6] = ["Virus Removal Tools", "Optimizations", "Third label", "Fourth label", "Fifth label", "Sixth label"]

$hGUI = GUICreate("Test", 1560, 600) ; Why 1560?  See below!

_GUIExtender_Init($hGUI, 1) ; Set horizontal extension

; This permanent section does not need any special code
For $i = 0 To 5
    $aLabel[$i] = GUICtrlCreateLabel($aText[$i], 0, 0 + (75 * $i), 450, 70, BitOR($SS_CenterImage, $SS_Center))
    GUICtrlSetBkColor($aLabel[$i], $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont(-1, 16, 800)
    GUICtrlSetColor(-1, 0x000000)
Next

; Now we start creating the extendable sections

$iSection_1 = _GUIExtender_Section_Start($hGUI, 450, 370) ; Starts 450 pixels in and is 370 pixels wide
_GUIExtender_Section_Action($hGUI, $iSection_1)
Global $cLabel = GUICtrlCreateLabel("Category 1", 450, 0, 370, 600) ; position is inside the whole GUI, not the section itself
GUICtrlSetBkColor(-1, 0xFFCCCC)
;Global $oObj = GUICtrlCreateObj($wLabel, 10, 50, 730, 350)
;_GUIExtender_Obj_Data($oObj, $wLabel)                                 ; No idea what this is for
_GUIExtender_Section_End($hGUI)

$iSection_2 = _GUIExtender_Section_Start($hGUI, 820, 370) ; Starts 820 pixels in and is 370 pixels wide - note it starts as the previous section ends
_GUIExtender_Section_Action($hGUI, $iSection_2)
Global $cLabel = GUICtrlCreateLabel("Category 2", 820, 0, 370, 600)
GUICtrlSetBkColor(-1, 0xCCFFCC)
_GUIExtender_Section_End($hGUI)

$iSection_3 = _GUIExtender_Section_Start($hGUI, 1190, 370) ; Starts 1190 pixels in and is 370 pixels wide - so whole GUI needs to be 1560 wide
_GUIExtender_Section_Action($hGUI, $iSection_3)
Global $cLabel = GUICtrlCreateLabel("Category 3", 1190, 0, 370, 600)
GUICtrlSetBkColor(-1, 0xCCCCFF)
_GUIExtender_Section_End($hGUI)

; Leave section_1 extended
Global $iCurrent_Extended = $iSection_1
; Retract sections 2 & 3
_GUIExtender_Section_Extend($hGUI, $iSection_2, False)
_GUIExtender_Section_Extend($hGUI, $iSection_3, False)

GUISetState()

; Set the GUI to the centre of the screen - we cannot do this automatically as the whole GUI is far too wide
WinMove($hGUI, "", (@DesktopWidth - (450 + 370)) / 2, (@DesktopHeight - 600) / 2)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $aLabel[0]
            ; We want Section_1 to display
            _Display_Section(1)
        Case $aLabel[1]
            ; We want Section_2 to display
            _Display_Section(2)
        Case $aLabel[2]
            ; We want Section_3 to display
            _Display_Section(3)
    EndSwitch

    ; Get cursor info
    $aCInfo = GUIGetCursorInfo($hGUI)
    ; loop through the label array to see which one is under the cursor
    For $i = 0 To 5
        ; If we are over a new label
        If $aCInfo[4] = $aLabel[$i] And $iLastLabel <> $i Then
            ; Recolour previos label
            GUICtrlSetBkColor($aLabel[$iLastLabel], $GUI_BKCOLOR_TRANSPARENT)
            ; colour current label
            GUICtrlSetBkColor($aLabel[$i], 0x0066FF)
            ; Store this label
            $iLastLabel = $i
            ; No point in looking further
            ExitLoop
        EndIf

    Next

WEnd

Func _Display_Section($iSection)

    ; Check this section is not already extended
    If $iSection = $iCurrent_Extended Then Return

    ; Retract current section
    _GUIExtender_Section_Extend($hGUI, $iCurrent_Extended, False)
    ; Extend required section
    _GUIExtender_Section_Extend($hGUI, $iSection)
    ; Set new current section
    $iCurrent_Extended = $iSection

EndFunc
Is it close? :)

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 comment
Share on other sites

Sorry I have been MIA, lmao. It is close, although I do not want half the screen as a different window. I do want the window that changes upon clicking a button to be resizeable.

Thanks in advanced. :)

Link to comment
Share on other sites

  • Moderators

ReconX,

 

I do not want half the screen as a different window

The adjust the size of the various sections to give you the width you require, although the height is always fixed. I just made all of the sections 370 pixels wide as an example, you can set any width you wish for each section - but you will have to recalculate all the start points to match. :)

 

I do want the window that changes upon clicking a button to be resizeable

Alas this is not possible with my UDF - the section sizes are fixed on GUI creation. :(

It sounds like you need some code which produces separate child GUIs when the buttons are clicked - these can then be dynamically resized as required. ;)

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 comment
Share on other sites

  • Moderators

ReconX,

Perhaps something like this might be what you are looking for: ;)

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

; Additional GUI
Global $hGUI_Add = 9999
; Set distance from edge of window where resizing is possible
Global Const $iMargin = 4
; Set min/max size for add GUI
Global $iGUIMinX = 50, $iGUIMinY = 50, $iGUIMaxX = 300, $iGUIMaxY = 300

Global $iX, $iY

; An array to hold the label ControlIDs
Global $aLabel[6]
; A variable to show the last label which changed colour
Global $iLastLabel = 0
Global $aText[6] = ["Virus Removal Tools", "Optimizations", "Third label", "Fourth label", "Fifth label", "Sixth label"]

$hGUI = GUICreate("Test", 450, 600)

For $i = 0 To 5
    $aLabel[$i] = GUICtrlCreateLabel($aText[$i], 0, 0 + (75 * $i), 450, 70, BitOR($SS_CenterImage, $SS_Center))
    GUICtrlSetBkColor($aLabel[$i], $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont(-1, 16, 800)
    GUICtrlSetColor(-1, 0x000000)
Next

GUISetState()

; Register message handlers
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") ; For resize
GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor") ; For cursor type change
GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; For GUI size limits
GUIRegisterMsg($WM_MOVE, "_WM_MOVE") ; For GUI move synchro

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $aLabel[0]
            ; Remove any existing additional GUI
            GUIDelete($hGUI_Add)
            $hGUI_Add = 9999
            ; Create new add GUI - set width, height and colour
            _Create_GUIAdd(200, 200, 0xFFCCCC)
            ; Set required max size of add GUI
            $iGUIMaxX = 300
            $iGUIMaxY = 300
        Case $aLabel[1]
            GUIDelete($hGUI_Add)
            $hGUI_Add = 9999
            _Create_GUIAdd(400, 300, 0xCCFFCC)
            $iGUIMaxX = 500
            $iGUIMaxY = 600
        Case $aLabel[2]
            GUIDelete($hGUI_Add)
            $hGUI_Add = 9999
            _Create_GUIAdd(100, 500, 0xCCCCFF)
            $iGUIMaxX = 400
            $iGUIMaxY = 500

    EndSwitch

    ; Get cursor info
    $aCInfo = GUIGetCursorInfo($hGUI)
    ; loop through the label array to see which one is under the cursor
    For $i = 0 To 5
        ; If we are over a new label
        If $aCInfo[4] = $aLabel[$i] And $iLastLabel <> $i Then
            ; Recolour previos label
            GUICtrlSetBkColor($aLabel[$iLastLabel], $GUI_BKCOLOR_TRANSPARENT)
            ; colour current label
            GUICtrlSetBkColor($aLabel[$i], 0x0066FF)
            ; Store this label
            $iLastLabel = $i
            ; No point in looking further
            ExitLoop
        EndIf

    Next

WEnd

Func _Create_GUIAdd($iW, $iH, $iCol)

    ; Get position of main GUI
    $aPos = WinGetPos($hGUI)
    $iX = $aPos[0]
    $iY = $aPos[1]
    $iX_Add = $iX + $aPos[2]
    $iY_Add = $iY
    ; Create add GUI
    $hGUI_Add = GUICreate("", $iW, $iH, $iX_Add, $iY_Add, $WS_POPUP, Default, $hGUI)
    GUISetBkColor($iCol)
    GUISetState()

EndFunc   ;==>_Create_GUIAdd

Func _WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    ; If main GUI moved then synchro movement of add GUI
    If $hWnd = $hGUI Then
        _SynchroGUIs()
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc  ;==>_WM_MOVE

Func _SynchroGUIs()

    ; Get position of main GUI
    Local $aPos = WinGetPos($hGUI)
    ; Has it moved
    If $aPos[0] <> $iX Or $aPos[1] <> $iY Then
        ; Move add GUI to follow
        $iX = $aPos[0]
        $iY = $aPos[1]
        $iX_Add = $aPos[0] + $aPos[2]
        $iY_Add = $aPos[1]
        WinMove($hGUI_Add, "", $iX_Add, $iY_add)
    ; Look for minimize/restore and synchro add GUI
    ElseIf ($aPos[0] <> $iX Or $aPos[1] <> $iY) And BitAND(WinGetState($hGUI), 16) Then
        WinSetState($hGUI_Add, "", @SW_MINIMIZE)
    ElseIf ($aPos[0] <> $iX Or $aPos[1] <> $iY) And BitAND(WinGetState($hGUI), 2) Then
        WinSetState($hGUI_Add, "", @SW_RESTORE)
    EndIf
EndFunc  ;==>_SynchroGUIs


; Check cursor type and resize/drag window as required
Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    ; if cursor is set for resizing
    Local $iCursorType = _GetBorder()
    If $iCursorType > 0 Then
        ; Resize add GUI
        $iResizeType = 0xF000 + $iCursorType
        _SendMessage($hGUI_Add, $WM_SYSCOMMAND, $iResizeType, 0)
    EndIf
EndFunc   ;==>_WM_LBUTTONDOWN

; Set cursor to correct resizing form if mouse is over a border
Func _SetCursor()
    Local $iCursorID
    Switch _GetBorder()
        Case 0
            $iCursorID = 2
        Case 1, 2
            $iCursorID = 13
        Case 3, 6
            $iCursorID = 11
        Case 5, 7
            $iCursorID = 10
        Case 4, 8
            $iCursorID = 12
    EndSwitch
    GUISetCursor($iCursorID, 1)
EndFunc   ;==>_SetCursor

; Determines if mouse cursor over a border
Func _GetBorder()
    ; Check if add GUI exists
    If Not IsHWnd($hGUI_Add) Then Return
    ; Get data
    Local $aCurInfo = GUIGetCursorInfo($hGUI_Add)
    Local $aWinPos = WinGetPos($hGUI_Add)
    Local $iSide = 0
    Local $iTopBot = 0
    ; If over right side
    If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2
    ; If over bottom
    If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6
    ; No need to check for left and top
    Return $iSide + $iTopBot
EndFunc   ;==>_GetBorder

; Set min and max GUI sizes
Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
    $tMinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($tMinMaxInfo, 7, $iGUIMinX)
    DllStructSetData($tMinMaxInfo, 8, $iGUIMinY)
    DllStructSetData($tMinMaxInfo, 9, $iGUIMaxX)
    DllStructSetData($tMinMaxInfo, 10, $iGUIMaxY)
    Return 0
EndFunc   ;==>_WM_GETMINMAXINFO
A fair bit more work to do, but how does that look as a basis? :)

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 comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...