Article View: comp.lang.pascal.delphi.components.writing
Article #10Re: [Q] How can I make a script safe ActiveX Control?
From: Jason Swager
Date: Tue, 11 Nov 1997 00:00
Date: Tue, 11 Nov 1997 00:00
206 lines
6659 bytes
6659 bytes
Try this -- it is from Conrad Herrmann...
Install the appropriate registry keys for your control. You can do
this by replacing the factory creation code (at the bottom of your
control's implementation unit) with a call that creates a special
factory with the object safety registry entries. Basically this means
replacing the code that says "TActiveXControlFactory.Create" with
"TSafeActiveXControlFactory.Create", and USEing the following unit.
unit SafeFactory;
interface
uses ComObj, ActiveX, AXCtrls;
const
CATID_SafeForScripting: TGUID =
'{7DD95801-9882-11CF-9FA9-00AA006C42C4}';
CATID_SafeForInitializing: TGUID =
'{7DD95802-9882-11CF-9FA9-00AA006C42C4}';
type
TSafeActiveFormFactory = class( TActiveFormFactory )
procedure UpdateRegistry( Register: Boolean ); override;
end;
TSafeActiveXControlFactory = class( TActiveXControlFactory )
procedure UpdateRegistry( Register: Boolean ); override;
end;
implementation
procedure AddSafetyKeys( const ClassID: TGUID );
var
ClassKey: string;
begin
ClassKey := 'CLSID\' + GUIDToString( ClassID );
CreateRegKey( ClassKey + '\Implemented Categories','','');
CreateRegKey( ClassKey + '\Implemented Categories\'+GUIDToString(
CATID_SafeForScripting ),'','');
CreateRegKey( ClassKey + '\Implemented Categories\'+GUIDToString(
CATID_SafeForInitializing ),'','');
end;
procedure RemoveSafetyKeys( const ClassID: TGUID );
var
ClassKey: string;
begin
ClassKey := 'CLSID\' + GUIDToString( ClassID );
DeleteRegKey( ClassKey + '\Implemented Categories\'+GUIDToString(
CATID_SafeForInitializing ));
DeleteRegKey( ClassKey + '\Implemented Categories\'+GUIDToString(
CATID_SafeForScripting ));
DeleteRegKey( ClassKey + '\Implemented Categories');
end;
{TSafeActiveFormFactory}
procedure TSafeActiveFormFactory.UpdateRegistry( Register: Boolean );
begin
if Register then
begin
AddSafetyKeys( ClassID );
inherited UpdateRegistry( Register );
end
else
begin
RemoveSafetyKeys( ClassID );
inherited UpdateRegistry( Register );
end;
end;
{TSafeActiveXControlFactory}
procedure TSafeActiveXControlFactory.UpdateRegistry( Register: Boolean
);
begin
if Register then
begin
AddSafetyKeys( ClassID );
inherited UpdateRegistry( Register );
end
else
begin
RemoveSafetyKeys( ClassID );
inherited UpdateRegistry( Register );
end;
end;
end.
This will solve your first problem. ActiveX components must have a
window handle -- I haven't heard about any preloader, unless you are
talking about server side scripting. The <PARAM> tag doesn't work
with standard D3 ActiveX -- it requires an interface called IGrabBag
or some such thing. You can do it, but D3 doesn't automatically do
it.
Hope this helps...
Jason Swager
jswager@alohaoi.com
On Mon, 10 Nov 1997 23:18:03 +0900, "M.Ish"
<l50679@sakura.kudpc.kyoto-u.ac.jp> wrote:
>Hello
>
> I have been trying to make an ActiveX Control to be used on a WEB Page.
>And I face some problems.
>
>1. I would like to control the ActiveX control with JavaScript.
>But an ActiveX Control converted from VCL is not script safe. So,
>it is rejected unless I lower the security level of my browser.
>How can I make an ActiveX control that is script safe?
>
>2. An ActiveX control made with Delphi3 does not seem to understand
>the <PARAM> tag in an HTML file. All the information of parameters are
>encoded into DATA=... part within <Object> tag.
>Is there any way to have it understand <PARAM> tag?
>
>3. Is it possible to make an ActiveX control without window handle? (
>something like preloader at MS's WEB page.)
>
>4. The ActiveX control made from the following code works fine on
>Delphi, MSIE and VB, but not exactly on ActiveX Control Pad.
>(You can see the ActiveX control at
>http://www.solution.co.jp/ac/ishii/AXtest/
>if you lower the security level of your browser.)
>The Paint method is called and a circle is drawn only when
>the Paint event is called from windows (for example, when
>the control is resized (maybe when Invalidate is called) ).
>If I replace the "Sendmessage(...)" with "Invalidate", it works on
>ActiveX control Pad, but then it starts blinking.
>Could anyone tell me why this happens and how I can solve this problem?
>
>
>Thanks in advance
>
>---- Code of the Control in item4------
>
>unit testpaint;
>
>interface
>
>uses
> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
> ExtCtrls;
>
>type
> Ttestpaint = class(TCustomPanel)
> private
> i: integer;
> mytimer: TTimer;
> procedure PaintEvent(Sender:TObject);
> {Private}
> protected
> {Protected}
> public
> constructor Create(Owner:Tcomponent); override;
> destructor Destroy; override;
> procedure Paint; override;
> {Public}
> published
> {Published}
> end;
>
>procedure Register;
>
>implementation
>
>constructor TtestPaint.Create(Owner:Tcomponent);
>begin
> inherited Create(Owner);
> mytimer:=TTimer.Create(self);
> mytimer.interval:=1000;
> mytimer.OnTimer:=PaintEvent;
> i:=20;
>end;
>
>
>destructor Ttestpaint.Destroy;
>begin
> mytimer.free;
> inherited Destroy;
>end;
>
>procedure Ttestpaint.PaintEvent(Sender:TObject);
>begin
> // If I replace the following line with "Invalidate",
> //it works on ActiveX Control Pad.
> // But then, it starts blinking.
> SendMessage(Handle,Wm_Paint,Canvas.Handle,0);
>end;
>
>procedure Ttestpaint.Paint;
>begin
> canvas.ellipse(0,0,i,i);
> i:=(i+20) mod 200;
>end;
>
>
>
>procedure Register;
>begin
> RegisterComponents('Samples', [Ttestpaint]);
>end;
>
>end.
Technical Details
Message-ID:
<3467c2de.1825518@nntp.ix.netcom.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3467179B.102@sakura.kudpc.kyoto-u.ac.jp>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5214,89810db6b1c520b2 X-Google-Attributes: gidf5214,public X-Google-Thread: 109d99,89810db6b1c520b2 X-Google-Attributes: gid109d99,public X-Google-Thread: 10baee,89810db6b1c520b2 X-Google-Attributes: gid10baee,public X-Google-Thread: fe2ce,89810db6b1c520b2 X-Google-Attributes: gidfe2ce,public From: jswager@alohaoi.com (Jason Swager) Subject: Re: [Q] How can I make a script safe ActiveX Control? Date: 1997/11/11 Message-ID: <3467c2de.1825518@nntp.ix.netcom.com> X-Deja-AN: 288456900 References: <3467179B.102@sakura.kudpc.kyoto-u.ac.jp> Organization: Netcom X-NETCOM-Date: Mon Nov 10 8:31:54 PM CST 1997 Reply-To: jswager@alohaoi.com Newsgroups: comp.lang.pascal.delphi.components.writing,comp.lang.pascal.delphi.misc,comp.lang.pascal.delphi.components.misc,borland.public.delphi.activex.controls.writing