Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to trap and process Windows messages before the applications' window procedu Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Win API
Language
Delphi 2.x
Views
102
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

How to trap and process Windows messages before the applications' window procedure 
is executed

Answer:

The following project source demonstrates how to get Window messages before the 
application's window procedure is called. It is rare, if ever, that this needs to 
be done. In most cases assigning a procedure to the Application.OnMessage will 
accomplish the same thing.


1   program Project1;
2   
3   uses
4     Forms, messages, wintypes, winprocs, Unit1 in 'UNIT1.PAS' {Form1};
5   
6   {$R *.RES}
7   
8   var
9     OldWndProc: TFarProc;
10  
11  function NewWndProc(hWndAppl: HWnd; Msg, wParam: Word; lParam: Longint): Longint; 
12  export;
13  begin
14    result := 0; { Default WndProc return value }
15    {Handle messages here; The message number is in Msg}
16    result := CallWindowProc(OldWndProc, hWndAppl, Msg, wParam, lParam);
17  end;
18  
19  begin
20    Application.CreateForm(TForm1, Form1);
21    OldWndProc := TFarProc(GetWindowLong(Application.Handle, GWL_WNDPROC));
22    SetWindowLong(Application.Handle, GWL_WNDPROC, longint(@NewWndProc));
23    Application.Run;
24  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC