Announcement

Collapse
No announcement yet.

Sending Data to another app

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

  • Sending Data to another app

    I just realized that I cannot create a progress bar from my DLL because it is called thousands of times. each time it is called by TradeStation it will create the progress bar, then when it is finished the progress bar window will be destroyed. then on the next bar it will be created and destroyed etc etc. The amount of time it would be on the screen is so small that you would not see it.

    SO, I guess i have to write a seperate app that creates the progress bar and send data to that app from my DLL each time it is called.

    Anyone know how to do that?


    ------------------
    Kind Regards
    Mike

  • #2
    This is known as Inter-Process Communication (IPC). There are a large number of articles on www.msdn.microsoft.com if you search for "IPC". Methods of IPC include Named Pipes, %WM_COPYDATA, Memory-mapped Files, Mail-slots, etc.

    However, if you only need to send a very low volume of data (say, a percentage level, or an "advance the count" flag), you should find the %WM_COPYDATA technique is the easiest.

    If you search this BBS for "WM_COPYDATA" you should find a few examples of this method of IPC.


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

    Comment


    • #3
      Why not create it in your app and pass its handle to the DLL?

      Peter.


      ------------------
      [email protected]
      [email protected]

      Comment


      • #4
        I agree with Peter, but if you want you could try this:
        Code:
        '==================================================================================================
        #Compile Exe  "TestBar.Exe"  'Draws a bar
        #Include "Win32Api.inc"
        #Include "Commctrl.inc"
        
        %PROGRESS = %WM_USER + 2048
        %USERMSG  = %WM_USER + 2049
        
        CallBack Function MainCb ()
          Select Case CbMsg
            Case %USERMSG
              Control Send CbHndl, %PROGRESS,%PBM_SETPOS, CbWparam , 0
          End Select
        End Function
        
        Function PbMain() As Long
          Local hDlg As Long
          InitCommonControls
          Local Icc As Init_Common_ControlsEx
          Icc.dwSize = SizeOf(Icc)
          Icc.dwIcc = %ICC_BAR_CLASSES
          InitCommonControlsEx Icc
        
          Dialog New 0, "Test Bar",100 ,100 , 100, 50, %WS_VISIBLE Or %WS_SYSMENU To hDlg
          Control Add "msctls_progress32", hDlg&, %PROGRESS, "", 10, 10, 80, 12, %Ws_Child Or %Ws_Visible Or %PBS_SMOOTH
          Control Send hDlg,%PROGRESS,%PBM_SETRANGE, 0, MakLng(0,20)
          Control Send hDlg,%PROGRESS,%PBM_SETBARCOLOR, 0, Rgb(200,0,0)
          Dialog Show Modal hDlg, Call MainCb
        End Function
        
        '==================================================================================================
        #Compile Exe "SetBar.Exe"  'Sets the bar
        #Include "Win32Api.inc"
        %BTN      = %WM_USER + 2040
        %USERMSG  = %WM_USER + 2049
        Global hWnd As Long
        
        CallBack Function MainCb ()
          Static lCnt As Long
          Select Case CbMsg
            Case %WM_COMMAND
              Select Case CbCtl
                Case %BTN
                  If lCnt < 20 Then Incr lCnt Else lCnt = 0
                  SendMessage hWnd, %USERMSG, lCnt, 0
              End Select
          End Select
        End Function
        
        Function PbMain() As Long
          Local hDlg As Long
          hWnd = FindWindow ("", "Test Bar")
          If hWnd Then
            Dialog New 0, "Set Bar",250 ,100 , 100, 50, %WS_VISIBLE Or %WS_SYSMENU To hDlg
            Control Add Button, hDlg&, %BTN, "Increment Bar", 10, 10, 80, 12
            Dialog Show Modal hDlg, Call MainCb
          Else
            MsgBox "Test Bar not started!",,"Error"
          End If
        End Function
        ------------------
        Peter.
        mailto[email protected][email protected]</A>
        Regards,
        Peter

        Comment


        • #5
          Thank you all so much.

          I cant create it in the app, cos the app is not mine. It is a commercially available app that has limited capability for writing code within it. I allows you to write with (Easy Language) this is a simplistic language with powefull features for calculating stock stuff.

          Its saving grace is that I can call a DLL. THe problem is it calls this DLL hundreds of times. I cant make it call it once for all the bars on the chart.



          ------------------
          Kind Regards
          Mike

          Comment


          • #6
            Maybe you can find some way to use LoadLibrary to keep the dll resident,
            and use some static variables to prevent the destruction of the window and
            progress bar.

            ------------------
            Thanks,

            John Kovacich
            Thanks,

            John Kovacich
            Ivory Tower Software

            Comment

            Working...
            X