Guidance
指路人
g.yi.org
software / rapidq / Examples / Memory Process Thread Message / SETTEXTCLICK.rqb

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
' BILL K     1-03
' This is a demo of a way you can interface RapidQ programs with other applications.
' Click on the control in the application and your RQ program can send text to it as long
'  as the application remains open.
' With Comboboxes it works better sometimes to click on the dropdown button
' rather than the edit field.
' You can even change a button caption, title bar caption, dialog boxes, etc.
' String size is limited to 255.
     $OPTIMIZE ON
     $APPTYPE GUI
     $TYPECHECK ON
     CONST VK_LBUTTON = &H1
     CONST VK_RBUTTON = &H2
     CONST WM_SETTEXT = &HC
     DEFLNG CTLHND
     DIM BFR AS STRING:BFR =SPACE$(255)
     DECLARE FUNCTION SendMessagex LIB "user32" ALIAS "SendMessageA" ( hwnd AS LONG,  wMsg AS LONG,  wParam AS LONG, lParam AS STRING) AS LONG
     DECLARE FUNCTION GetAsyncKeyState LIB "user32" ALIAS "GetAsyncKeyState" ( vKey AS LONG) AS INTEGER
     DECLARE FUNCTION WindowFromPoint LIB "user32" ALIAS "WindowFromPoint" (xPoint AS LONG, yPoint AS LONG) AS LONG
     DECLARE FUNCTION GetParent LIB "user32" ALIAS "GetParent"( hwnd AS LONG) AS LONG
     DECLARE FUNCTION GetWindowText LIB "user32" ALIAS "GetWindowTextA" ( hwnd AS LONG,  ByRef lpString AS STRING,  cch AS LONG) AS LONG
     DECLARE FUNCTION GetClassName LIB "user32" ALIAS "GetClassNameA" ( hwnd AS LONG,  ByRef lpClassName AS STRING,  nMaxCount AS LONG) AS LONG
     DECLARE FUNCTION SetWindowPos LIB "user32" ALIAS "SetWindowPos"(hWnd AS LONG, hWndAfter AS LONG, x AS INTEGER, y AS INTEGER, width AS INTEGER, height AS INTEGER, FLAGS AS INTEGER) AS INTEGER
'
     DECLARE SUB DOINIT
     DECLARE SUB DOTIMER
     DECLARE SUB STARTCAPT
     DECLARE SUB CHECKLEN(Key AS WORD, Shift AS INTEGER)
     DECLARE SUB SENDDATA
     DECLARE SUB GETADDITIONALINFO
     CREATE TIMEX AS QTIMER
      INTERVAL=100
      ONTIMER=DOTIMER
      ENABLED=0
     END CREATE
'
     CREATE BFONT AS QFONT
      NAME= "ARIAL"
      SIZE= 9
      COLOR= 0
      BOLD= 1
      ITALIC= 0
     END CREATE
     CREATE RFONT AS QFONT
      NAME= "ARIAL"
      SIZE= 9
      COLOR= 255
      BOLD= 1
      ITALIC= 0
     END CREATE
'
     CREATE FORM AS QFORM
      CAPTION= "SEND IT"
      WIDTH= 647
      HEIGHT= 180
      ONSHOW=DOINIT
      CENTER
      CREATE REDIT AS QRICHEDIT
       FONT= BFONT
       HIDESELECTION= 0
       SCROLLBARS= 3
       PLAINTEXT= 1
       WANTTABS= 1
       FONT= BFONT
       TOP= 10
       LEFT= 10
       WIDTH= 480
       HEIGHT= 80
       ONKEYDOWN=CHECKLEN
      END CREATE   ' REDIT
      CREATE SENDBTN AS QBUTTON
       CAPTION= "SEND"
       TABORDER= 2
       TAG= 2
       FONT= BFONT
       ONCLICK=SENDDATA
       TOP= 35
       LEFT= 520
       WIDTH= 80
       HEIGHT= 30
      END CREATE   ' SENDBTN
      CREATE GROUPBOX AS QGROUPBOX
       CAPTION="Press Capture Control Button then Click on a control in the Application you want the above text sent to..."
       TOP= 100
       LEFT= 10
       WIDTH= 620
       HEIGHT= 45
       CREATE CAPTBTN AS QBUTTON
        CAPTION= "CAPTURE CONTROL"
        TABORDER= 3
        TAG= 3
        FONT= BFONT
        ONCLICK=STARTCAPT
        TOP= 15
        LEFT= 10
        WIDTH= 130
        HEIGHT= 25
       END CREATE   ' CAPTBTN
       CREATE PANEL4 AS QPANEL
        BEVELOUTER=0
        FONT= BFONT
        TOP= 13
        LEFT= 140
        WIDTH= 470
        HEIGHT= 25
       END CREATE   ' PANEL4
      END CREATE   ' GROUPBOX
     END CREATE ' FORM
'
     SUB SENDDATA
      SENDMESSAGEX CTLHND, WM_SETTEXT, 0 ,REDIT.TEXT
     END SUB
'
     SUB DOTIMER
      DEFINT BS
      BS=GETASYNCKEYSTATE(&H01) OR GETASYNCKEYSTATE(&H02)
      IF BS<>0 THEN
       CTLHND=WINDOWFROMPOINT(SCREEN.MOUSEX, SCREEN.MOUSEY)
       IF CTLHND = SENDBTN.HANDLE OR CTLHND = CAPTBTN.HANDLE THEN EXIT SUB
       GETADDITIONALINFO
       SENDDATA
       TIMEX.ENABLED=0
       CAPTBTN.FONT=BFONT
      END IF
     END SUB
'
     SUB STARTCAPT
      TIMEX.ENABLED=1
      PANEL4.CAPTION=""
      CAPTBTN.FONT=RFONT
     END SUB
'
     SUB CHECKLEN
      IF LEN(REDIT.TEXT)>255 THEN ' LIMIT OF WM_SETTEXT
       KILLMESSAGE(FORM.HANDLE, &H102)
      END IF
     END SUB
'
     SUB GETADDITIONALINFO
      DEFSTR TXT,ST
      DEFLNG LH
      TXT="Handle= " & STR$(CTLHND)
      LH = GETWINDOWTEXT(CTLHND,BFR, 255)
      ST = LEFT$(BFR, LH)
      IF ST<>"" THEN TXT=TXT & "  Title: " & ST
      LH = GETCLASSNAME(CTLHND,BFR, 255)
      ST = LEFT$(BFR, LH)
      TXT = TXT & "  Class: " & ST
      PANEL4.CAPTION=TXT
     END SUB
'
     SUB DOINIT
      REDIT.TEXT="Sample Text to Send"
      SetWindowPos(FORM.handle, -1, 0, 0, 0, 0, 3)'STAY ON TOP
     END SUB
     FORM.SHOWMODAL
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2019-7-17  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-01-20 20:04:55