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 check if a component sits on a normal TForm or on an ActiveX one 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
VCL-Forms
Language
Delphi 3.x
Views
66
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I have a component that is used both on an Active Form and on a normal TForm. The 
component needs to find out if the application it's being used in is an ActiveX 
project or a normal project. Is there a good way to find out?

Answer:

In case your component is TControl you can use the functions below:
1   
2   function IsParentFormActiveXOne(Control: TControl): Boolean;
3   function GetParentForm(Control: TControl): TCustomForm;
4   
5       function GetParentForm(Control: TControl): TCustomForm;
6       begin
7         Result := nil;
8         if Assigned(Control) then
9           if Control is TCustomForm then
10          begin
11            Result := Control as TCustomForm;
12            if Assigned(Result) and (Result is TForm) and 
13  						(TForm(Result).FormStyle = fsMDIForm) then
14            begin
15              Exit;
16            end;
17          end
18          else
19          begin
20            if Assigned(Control.Parent) then
21              Result := GetParentForm(Control.Parent);
22          end;
23      end;
24  
25      function IsParentFormActiveXOne(Control: TControl): Boolean;
26      var
27        Form: TCustomForm;
28      begin
29        Form := GetParentForm(Control);
30        Result := Assigned(Form) and (Form is TCustomActiveForm);
31      end;
32  
33  //Otherwise simply use:
34  
35  if TCustomForm(Owner) is TCustomActiveForm then
36    { ... }


			
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