Jump to content

Lots of Buttons on the GUI each needs to paste (add data) to a GUICtrlCreateInput data field.


Recommended Posts

right now the way i have is

GUICtrlSetOnEvent($icons[26], "TEST")

FUNC TEST()
    $tempdata = (GUICtrlRead($MSGINPUTS))
    $tempdata2 = $tempdata & "{w}" <---- this is the button text i need a better way.
    GUICtrlSetData($MSGINPUTS, $tempdata2)
EndFunc

what i need to insert each time is the Button text (every time i press the button)

and i want to paste the data into the current datafield inside the gui (I can have a few control where there is a place to insert data)

this is not so good -i have over 50 icons on the GUI -i dont want to make a function for each one.

any way you can think about that is better?

thanks

Edited by mrbig1479
Link to comment
Share on other sites

1) Create your buttons as an array

2) Check to see if a button was clicked

3) Execute the function with an argument

Dim $aButton[51], $aButtonText[51]

;$aButton[1] = GUICtrlCreateButton ...
;$aButtonText[1] = "specific text"
;.
;.
;.
;$aButton[51] = GUICtrlCreateButton ...
;$aButtonText[51] = "specific text"

While 1
   $nMsg = GUIGetMsg()

   If $nMsg <> 0
      For $nCount=1 To 51
         If $aButton[$nCount] = $nMsg
        ;means that button was clicked
         TEST($aButtonText[$nCount])
         EndIf
      Next 
   EndIf

   Select 
      Case  $nMsg = $GUI_EVENT_CLOSE
         Exit
   EndSelect

WEnd

FUNC TEST($sSpecificData)
    $tempdata = (GUICtrlRead($MSGINPUTS))
    $tempdata2 = $tempdata & $sSpecificData;<---- this is the button text i need a better way.
    GUICtrlSetData($MSGINPUTS, $tempdata2)
EndFunc

Don't know if this will be any more efficient, but it is a different way :)

Bob

You can't see a rainbow without first experiencing the rain.

Link to comment
Share on other sites

Thanks ill try that way . look ok except the part where i have to define every text on every button separately

when i define a button for example

$icons[23] = GUICtrlCreateButton("{s}", 100, $POXICONY+30, 25, 25, $BS_BITMAP)

the botton text is {s}

why can i use a command to grab that text if i knwo the botton was pressed?

im sure there is a way.

i dont want to define

$botton_text [$i] ="{s}"

for every button...

Link to comment
Share on other sites

I didn't know if the exact button text was what you wanted to have added. If this is the case, then

GUICtrlRead($button[$ncount]) will return the displayed text of the button. This would eliminate the second array.

Thus the call would become:

TEST(GUICtrlRead($aButton[$nCount]))

Good luck!

Bob

You can't see a rainbow without first experiencing the rain.

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