Jump to content

Simplify button adaption from the original code


Chimaera
 Share

Recommended Posts

Hi, ive got a gui with a number of buttons which i might need to add buttons too as i go along

example button code

Local $hButton1 = GUICtrlCreateButton("", 6, 6, 70, 70, $BS_BITMAP, $WS_EX_WINDOWEDGE)
    Local $Dir1 = @ScriptDir & '\settings\button_1\'
    $search = FileFindFirstFile($Dir1 & '*.bmp')
    If @error = 1 Or $search = -1 Then
        GUICtrlSetImage($hButton1, @AppDataDir & '\Toolz\question_large.bmp')
    Else
        While 1
            $find = FileFindNextFile($search)
            If @error Then ExitLoop
            $IconTest_1 = $find
            $image = GUICtrlSetImage($hButton1, $Dir1 & $IconTest_1)
        WEnd
    EndIf
    Local $ToolTip_1 = IniRead($IniFile, 'Button_1', 'button_1_tooltip', 'Error Reading Button 1 Tooltip')
    GUICtrlSetTip(Default, ' ' & $ToolTip_1 & ' ')

Now the problem is, if i copy that and paste to make a new button i end up having to change the '1' at the end of each part so it relates to button 24 for eg

Ive been messing about trying to make it work with stuff like this

$hButton = 'Button', $bNumber = '_1'
     $bBut_ID = '$bBut_ID' & $bNumber
    ConsoleWrite($bBut_ID & @CRLF)
    $bBut_ID = $hButton & $bNumber
    ConsoleWrite($bBut_ID & @CRLF)

But then the Case statement for the button doesnt work.

 

Is there a simple way to do this? so i can edit one number and the whole button section changes? and still works with the case statement

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