Articles   Members Online:
-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 check if a MDI child has been created or destroyed 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-Sep-02
Category
Others
Language
Delphi 2.x
Views
80
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I have to write a kind of task list of all MDI child windows which are opened in 
the application. For this reason I tried to use the WM_PARENTNOTIFY to get an 
event, if a MDI child is created or destroyed. But I don't receive a message when 
the child windows are created or destroyed.

Answer:

Try the following:


1   const
2     WM_AddWin = WM_User + 300;
3     WM_DelWin = WM_User + 301;
4   
5   type
6     TForm1
7       { ... }
8     private
9   
10    procedure OnAddWindow(var msg: TMessage); message WM_AddWin;
11    procedure OnDelWindow(var msg: TMessage); message WM_DelWin;
12      public
13  end;
14  
15  procedure TForm1.OnAddWindow(var msg: TMessage);
16  begin
17    List.Add(Strpas(Pointer(msg.lparam)));
18  end;
19  
20  procedure TForm1.OnDelWindow(var msg: TMessage);
21  begin
22    List.delete(List.indexof(Strpas(Pointer(msg.lparam))));
23  end;
24  
25  procedure OnChildFormCreate(Sender: TObject);
26  begin
27    PostMessage(TForm(Owner).handle, WM_AddWin, 0, Integer(PChar('ChildFormname')));
28  end;
29  
30  procedure OnChildFormDestroy;
31  begin
32    PostMessage(TForm(Owner).handle, WM_DelWin, 0, Integer(PChar('ChildFormname')));
33  end;



This will post a message to the owner of a child form to add it to the master list 
and delete it
when it dies.

			
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