Solved

Message Handling in Simple Components

Posted on 2003-11-11
3
178 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
ID: 9728962
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
ID: 9735616

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
ID: 9737304
.. 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

896 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

12 Experts available now in Live!

Get 1:1 Help Now