转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
Building ActiveX Controls with Delphi 3         ★★★★

Building ActiveX Controls with Delphi 3

作者:闵涛 文章来源:闵涛的学习笔记 点击数:5176 更新时间:2009/4/23 18:31:11
edientials and the file that contains the private key. In the Project|Web Deployment Options dialog, in the Project page, check the Code Sign Project checkbox. Then, turn to the Code Signing page and fill in the credentials file and private key file fields.

The application name and optional company URL fields will appear in the certificate dialog when the app is downloaded and verified. You should enter your company''''s information here.

Web Security

Security is an extremely important when you''''re building an ActiveX for web deployment. While ActiveX controls can be very powerful and convenient, they can also become your worst nightmare. As a builder of ActiveX controls, here are some things you should consider:

  • Be ethical. Don''''t build ActiveX controls that are harmful.
  • Build your control to be tamper-resistant.
  • Keep close watch on your software certificate. Establish notary procedures for its use. Keep records about what controls you''''ve signed and who signed it, and who had access to the signature key.
  • Don''''t give your control privileges over your network. Don''''t include default passwords, etc.
  • Set up your server so it knows who downloads the controls and when and where.

When deploying ActiveX controls in an Intranet, here''''s some advice:

  • Code signatures do not necessarily mean full security. Even signed, legitimate ActiveX controls have security flaws that can be taken advantage of.
  • Don''''t accept HTML pages containing an ActiveX control from anyone you don''''t trust as well as your least trustworthy staff. If you have a business partner that only publishes its data through an ActiveX, allow only that ActiveX to run, and only in the context of the page they published.
  • Caveat surfer

Data-aware controls

VB4 provides an open specification for "simple data bound controls." Such controls are typically controls that show a single value, like an edit field or a check box. Unlike the VB complex data binding spec, this standard has been adopted by a number of vendor, with the notable exception of Delphi itself. Despite the fact that Delphi doesn''''t host data-bound ActiveX controls, it can be used to produce them without too much trouble.

It doesn''''t take much to make a control data-aware, once you have a working ActiveX control. A simple data-aware ActiveX control has a special property that represents its "value". The property might be called Value, Text, Temperature, or whatever. This property is marked in the type library with several flags that indicate that it can be bound to. You can use the type library editor to set the flags in the control that indicate how the property is to be bound. Figure 3 shows how this can be done, by checking the Bindable, Request Edit, Display Bindable and Default Bindable flags of the property''''s Attributes pane.

The options tell the container that it can bind a data source value to this property. If the container chooses to bind a data source to the bindable property, the two always keep their values synchronized: when the data source changes value, the value property, and when the value property changes the data source changes value.

Figure 4. Type library editor, showing the Caption property defined as the default bound property.

The value property must also ask its container for permission to change the value property, before the property is actually changed. The container can refuse the modification if desired.

You can implement this relationship easily by taking advantage of the OnChanging and OnChanged events of your VCL control.

class TButtonXControl = ...;
  ...
private  
  FPropNotifySink: IPropNotifySink;
end;

procedure TButtonXControl.InitializeControl; 
begin
  FConnectionPoints.CreateConnectionPoint(IPropNotifySink, PropNotifySinkConnect); 
  FDelphiControl.OnChanged := OnChangedEvent;
  FDelphiControl.OnChanging := OnChangingEvent;
end;

procedure TButtonXControl.PropNotifySinkConnect(const Sink: IUnknown);
begin
  if Sink <> nil then 
    OleCheck(Sink.QueryInterface(IPropNotifySink, FPropNotifySink)) 
  else FPropNotifySink := nil;
end;

procedure TButtonXControl.Set_Caption(const Value: WideString);
begin
  FDelphiControl.Caption := TCaption(Value);
end;

procedure TButtonXControl.OnChangingEvent( Sender: TObject );
begin
  if FPropNotifySink <> nil then 
    if FPropertyNotifySink.RequestEdit( DISPID_CAPTION ) = S_FALSE then
      OleError( CTL_E_SETNOTPERMITTED );
end;

procedure TButtonX.OnChangedEvent( Sender:TObject );
begin 
  if FPropNotifySink <> nil then FPropNotifySink.OnChanged( DISPID_CAPTION );
end;

Conclusion

Delphi 3 provides you with an easy way to get started building ActiveX controls, bu combining a basic class framework called DAX with the VCL and a set of code-generation wizards. In this class, I''''ve explained how to convert a VCL control into an ActiveX control, and then how to add some of the more important ActiveX features to the control. I''''ve also explained how the Delphi ActiveX framework is built, and shown how you can extend it. This is an important skill, because ActiveX is an extremely fluid specification.

Further Reading

Microsoft''''s OLE web site is at http://www.microsoft.com/oledev. There''''s lots of really good stuff there.

Books

Designing and Using OLE Custom Controls, Tom Armstrong, M&T Press.

Tom maintains a web site at http://www.widgetware.com, including a comprehensive FAQ.

OLE Controls Inside Out, Adam Denning, Microsoft Press

Inside OLE, Kraig Brockschmidt, Microsoft Press

More book listings can be found at http://www.microsoft.com/oledev/books.htm

White papers

The Java Beans Specification, at http://splash.javasoft.com/beans/spec.html

This paper is a better explanation of component models than Microsoft''''s.

What OLE is Really About, by Kraig Brockschmidt, at http://www.microsoft.com/oledev/olecom/aboutole.htm. Best quote: "OLE is very much like the Coke bottle…"

Vijay Mukhi''''s site: http://www.neca.com/~vmis/ Vijay writes irreverently about various technologies, including ActiveX. Best quote: "Microsoft has won the battle for the Internet".

Documentation

OLE Controls specification, versions 1.0, 1.1 and 2.0, from Microsoft.

OC96 - additions to the OLE controls specification, from Microsoft.

ActiveX SDK Docs on ActiveX Controls: http://www.microsoft.com/msdn/sdk/platforms/doc/activex/src/olectrl.htm

Authenticode: see Microsoft''''s web site at http://www.microsoft.com/security/tech/misf8_2.htm

ActiveDesigner: see http://www.microsoft.com/intdev/sdk/dtctrl

Class hierarchies

Class hierarchies can be useful reference material when you can''''t find why something doesn''''t work. Look for cryptic comments like ''''some containers do this, so we have to bend over backwards here'''' to discover where a Microsoft developer has been there before you.

MFC - with Borland C++ 5.01 or Microsoft Visual C++ 4.2a.

ActiveX SDK - the BaseCtl framework. See http://www.microsoft.com/intdev/sdk/sdk.htm

ATL 2.x - with Microsoft Visual C++ 5.0

OLE Control Developer''''s Kit - from Microsoft, in the ActiveX SDK.

(C) Copyright 1997 by Conrad Herrmann. You may copy, modify, distribute or use for any purpose all ObjectPascal source code published in this article. All other rights reserved.

上一页  [1] [2] [3] [4] [5] [6] [7] [8] 


[办公软件]excel中的VBA中的With语句的使用介绍及实例  [系统软件]OLE with the internet explorer
[Delphi程序]Delphi深度探索-数据库明了的ActiveX控件  [Delphi程序]override deal with window closing in database …
[Delphi程序]DELPHI实现activex控件的限制  [Delphi程序]Delphi使用VB编写的ActiveX控件全攻略
[Delphi程序]Delphi使用VB6编写的ActiveX控件???  [Delphi程序]MediaPlayer9 ActiveX 攻略(原创)
[VB.NET程序]Socket Programming with VB  [VB.NET程序]Managing Windows with WMI
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台