Announcement

Collapse
No announcement yet.

DDE

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DDE

    POFFS didnt return anything fruitful about DDE, and i couldnt find any source! - has anybody done this before???
    Im just writing a client, so it just has to say "hello" to a program over DDE...
    My Visual Basic code to do it is this:
    Code:
    Public Sub AddLine(Newstr As String)
    On Error Resume Next
    Text1.Text = Newstr
    DoEvents
    If Text1.LinkMode = 0 Then
       Text1.LinkTopic = "Waynes Program|Form1"
       Text1.LinkItem = "Text1"
       Text1.LinkMode = 3 '2=MANUAL, 3=NOTIFY
    End If
    Text1.LinkPoke
    DoEvents
    End Sub
    And then I would just call Addline("hello")

    has anybody done any DDE with PB, and would they be kind enough to post code snippets?




    ------------------
    -

  • #2
    Never had to deal with it myself, but in Win32api.hlp, you can
    find a lot about it, including samples in C on how to establish
    connections, etc. If you start from "Dynamic Data Exchange" in
    Win32api.hlp and then move forward with the help of the >> button,
    you will find some good articles about it.


    ------------------

    Comment


    • #3
      I seem to recall the aforementioned PETZOLD.ZIP file contains a couple of DDE projects.
      http://www.powerbasic.com/files/pub/pbwin

      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Thanks Lance - I looked at the Petzold DDE example (chapter 17), but i was a bit daunted by it!
        But i got to thinking, and realised (with the help of a memory objects viewer) that the VB form i was using for DDE was a parent window, with just one textbox under it - a child window...
        So i thought - if I can find the hWnd of the parent window, and then grab the hWnd of it's first child window (as there's only one), then wallah! I would be able to change the text - which triggers the remote VB program (it activates on Text1_Change)
        And it worked!! it's not DDE, but for this purpose it works just as well - and with a lot less code than DDE

        Code:
        #COMPILE EXE
        #INCLUDE "WIN32API.INC"
         
        FUNCTION ENCW(BYVAL hWnd AS LONG, BYVAL lParam AS LONG) AS LONG
        ON ERROR RESUME NEXT
              SendText$ = "String to put in textbox of the VB program"
              SendMessage hWnd, %WM_SETTEXT, 0, STRPTR(SendText$)
              SLEEP 50
        END FUNCTION
         
        FUNCTION WinMain(BYVAL hCurInstance  AS LONG, _
                         BYVAL hPrevInstance AS LONG, _
                         lpszCmdLine   AS ASCIIZ PTR, _
                         BYVAL nCmdShow      AS LONG) _
                         EXPORT AS LONGWin
        IF FindWindow("ThunderRT6FormDC","FormDDE") > 0 THEN EnumChildWindows FindWindow ("ThunderRT6FormDC","FormDDE"), CODEPTR(ENCW), 0
        END FUNCTION

        ------------------
        -

        Comment

        Working...
        X