Jump to content
  • Advertisement
Sign in to follow this  
Kamos

DelphiX, TDXPlay

This topic is 4548 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm using Delphi and am now writing a class to handle network communication. Now normally you would place a DXPlay Object on the form. But seeing as I'm writing a class to handle network communication, this class will have the DXPlay Object. But here's the problem: The events that happen when a message is received or a player joins, they don't trigger anymore. This is the constructor: TDXPlay.Create(AOwner: TComponent) Note that when you drop DXPlay on the form, you don't have to create the object yourself, I guess delphi does this internally, but I can't find where it does so. Network class:
type TNetwork = Class(TObject)
 FDXPlay: TDXPlay;
 constructor create(AOwner: TComponent);
// other variables, methods...
end;

I am working with a form and I tried:
procedure TForm1.FormCreate(Sender: TObject);
begin
  FNetwork := TNetwork.Create(Form1);
// also tried:
// FNetwork := TNetwork.Create(TComponent(Sender));
// and also:
// FNetwork := TNetwork.Create(nil);
end;

But the events still aren't called... Any help is greatly appreciated :)

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Try posting your question here: http://www.delphigamer.com/
Most people don't know Delphi here.

Share this post


Link to post
Share on other sites
I found the answer :)

And for those who will someday have the same problem:
You have to link the events from TDXPlay to a function of your own.
So it goes like this:


// define class:
type TNetwork = Class(TObject)
FDXPlay: TDXPlay;
constructor create(AOwner: TComponent);
function YourOwnFunction(<Insert parameters of the OnMessage Event>);
// other variables, methods...
end;

implementation

constructor create(AOwner: TComponent);
begin
FDXPlay.Create(nil); // or fill in AOwner here instead of nil, so
// the owner will free FDXPlay instance
FDXPlay.OnMessage := YourOwnFunction;
end;

function YourOwnFunction(<Insert parameters of the OnMessage Event>);
begin
// Process message
end;



btw: Delphi uses a DFM file to link the events generated by an object to your function (delphi makes this function for you), when you drop an object on the form and use its events.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!