Jump to content
chrisser

Get result of control in function

Recommended Posts

chrisser

Hi everybody,

hope you can help me. I want to know, how it is possible to get the result of a control, which is build in a function. The problem is, that i want to this function several times?

Chrisser

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
#include <GuiConstants.au3>



Global $FONT = "Segoe UI"

Local $hGUI = GUICreate("Example")
GUISetBkColor(0xFFFFFF,$hGUI)


_GUICtrlTC_Station_Create(5, 5, "Station 01",$hGUI,$FONT)

_GUICtrlTC_Station_Create(5, 205, "Station 02",$hGUI,$FONT)

GUISetState(@SW_SHOW, $hGUI)





While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop



        EndSwitch

    WEnd









Func _GUICtrlTC_Station_Create($iX, $iY,$StationName,$hWnd,$Fontname)
    $GRREF = GUICtrlCreateGroup("", $iX, $iY, 306, 110)
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($GRREF), "wstr", 0, "wstr", 0)
    $REF = GUICtrlCreateCheckbox($StationName, $iX+5, $iY+82, 85, 20)
    GUICheckBoxSetColor($REF, 0x3C3C3C, 0xFFFFFF, 9)
    $IPADDREF = _GUICtrlIpAddress_Create($hWnd, $iX+90, $iY+15, 160, 25)
    _GUICtrlIpAddress_SetFont($IPADDREF, $Fontname, 12, 400)
    $INPUTUSERNAMEREF = GUICtrlCreateInput("", $iX+90, $iY+45, 160, 25)
    GUICtrlSetFont(-1, 10, 400, 0, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)
    $INPUTPASSWORDREF = GUICtrlCreateInput("", $iX+90, $iY+75, 160, 25, $ES_PASSWORD)
    GUICtrlSetFont(-1, 9, 400, 0, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)
EndFunc









Func GUICheckBoxSetColor(ByRef $CtrlID, $iColor, $iBkColor = "0xF1EDED", $iSize = "10")
    ; SEuBo

    $CtrlHWnd = $CtrlID

    If Not IsHWnd($CtrlHWnd) Then $CtrlHWnd = GUICtrlGetHandle($CtrlID)
    $aParent = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $CtrlHWnd)
    $hOldG = GUISwitch($aParent[0])
    $aCPos = ControlGetPos($aParent[0], "", $CtrlID)
    $sOldT = GUICtrlRead($CtrlID, 1)
    GUICtrlDelete($CtrlID)
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0)
    $CtrlID = GUICtrlCreateCheckbox($sOldT, $aCPos[0], $aCPos[1], $aCPos[2], $aCPos[3])
    GUICtrlSetColor(-1, $iColor)
    GUICtrlSetBkColor(-1, $iBkColor)
    GUICtrlSetFont(-1, $iSize, 400, 0, $FONT)
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 7)
    GUISwitch($hOldG)
EndFunc   ;==>GUICheckBoxSetColor

 

 

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Starstar

Just set the control variable to global.

Global $cntrlid

[Edit::]

And you will be able to read the value of that variable in hole script.

 

Edited by Starstar

Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites
chrisser

Just set the control variable to global.

 

Global $cntrlid

 

 

​mhh.. yeah ..

but my problem is, that I didn´t get the exact result of the control. I have one function and "two" controls. I added some "result"-buttons to test it.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
#include <GuiConstants.au3>


Global $INPUTUSERNAMEREF

Global $FONT = "Segoe UI"

Local $hGUI = GUICreate("Example")
GUISetBkColor(0xFFFFFF,$hGUI)


_GUICtrlTC_Station_Create(5, 5, "Station 01",$hGUI,$FONT)

_GUICtrlTC_Station_Create(5, 205, "Station 02",$hGUI,$FONT)

$return1 = GUICtrlCreateButton("return 1",5,370)
$return2 = GUICtrlCreateButton("return 2",105,370)

GUISetState(@SW_SHOW, $hGUI)





While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

             Case $return1
                MsgBox(0,"",GUICtrlRead($INPUTUSERNAMEREF))
             Case $return2
                MsgBox(0,"",GUICtrlRead($INPUTUSERNAMEREF))
        EndSwitch

    WEnd









Func _GUICtrlTC_Station_Create($iX, $iY,$StationName,$hWnd,$Fontname)

    $GRREF = GUICtrlCreateGroup("", $iX, $iY, 306, 110)
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($GRREF), "wstr", 0, "wstr", 0)
    $REF = GUICtrlCreateCheckbox($StationName, $iX+5, $iY+82, 85, 20)
    GUICheckBoxSetColor($REF, 0x3C3C3C, 0xFFFFFF, 9)
    $IPADDREF = _GUICtrlIpAddress_Create($hWnd, $iX+90, $iY+15, 160, 25)
    _GUICtrlIpAddress_SetFont($IPADDREF, $Fontname, 12, 400)
    $INPUTUSERNAMEREF = GUICtrlCreateInput("", $iX+90, $iY+45, 160, 25)
    GUICtrlSetFont(-1, 10, 400, 0, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)
    $INPUTPASSWORDREF = GUICtrlCreateInput("", $iX+90, $iY+75, 160, 25, $ES_PASSWORD)
    GUICtrlSetFont(-1, 9, 400, 0, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)

EndFunc









