Thread View: comp.lang.pascal.delphi.components.writing
3 messages
3 total messages
Started by M.Ish
Mon, 10 Nov 1997 00:00
[Q] How can I make a script safe ActiveX Control?
Author: M.Ish
Date: Mon, 10 Nov 1997 00:00
Date: Mon, 10 Nov 1997 00:00
104 lines
3509 bytes
3509 bytes
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.
Re: [Q] How can I make a script safe ActiveX Control?
Author: Jason Swager
Date: Tue, 11 Nov 1997 00:00
Date: Tue, 11 Nov 1997 00:00
6 lines
1054 bytes
1054 bytes
Better yet, get it from the man himself... http://pweb.netcom.com/~cherrman/daxfaqs.htm Jason Swager jswager@alohaoi.com
Re: [Q] How can I make a script safe ActiveX Control?
Author: 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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads