Solved

Message Handling in Simple Components

Posted on 2003-11-11
3
177 Views
Last Modified: 2010-04-05
Greetings,

I've been developing a set of simple components (derived from TComponent) which need
to do 2 things :-

1. Generate and handle windows messages as a means of managing internal data without, for example, destroying classes from within their own methods.

2. Work in conjunction with other components - for example, hooking into method pointers of components which might not exist at the time of creation (hence the need for a create message)

The components in question are a server and services which hook into it
The server component maintains a list of connected clients and handles data transfer.  
The service component manages a subset of the servers clients, transfers them between other services and provides methods for the user.

I've been reading up on the windows API and from what I understand, I would need to create a window for each component.  Slightly less than straight-forward but on top of all that, there are considerations such as threads and use within DLL's and thats where it becomes more trouble than its worth.

Is there no easier way to do it since I would eventually like to make these components publically available
0
Comment
Question by:LordWolfy
  • 2
3 Comments
 
LVL 12

Expert Comment

by:Lee_Nover
Comment Utility
for creating the message queue and handling messages is really simple
just create a new window using AllocateHWnd
then send messages to this handle
to destroy an object from it's own method post a message to it (PostMessage)
some reference code: http://leenover.homeip.net/isapi/pas2html.dll/pas2html?File=/delphi/lnMsgCompos/
two components for communication using messages (simplifying messaging)
0
 
LVL 2

Author Comment

by:LordWolfy
Comment Utility

Thats the thing  - I remember reading soemthing about AllocateHWnd and the 32 bit VCL not being thread safe.

If these components are going to be available to everyone - they need to be able to work in all scenarios.

P.S. the reference you posted just comes up with a set of broken links.
0
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 250 total points
Comment Utility
.. crap .. probably messed up sumtin' on my server
anyway you can click the delphi sourcefile icon to display the source .. that works
download for some reason doesn't .. gotta fix that later
here are the links
http://leenover.homeip.net/isapi/pas2html.dll/pas2html?File=/delphi/lnMsgCompos/lnGlobalVar.pas
http://leenover.homeip.net/isapi/pas2html.dll/pas2html?File=/delphi/lnMsgCompos/lnMsgServer.pas
http://leenover.homeip.net/isapi/pas2html.dll/pas2html?File=/delphi/lnMsgCompos/lnMsgClient.pas
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now