Func GUICheckBoxSetColor(ByRef $CtrlID, $iColor, $iBkColor = "0xF1EDED", $iSize = "10")
    ; SEuBo

    $CtrlHWnd = $CtrlID

    If Not IsHWnd($CtrlHWnd) Then $CtrlHWnd = GUICtrlGetHandle($CtrlID)
    $aParent = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $CtrlHWnd)
    $hOldG = GUISwitch($aParent[0])
    $aCPos = ControlGetPos($aParent[0], "", $CtrlID)
    $sOldT = GUICtrlRead($CtrlID, 1)
    GUICtrlDelete($CtrlID)
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0)
    $CtrlID = GUICtrlCreateCheckbox($sOldT, $aCPos[0], $aCPos[1], $aCPos[2], $aCPos[3])
    GUICtrlSetColor(-1, $iColor)
    GUICtrlSetBkColor(-1, $iBkColor)
    GUICtrlSetFont(-1, $iSize, 400, 0, $FONT)
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 7)
    GUISwitch($hOldG)
EndFunc   ;==>GUICheckBoxSetColor

 

 

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Starstar

Please Wait i am examining your script........... 


Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once."

Share this post


Link to post
Share on other sites
Melba23

chrisser,

When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.


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

 

Share this post


Link to post
Share on other sites
chrisser

Okay, thanks :-) I´ll do that..

Btw. Here is my solution:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
#include <GuiConstants.au3>
#include <Array.au3>


Global $INPUTUSERNAMEREF

Global $FONT = "Segoe UI"

Local $hGUI = GUICreate("Example")
GUISetBkColor(0xFFFFFF,$hGUI)


$1 = _GUICtrlTC_Station_Create(5, 5, "Rechner 01",$hGUI,$FONT)

$2 = _GUICtrlTC_Station_Create(5, 205, "Rechner 02",$hGUI,$FONT)

$return1 = GUICtrlCreateButton("return 1",5,370)
$return2 = GUICtrlCreateButton("return 2",105,370)

GUISetState(@SW_SHOW, $hGUI)




While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
             Case $return1
                _ArrayDisplay($1)
                MsgBox(0,"",_GUICtrlIpAddress_Get($1[0]))
                MsgBox(0,"",GUICtrlRead($1[1]))
             Case $return2
                _ArrayDisplay($2)
        EndSwitch
    WEnd



Func _GUICtrlTC_Station_Create($iX, $iY,$StationName,$hWnd,$Fontname)
    Dim $array[5]
    $STATIONGROUP= GUICtrlCreateGroup("", $iX, $iY, 356, 120, $BS_FLAT)
    DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($STATIONGROUP), "wstr", 0, "wstr", 0)
    $STATIONCHK = GUICtrlCreateCheckbox($StationName, $iX+5, $iY+92, 90, 20)
    GUICheckBoxSetColor($STATIONCHK, 0x3C3C3C, 0xFFFFFF, 11)
    $array[0] =GUICtrlCreateLabel("(Name)",$iX+158,$iY+10,190,20)
    GUICtrlSetFont(-1, 9, 400, 2, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)
    $array[1] =GUICtrlCreateLabel("(Firma)",$iX+158,$iY+25,190,20)
    GUICtrlSetFont(-1, 9, 400, 2, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)
    GUICtrlCreateLabel("IP-Adresse:",$iX+115,$iY+45,70,20)
    GUICtrlSetFont(-1, 9, 400, 0, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)
    $array[2] = _GUICtrlIpAddress_Create($hWnd, $iX+185, $iY+43, 160, 20)
    _GUICtrlIpAddress_SetFont($array[0], $Fontname, 12, 400)
    GUICtrlCreateLabel("Benutzer:",$iX+115,$iY+70,90,20)
    GUICtrlSetFont(-1, 9, 400, 0, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)
    $array[3] = GUICtrlCreateInput("", $iX+185, $iY+68, 160, 20)
    GUICtrlSetFont(-1, 10, 400, 0, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)
    GUICtrlCreateLabel("Passwort:",$iX+115,$iY+95,70,20)
    GUICtrlSetFont(-1, 9, 400, 0, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)
    $array[4] = GUICtrlCreateInput("", $iX+185, $iY+92, 160, 20, $ES_PASSWORD)
    GUICtrlSetFont(-1, 9, 400, 0, $FONT)
    GUICtrlSetColor(-1, 0x3C3C3C)

    Return($array)
EndFunc



Func GUICheckBoxSetColor(ByRef $CtrlID, $iColor, $iBkColor = "0xF1EDED", $iSize = "10")
    ; SEuBo
    $CtrlHWnd = $CtrlID
    If Not IsHWnd($CtrlHWnd) Then $CtrlHWnd = GUICtrlGetHandle($CtrlID)
    $aParent = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $CtrlHWnd)
    $hOldG = GUISwitch($aParent[0])
    $aCPos = ControlGetPos($aParent[0], "", $CtrlID)
    $sOldT = GUICtrlRead($CtrlID, 1)
    GUICtrlDelete($CtrlID)
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0)
    $CtrlID = GUICtrlCreateCheckbox($sOldT, $aCPos[0], $aCPos[1], $aCPos[2], $aCPos[3])
    GUICtrlSetColor(-1, $iColor)
    GUICtrlSetBkColor(-1, $iBkColor)
    GUICtrlSetFont(-1, $iSize, 400, 0, $FONT)
    DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 7)
    GUISwitch($hOldG)
EndFunc   ;==>GUICheckBoxSetColor

 

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

×