Results 1 to 2 of 2

Thread: canvas getwindowkey qt

  1. #1

    Post canvas getwindowkeystate qt

    how I can get infos or an thinbasic example about canvas/"getwindowkeystate" (for example: (%VK_L, %VK_B) in GUI modus ?

    or something like

         If GetAsyncKeyState(%VK_ESCAPE) Then  
         Dialog End hDlg
    
        End If
    
    but that's not working in canvas mode for one-letter-key strokes.
    Last edited by largo_winch; 08-10-2013 at 16:02.

  2. #2
    something I have built this afternoon:

       ' Basic Template for custom dialog
     ' Start Date 10-09-2013
     ' Created by  
       
     Uses "UI"
     
    
     ' -- ID numbers of controls
     Begin ControlID
       %bClose                 
       %myLabel
     End ControlID     
     
    
     Begin Const
       %MAIN_WIDTH   = 420
       %MAIN_HEIGHT  = 340
     End Const
     
    
     ' -- Create dialog here
     Function TBMain()
       Local hDlg,counts As Long
       Local strx As String
     
    
       Dialog New Pixels, 0, "GetKeyState_test",-1,-1, %MAIN_WIDTH, %MAIN_HEIGHT, _
                     %WS_POPUP Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
        
       ' -- Place controls here
       Control Add Button, hDlg, %bClose, "Click to close", %MAIN_WIDTH-105, %MAIN_HEIGHT-30, 100, 25, Call cbCloseButton
       Control Add Label, hDlg, %myLabel, "", 5, 40, 202, 268, _
             %WS_CHILD Or %WS_VISIBLE Or %WS_BORDER Or %SS_LEFT Or %SS_SUNKEN, _
             %WS_EX_CLIENTEDGE Or %WS_EX_LEFT Or %WS_EX_LTRREADING
     
    
       'Dialog Show Modal hDlg, Call cbDialog
       Dialog Show Modeless hDlg, Call cbDialog
     Do
       If GetAsyncKeyState(Asc("A")) And &H80 > 0 Then strx = strx + "'A' is pressed" + $CRLF
    
       If GetAsyncKeyState(Asc("B")) And &H80 > 0 Then strx = strx + "'B' is pressed" + $CRLF
        
       Control Set Text hDlg, %myLabel, strx
       Dialog DoEvents To counts
     Loop Until counts = 0
          
     End Function
     
    
     ' -- Callback for dialog
     CallBack Function cbDialog()
        
       ' -- Test for messages
       Select Case CBMSG
     
    
         Case %WM_INITDIALOG
         ' -- Put code to be executed after dialog creation here
     
    
         Case %WM_COMMAND
         ' -- You can handle controls here
     
    
         'SELECT CASE CBCTL
         '
         '  CASE ...
         '    IF CBCTLMSG = ... THEN
         '
         '    END IF
         '
         'END SELECT
     
    
     
    
         Case %WM_CLOSE
         ' -- Put code to be executed before dialog end here
         'Case %WM_KEYDOWN
         'If GetAsyncKeyState(Asc("A")) And &H80 > 0 Then strx = strx + "'A' is pressed" + $CRLF
       End Select
     
    
     End Function
       
     ' -- Callback for close button
     CallBack Function cbCloseButton()
     
    
       If CBMSG = %WM_COMMAND Then
         If CBCTLMSG = %BN_CLICKED Then
           ' -- Closes the dialog  
           Dialog End CBHNDL
         End If
       End If
     
    
     End Function
    
    this example works for some keys, not bad. now my next step is to built in this "GetAsyncKeyState" in callback part.

    interesting that this example only runs with "modeless" and a loop.

    bye, largo

Similar Threads

  1. math Art using the Canvas
    By zak in forum UI (User Interface)
    Replies: 5
    Last Post: 25-07-2011, 17:18
  2. canvas tourism
    By zak in forum UI (User Interface)
    Replies: 0
    Last Post: 29-06-2010, 15:57
  3. Replies: 6
    Last Post: 16-06-2010, 06:40
  4. canvas example :)
    By lydia_sp in forum UI (User Interface)
    Replies: 1
    Last Post: 16-09-2009, 17:19

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
  •