Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Message Handling in Simple Components

Posted on 2003-11-11
3
Medium Priority
?
187 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 750 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

927 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