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
Knowing Run-Time verses Design-Time mode in an Active Form 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
26-Jul-03
Category
ActiveX
Language
Delphi 4.x
Views
168
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Christopher Brandsma

How to find out if your ActiveX control is running in Design mode or Run mode

Answer:

Every now and then an ActiveForm developer will want to add a feature to an ActiveX 
control that only shows up in either Design-Time or Run-Time (splash screens and 
nag screens are an example). (Background: Design-Time is when a control is applied 
to a form in the Visual Basic environment; Run-Time is when the control is running 
inside of an executable).  If you are using TActiveXControl as you’re base object, 
you get this for free.  If you are using TActiveForm you have to work for the 
information. 

The property we need is UserMode.  If this property is True we are in Run-Time 
mode; if False we are in Design-Time mode. UserMode is one of the AmbientProperties 
that a control’s container is supposed to provide.  Delphi even supplies an 
interface call IAmbientDispatch in AxCtrls for retrieving the ambient properties.   

To get it: Your ActiveForm has a property called ActiveFormControl.ClientSite.  
This property is set sometime before your control's OnShow event (ClientSite will 
not be set in the constructor or the initialize procedures).  Cast ClientSite to an 
IAmbientDispatch (found in AxCtrls), then get the UserMode property. (see code 
below) 

1   procedure TDesignCtrl.HandleOnShow(Sender: TObject);
2   var
3     b: Boolean;
4     pIAmbient: IAmbientDispatch;
5   begin
6     pIAmbient := Self.ActiveFormControl.ClientSite as IAmbientDispatch;
7     b := pIAmbient.UserMode;
8   
9     if b then
10      ShowMessage('is in runtime mode')
11    else
12      ShowMessage('is in design mode');
13  end;


There are other properties in the IAmbientDispatch interface that could also be useful to a control writer so feel free to experiment. 

			
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