Announcement

Collapse
No announcement yet.

RideRunner & Delphi Plugin

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

  • RideRunner & Delphi Plugin

    Hello from Austria,

    i am the new guy and fan of Riderunner
    I use this great software for about 2 Months.
    Now is time to write the first plugin.
    I am working on a temperature plugin using a 1-wire USB Adapter and DS1920 sensors.
    This part is okay, my problem ist to send a message to RideRunner.
    I found this example, but i can't get it work.
    Has anybody a working example for Borland Delphiform me !?

    Thank you in advance
    Tesla76

    Code:
    unit Unit2;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    const
      WM_COPYDATA = 74;
    
    type
      TMyCopyDataStruct = packed record
        dwData: DWORD;
        cbData: DWORD;
        lpData: Pointer;
      end;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Edit1: TEdit;
        procedure Button1Click(Sender: TObject);
    
      private
        procedure WMCopyData(var Msg : TWMCopyData) ; message WM_COPYDATA;
      public
        procedure SendCopyData(hTargetWnd: HWND; ACopyDataStruct:TCopyDataStruct);
      end;
    
    var
      Form1: TForm1;
      MyCopyDataStruct: TCopyDataStruct;
    
    implementation
    
    {$R *.dfm}
    
    { Use: "SENDMSG;<FORMTITLE>;<TEXT>" from RR to receive data here }
    procedure TForm1.WMCopyData(var Msg: TWMCopyData) ;
    var
      s : string;
    begin
      s := PChar(Msg.CopyDataStruct.lpData) ;
      SetLength(s, Msg.CopyDataStruct.cbData) ;
    
      // Displays Received Data
      showmessage(s);
    
      //Send something back
      msg.Result := 1;
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      txt: string;
    begin
    
      with MyCopyDataStruct do begin
        dwData := 1; // may use a value do identify content of message
        cbData := StrLen(PChar(Edit1.Text));// + 1;  //Need to transfer terminating #0 as well
        lpData := PChar(Edit1.Text)
      end;
    
      sendcopydata(findwindow(nil, 'RideRunner'), MyCopyDataStruct);
      sendcopydata(findwindow(nil, 'RoadRunner'), MyCopyDataStruct);
    
    end;
    
    procedure TForm1.SendCopyData(hTargetWnd: HWND; ACopyDataStruct:TCopyDataStruct);
    begin
      if hTargetWnd <> 0 then
        SendMessage(hTargetWnd, WM_COPYDATA, Longint(Handle), Longint(@ACopyDataStruct))
      else
        ShowMessage('No Recipient found!');
    end;
    
    end.

  • #2
    You may want to try something like this instead..

    Code:
    procedure TForm1.InsertBtnClick(Sender: TObject);
    var
      S: string;
      RRSDK: Variant;
    begin
      try
        RRSDK := CreateOleObject('RideRunner.SDK');
      except
        ShowMessage('Could not start RR.');
        Exit;
      end;
    
      RRSDK.Execute('PLAY');
      S := RRSDK.GetInfo('TRACKNAME');
    
    end;
    I highly recommend you reading the method "3" of this link:
    http://www.mp3car.com/vbulletin/rr-f...cation-rr.html

    The method you were trying to use (while it should still work) is more complex and offers no benefit over the COM method above described.
    Ride Runner RR's Myspace

    "Being happy is not about having what you want, it's about wanting what you have."
    "The best things in life are always free - but that doesn't mean money can't buy you good things."

    Comment


    • #3
      @guino

      Thank you very much !!
      Your solution is very easy (perhaps to easy) and working like a charme !!
      I highly recommend you reading the method "3" of this link:
      http://www.mp3car.com/vbulletin/rr-f...cation-rr.html
      I read this 20 times bevore, but i don't know that creating an COM Objekt in Delphi is so easy !!
      Now my prog is updating the temperature with the SETVAR command.

      Tesla

      Comment


      • #4
        That would be a good idea to have a Delphi plugin example ready to use and modify

        Comment

        Working...
        X