Results 1 to 7 of 7

Thread: Control states

  1. #1

    Control states

    Hello,

    I've been trying to figure this out:

    How do I GET and SET the state of a checkbox, check3box or radiobutton control?

    Also, is it yet possible to assign hotkey shortcuts to dialog window button controls? I know you can use ampersand in the button text eg:
    "&Button1" puts underline under letter "B". How now to continue?

    Any help much appreciated.

    catventure.
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Control states

    Hi Catventure,

    Control Get Check
    It seems that Control Get Check is not yet implemented.
    You can emulate it for a while by doing this

    * Declare variable, which will keep the check status
    DIM CheckFlag AS LONG

    * In the main dialog loop, add case for the checkbox control
    ...
    CASE %MYCHECKBOX
    CheckFlag = CheckFlag XOR 1
    MsgBox 0, "CheckFlag is "+FORMAT$(CheckFlag)

    -> when user clicks the checkbox, it will make CheckFlag 1 or 0.


    Control Set Check
    Solution for Control Set Check could be something like this
    %BM_CLICK    = &HF5 ' declare this equate at the beginning of source code
    
    Function myControlSetCheck ( dlgHandle AS DWORD, dlgControl AS LONG ) As Long
    IF CheckFlag = 0 THEN control send dlgHandle, dlgControl, %BM_CLICK,0,0
    End Function
    
    ... then by calling myControlSetCheck ( hDlg, %MYCHECKBOX ) this should programaticaly click the checkbox IF is unchecked

    Please keep in mind that's a bit dirty way, but it doesn't occur to me other solution now


    See ya,
    Psch
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3

    Control states

    That code looks interesting, Psch.

    The developers may well come up with a more elegant solution for testing and getting the on/off state of a checkbox and check3state controls but your code may suffice as a temporary stopgap measure until then.

    I will try it out and see how it goes

    catventure
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Control states

    Sorry for the delay but today (and I think tomorrow) I had (will have) very little time.

    Please find here attached new thinBasic_UI.dll updated module.
    I've added:
    CONTROL GET CHECK hDlg, id TO lResult
    CONTROL SET CHECK hDlg, id, checkstate
    CONTROL SET OPTION hDlg, id, minid, maxid

    They are exactly like PowerBasic ones.
    I will document and released officially during this weekend.

    Hopes they work fine.

    Here a fast example taken from PB help doc:
    uses "UI"
    
    %OPT1 = 101
    %OPT2 = 102
    %OPT3 = 103
    %OPT4 = 104
    %OPT5 = 105
    
    MAIN
    
    
    FUNCTION MAIN() as long
        DIM Msg       AS LONG
        DIM wParam    AS LONG
        DIM lParam    AS LONG
        DIM hDlg      AS DWORD
        dim lResult   as long
        dim sResult   as string
        dim Count     as long
    
        DIALOG NEW 0, "OPTION control test", -1, -1, _
            100, 100, %WS_SYSMENU OR %WS_CAPTION TO hDlg
        CONTROL ADD OPTION, hDlg, %OPT1, "Option 1", _
            10, 6, 50, 14, %WS_GROUP OR %WS_TABSTOP
        CONTROL ADD OPTION, hDlg, %OPT2, "Option 2", _
            10, 20, 50, 14
        CONTROL ADD OPTION, hDlg, %OPT3, "Option 3", _
            10, 34, 50, 14
        CONTROL ADD OPTION, hDlg, %OPT4, "Option 4", _
            10, 48, 50, 14
        CONTROL ADD OPTION, hDlg, %OPT5, "Option 5", _
            10, 62, 50, 14
        CONTROL ADD BUTTON, hDlg, %IDOK, "OK", _
            25, 80, 50, 14, %WS_GROUP OR %WS_TABSTOP
    
        '---Set the initial state to OPTION button 3
        CONTROL SET OPTION hDlg, %OPT3, %OPT1, %OPT5
    
      DIALOG SHOW MODELESS hDlg
        
      '---Start the main message loop
      WHILE IsWindow(hDlg)                  
      
        '---Get the message and fill wParam and lParam
        Msg = GetMessage(hDlg, wParam, lParam)        
        SELECT CASE Msg
          CASE %WM_COMMAND
    
            '---Test which control has been clicked
            SELECT CASE wParam
    
              '---A number was activated
              CASE %IDOK
                sResult = ""
                for Count = %OPT1 to %OPT5
                  CONTROL GET CHECK hDlg, Count TO lResult
                  sResult += "Control " & Count & " is " & lResult & $crlf
                next
                msgbox 0, sResult
    
                
            END SELECT
    
          CASE %WM_SYSCOMMAND
    
            SELECT CASE wParam
                
              CASE %SC_CLOSE
                EXIT WHILE
    
                  
            END SELECT
    
          CASE ELSE
          
        END SELECT
        
      WEND
    
      DIALOG END hDlg
    
    
    END FUNCTION
    
    Psch, thanks a lot for your support !!!!
    Eros
    Attached Files Attached Files
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5

    Control states

    OOH! This a very nice surprise when I woke up this morning!

    Thanks ever so much for putting this into the UI module Eros and also thanks to Psch for the workaround code.

    I will try it today.


    Best wishes,
    catventure
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  6. #6

    Control states

    Hi,

    Just to let you know I tried the new checkbox commands in my project and they worked without problem.

    Regards,
    catventure
    http://tab.thinbasic.com - Home Of The ThinBasic Adventure Builder Project. (Interactive Fiction/Text Adventure Maker)

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Control states

    OK, thanks.
    I will document and publish during this week-end. I think I will be able to add some more functionalities :P

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •