Solved

Message Handling in Simple Components

Posted on 2003-11-11
3
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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