Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to assigne windows procedure to Application object

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have to write a program that responds to some windows messages but I don’t need any forms. How can I assign my window procedure to the application object? When I remove all forms from projects source and add OnMessage event handler, program simply terminates.


thanks
 
Hello,

I'm not completely sure, but I think you should write a method "OnAppMessage". In this procedure describe what your application shall do on Message.

Then you write in the constructor of your object:

Application.OnMessage := OnAppMessage;

Would be nice if you told me whether it worked... s-)
 
We have done this with an object which has an "execute loop" which loops until the program is stopped. The object also contains the onappmessage handler.

Initially our execute loop had a sleep call in it so it didn't use 100% of processor time, but that causes problems with several microsoft apps, making them take a long time to start up if this process is running in the background. So, we changed it to

hEvnt := CreateEvent(nil, false, false, nil);
MsgWaitForMultipleObjects(1, hEvnt, False, 10000, QS_ALLINPUT);
CloseHandle(hEvnt);

which acts like a sleep but doesn't cause other programs to slow down.

Anyway, hope that helps.

Good luck!
TealWren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top