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

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'=================program #2========================

' name this ap_b.rqb and compile
' Bill K 12-2002
     $APPTYPE GUI
     $TYPECHECK ON
     $OPTIMIZE ON
     CONST CRLF=CHR$(13) & CHR$(10)
     CONST WM_COPYDATA = &H4A
     TYPE COPYDATASTRUCT
      dwData AS LONG
      cbData AS LONG
      lpData AS LONG
     END TYPE
     DIM DataStruct AS COPYDATASTRUCT
     DEFSTR strSend, strRecv
'
     DECLARE SUB SendData
     DECLARE SUB FormWndProc (Hwnd&, uMsg&, wParam&, lParam&)
     DECLARE FUNCTION FindWindow LIB "user32" ALIAS _
      "FindWindowA" (BYVAL lpClassName AS STRING, _
      BYVAL lpWindowName AS STRING) AS LONG
'
     CREATE FORM AS QFORM
' title the other application will search for:
      CAPTION="Application B"
      left=500
      top=100
      CREATE sendbtn AS QBUTTON
       WIDTH=75
       TOP=form.clientheight-33
       LEFT=(form.clientwidth-sendbtn.width)/4-15
       CAPTION="SEND"
       ONCLICK=senddata
      END CREATE
      CREATE sendlbl AS QLABEL
       CAPTION="Send:"
       top=3
       left=10
      END CREATE 'sendlbl
      CREATE recvlbl AS QLABEL
       CAPTION="Receive:"
       top=3
       left=form.clientwidth/2+15
      END CREATE 'recvlbl
      CREATE redit1 AS QRICHEDIT
       hideselection=0
       scrollbars=3
       top=18
       left=5
       width=form.clientwidth/2-10
       height=form.clientheight-60
      END CREATE ' redit
      CREATE Redit2 AS QRICHEDIT
       hideselection=0
       scrollbars=3
       top=18
       left=redit1.LEFT + redit1.width +10
       width=form.clientwidth/2-10
       height=form.clientheight-60
      END CREATE ' Redit2
     END CREATE ' FORM
'
     SUB SendData
      DEFLNG wndhnd
      wndhnd=Findwindow("TForm","Application A")
      IF wndhnd=0 THEN
       SHOWMESSAGE "Could not find Application A"
       EXIT SUB
      END IF
      strSend=redit1.text
      DataStruct.lpData = VARPTR(strSend)
      DataStruct.cbData = LEN(strSend)
      SENDMESSAGE wndhnd, WM_COPYDATA, 0, DataStruct
     END SUB
'
     SUB FormWndProc (Hwnd&, uMsg&, wParam&, lParam&)
      IF uMsg& = WM_COPYDATA THEN
       DIM MStream AS QMEMORYSTREAM
       MStream.MemCopyFrom(lParam&, 12)
       MStream.Position = 0
       MStream.ReadUDT(DataStruct)
       MStream.CLOSE
       strRecv = VARPTR$(DataStruct.lpData)
       Redit2.addstrings strRecv
      END IF
     END SUB
'
     REDIT1.ADDSTRINGS "This is sample data text" + _
      crlf + "from Application B"
     Form.WndProc = FormWndProc' best if this is
' just before showmodal
     form.SHOWMODAL

'=== end ap_b.rqb
掌柜推荐
 
 
¥908.00 ·
 
 
¥1,380.00 ·
 
 
¥1,580.00 ·
 
 
¥890.00 ·
 
 
¥1,800.00 ·
 
 
¥294.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:49:00