Jump to content

Recommended Posts

Posted (edited)

Hi

I am trying to set Accelerator keys from an array.

I select the KEY and CONTROL from a SQLite table, the Array looks like that generated for the Helpfile, but I can't get the CONTROLS to resolve...

I though about Assign & Eval, but not sure if that's a step in the right direction. IsDeclared shows that the $var exists in Local Scope -1.  

 

Local $Main = GUICreate("Custom MsgBox", 225, 80)

    GUICtrlCreateLabel("Please select a button.", 10, 10)
    Local $idButton_Yes = GUICtrlCreateButton("Yes", 10, 50, 65, 25)
    Local $idButton_No = GUICtrlCreateButton("No", 80, 50, 65, 25)
    Local $idButton_Exit = GUICtrlCreateButton("Exit", 150, 50, 65, 25)


    Local $query, $aResult, $iRows, $iColumns
    $query = "" ;reset
    $query = "Select hotkey_key, hotkey_ctrl from mytable where mykeys = 'hotkey' ; " ;
    ; Query
    $iRval = _SQLite_GetTable2d($sqliteDb, $query, $aResult, $iRows, $iColumns)
    If $iRval = $SQLITE_OK Then
        Local $sizeofHotkeys = UBound($aResult) - 1
        ConsoleWrite("$sizeofHotkeys " & $sizeofHotkeys & @CRLF)
        If $sizeofHotkeys > 0 Then
            Local $main__aAccelKeys[$sizeofHotkeys][2]
            For $i = 0 To $sizeofHotkeys - 1
                $j = $i + 1
                ; replace friendly text with code -- ! alt + Shift ^ Ctrl # Windows
                $aResult[$j][0] = StringReplace($aResult[$j][0], "Alt", "!")
                $aResult[$j][0] = StringReplace($aResult[$j][0], "Shift", "+")
                $aResult[$j][0] = StringReplace($aResult[$j][0], "Ctrl", "^")
                $main__aAccelKeys[$i][0] = $aResult[$j][0] ;---
                $main__aAccelKeys[$i][1] = $aResult[$j][1] ;---
            Next
;~ Row|Col 0|Col 1
;~ Row 0|F2|$idButton_Yes
;~ Row 1|F3|$idButton_No

            _DebugArrayDisplay($main__aAccelKeys)
            Local $rv = GUISetAccelerators($main__aAccelKeys, $Main)


    GUISetState(@SW_SHOW) ; Display the GUI.

 

Please note that this is a modified Helpfile example.

The Helpfile specifies (a) WinHandle and (b) last Gui created.

--> the example uses a control not a WinHandle and (b) what happens with ChildGuis? Also, the HelpFile specifies lower case, yet the examples show "{F1}" upper case?

Also, is there a way to check the result of the GuiSetAccelerator function? 

Note, if I add these to lines after the FOR loop, then the F1 works, and the DebugArrayDisplays shows control 4... not it's name... So I am in the right place, but my $vars names do not convert to their control numbers in the GUI

Next
            $main__aAccelKeys[$sizeofHotkeys - 1][0] = "{F1}" ; -- -- use the extra row for the F1
            $main__aAccelKeys[$sizeofHotkeys - 1][1] = $ChmHLP   ;---

Skysnake

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Posted

Hi @Skysnake How do you match the SQLite column hotkey_ctrl with the actual control id in the GUI.  That seems to me the major problem of your approach.  The moment you change your GUI by adding, for example, a label or a button or a dummy, you will need to change your database accordingly.

Posted
1 hour ago, Nine said:

you will need to change your database accordingly.

@Nine Thanks for the reply.

This is true, but a different question.  The issue you refer to here occurs when new functions / controls are created and that needs to be taken care of separately. I am thinking of putting that into an array.

However, right now, I need to get the value out of the SQLite array into the Accelerator array. 

Any ideas?

Skysnake

Why is the snake in the sky?

Posted (edited)
1 hour ago, Skysnake said:

Any ideas?

oh, I just noticed your commented lines after the loop.  So if I understand correctly.  It is the name of the control that you have inside the database, Not the control id, right ?  If it is the case, you could use eval () ? 

Edited by Nine

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
×
×
  • Create New...