起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 1662|回复: 6

[分享]X3X.OCX的说明**

[复制链接]
发表于 2007-10-24 10:36:10 | 显示全部楼层 |阅读模式
用Delphi打开这个X3X.OCX文件,可以得到这个文件中提供的对象

  TBusiness = class(TOleControl)
  private
    FOnActivate: TNotifyEvent;
    FOnClick: TNotifyEvent;
    FOnCreate: TNotifyEvent;
    FOnDblClick: TNotifyEvent;
    FOnDestroy: TNotifyEvent;
    FOnDeactivate: TNotifyEvent;
    FOnKeyPress: TBusinessOnKeyPress;
    FOnPaint: TNotifyEvent;
    FOnServerAction: TNotifyEvent;
    FOnTerminate: TNotifyEvent;
    FIntf: IX3;
    function  GetControlInterface: IX3;
  protected
    procedure CreateControl;
    procedure InitControlData; override;
  public
    procedure Run(const FuncURL: WideString; const Params: WideString; const DeptID: WideString;
                  const PositionID: WideString);
    procedure Logon(const LogonID: WideString; const Password: WideString);
    procedure Logoff;
    procedure UpdateVersion;
    procedure Init;
    procedure ShowSplash;
    procedure CloseSplash;
    function AutoLogon(const ID: WideString; const Info: WideString): WordBool;
    function TerminateQuery: WordBool;
    function InvokeMethod(const MethodName: WideString; var Params: OleVariant): OleVariant;
    procedure Run2(const FuncURL: WideString; Params: OleVariant);
    property  ControlInterface: IX3 read GetControlInterface;
    property  DefaultInterface: IX3 read GetControlInterface;
    property Visible: WordBool index 1 read GetWordBoolProp write SetWordBoolProp;
    property Active: WordBool index 9 read GetWordBoolProp;
    property DropTarget: WordBool index 10 read GetWordBoolProp write SetWordBoolProp;
    property HelpFile: WideString index 11 read GetWideStringProp write SetWideStringProp;
    property DoubleBuffered: WordBool index 12 read GetWordBoolProp write SetWordBoolProp;
    property AlignDisabled: WordBool index 13 read GetWordBoolProp;
    property VisibleDockClientCount: Integer index 14 read GetIntegerProp;
    property Enabled: WordBool index -514 read GetWordBoolProp write SetWordBoolProp;
    property DisplayName: WideString index 20 read GetWideStringProp;
  published
    property  ParentColor;
    property  ParentFont;
    property  Align;
    property  DragCursor;
    property  DragMode;
    property  ParentShowHint;
    property  PopupMenu;
    property  ShowHint;
    property  TabOrder;
    property  OnDragDrop;
    property  OnDragOver;
    property  OnEndDrag;
    property  OnEnter;
    property  OnExit;
    property  OnStartDrag;
    property AutoScroll: WordBool index 2 read GetWordBoolProp write SetWordBoolProp stored False;
    property AutoSize: WordBool index 3 read GetWordBoolProp write SetWordBoolProp stored False;
    property AxBorderStyle: TOleEnum index 4 read GetTOleEnumProp write SetTOleEnumProp stored False;
    property Caption: WideString index -518 read GetWideStringProp write SetWideStringProp stored False;
    property Color: TColor index -501 read GetTColorProp write SetTColorProp stored False;
    property Font: TFont index -512 read GetTFontProp write SetTFontProp stored False;
    property KeyPreview: WordBool index 5 read GetWordBoolProp write SetWordBoolProp stored False;
    property PixelsPerInch: Integer index 6 read GetIntegerProp write SetIntegerProp stored False;
    property PrintScale: TOleEnum index 7 read GetTOleEnumProp write SetTOleEnumProp stored False;
    property Scaled: WordBool index 8 read GetWordBoolProp write SetWordBoolProp stored False;
    property Cursor: Smallint index 15 read GetSmallintProp write SetSmallintProp stored False;
    property HelpType: TOleEnum index 16 read GetTOleEnumProp write SetTOleEnumProp stored False;
    property HelpKeyword: WideString index 17 read GetWideStringProp write SetWideStringProp stored False;
    property ServerURL: WideString index 19 read GetWideStringProp write SetWideStringProp stored False;
    property MultiWindow: Integer index 27 read GetIntegerProp write SetIntegerProp stored False;
    property ThreadIdle: WordBool index 30 read GetWordBoolProp write SetWordBoolProp stored False;
    property IdleInterval: Integer index 29 read GetIntegerProp write SetIntegerProp stored False;
    property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
    property OnClick: TNotifyEvent read FOnClick write FOnClick;
    property OnCreate: TNotifyEvent read FOnCreate write FOnCreate;
    property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick;
    property OnDestroy: TNotifyEvent read FOnDestroy write FOnDestroy;
    property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate;
    property OnKeyPress: TBusinessOnKeyPress read FOnKeyPress write FOnKeyPress;
    property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
    property OnServerAction: TNotifyEvent read FOnServerAction write FOnServerAction;
    property OnTerminate: TNotifyEvent read FOnTerminate write FOnTerminate;
  end;
回复

使用道具 举报

 楼主| 发表于 2007-10-24 10:43:58 | 显示全部楼层
//进入平台,运行某个功能
{FuncURL 进入平台后运行的功能的BizURL,如果这个参数为空字符串,那么运行Biz:\sysem\init.func,进入平台主界面,如果已经执行Logon方法提供用户名密码,则不会弹出登陆对话框,如果没有调用Logon方法,则弹出登陆对话框
Params 运行功能的参数
DeptID 运行功能的部门ID
PositionID 运行功能的岗位ID
例如:
  Run('', '', '', '', '')  表示运行起平台的主界面
  Run('Biz:\myspace\myfunc.func', '', '', '')  表示进入平台,不显示平台主界面,只运行这个myfunc功能
}
   procedure Run(const FuncURL: WideString; const Params: WideString; const DeptID: WideString;
                  const PositionID: WideString);
//用LogonID和Password登陆平台(LogonID是人员的登陆ID,Password是密码)
    procedure Logon(const LogonID: WideString; const Password: WideString);
//注销
    procedure Logoff;
//更新NewVersion目录文件
    procedure UpdateVersion;
//执行控件的初始化工作
    procedure Init;
//显示splash.jpg或者splash.bmp图片
    procedure ShowSplash;
//关闭splash图片
    procedure CloseSplash;
回复 支持 反对

使用道具 举报

发表于 2007-10-24 11:01:39 | 显示全部楼层

好,跟上

好,收藏!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-24 11:02:54 | 显示全部楼层
procedure Run2(const FuncURL: WideString; Params: OleVariant);
不需要登陆主界面,直接运行某个功能

调用这个函数时候,实际调用的是平台上 系统空间\系统运行库\系统初始化 中的
function TCreateFunc.Invoke(var Params: array of object): object;
begin
  Result := TSystemCore.FuncManager.CreateFunc(BizSys.GlobalContext, System.String(Params[0]));
end;
函数,通过传递参数(Runs函数的Params参数)的方式,在平台上可以得到这些参数,从而知道应该用什么用户什么来运行这个给定的功能
在这个TCreateFunc.Invoke 函数中,System.String(Params[0])是run2方法的FuncURL参数
Params[1] 是 run2方法提供的 Params[0] 参数
Params[2] 是 run2方法提供的 Params[1] 参数
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-24 11:06:29 | 显示全部楼层
function InvokeMethod(const MethodName: WideString; var Params: OleVariant): OleVariant;
可以在平台上任意定义一个函数,通过调用OCX的InvokeMethod的方法来调用平台上的这个函数

平台上定义
在  系统空间\系统运行库\系统初始化 上定义一个对象,必须从TBusinessRuntimeServerMethod继承下来,并且重载两个函数
function GetName: string; override;  函数名,在ocx中就是用这个作为InvokeMethod的第一个参数MethodName
function Invoke(var Params: array of object): object; override; 函数体,当调用这个函数时候,实际就是在平台上执行这个函数的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-10-24 11:16:18 | 显示全部楼层
InvokeMethod举例:
参考  系统空间\系统运行库\系统初始化 中定义的 TGetOperatorID 对象
1  对象定义
  { TGetOperatorID }
  TGetOperatorID = class(TBusinessRuntimeServerMethod)
    function GetName: string; override;
    function Invoke(var Params: array of object): object; override;
  end;

2 对象方法的实现
{ TGetOperatorID }
function TGetOperatorID.GetName: string;
begin
  Result := 'GetOperatorID';
end;

function TGetOperatorID.Invoke(var Params: array of object): object;
begin
  if TSystemCore.Operator = nil then
    Result := ''
  else
    Result := TSystemCore.Operator.ID;
end;

3 在 TInit.Create 函数中,创建对象实例,并注册这个对象
//创建对象实例
  FGetOperatorID := TGetOperatorID.Create;
//注册这个对象
  BizRtSrvr.BusinessRuntimeServer.RegisterMethod(FGetOperatorID);

4 在 TInit.Destroy 中,反注册这个对象,释放对象
//反注册对象
  BizRtSrvr.BusinessRuntimeServer.UnregisterMethod(FGetOperatorID);
//释放对象
  FGetOperatorID.Free;

5 在网页上调用
function   pause(numberMillis)   {   
                  var   now   =   new   Date();   
                  var   exitTime   =   now.getTime()   +   numberMillis;   
                  while   (true)   {   
                          now   =   new   Date();   
                          if   (now.getTime()   >   exitTime)   
                                  return;   
                  }   
          }

X3X.ServerURL="<%=url%>"
X3X.UpdateVersion();
X3X.Init();
X3X.Run("", "", "", "");
pause(10000);  //这里需要延时,保证Run已经执行完成
alert(X3X.Invokemethod("GetOperatorID",""));
回复 支持 反对

使用道具 举报

发表于 2009-3-3 13:38:19 | 显示全部楼层
Invokemethod调用方法的时候,提示找不到方法!
http://bbs.justep.com/forum.php?mod=viewthread&tid=19915
补充说明一下:

Invokemethod此方法主要用来做系统集成。由于在X3X.Run的时候才调用TInit.Create来创建对象TInit,在X3X.Run结束时就已经调用了TInit.Destroy来释放对象TInit了。所以在Create里面注册和Destroy里面注销的方法都是要在X3X.Run运行之后,而X3X.Run调用结束之前来调用的。一般用于Web应用集成。在X3X.Run起来之后,在其他系统中通过invokemethod和X3系统来做通讯。

由于在X3X.Init里面调用了静态方法TInit.Init,所以如果需要在Run之前或之后再调用的话(如同本贴中就是在Run方法结束之后调用的),可以在TInit.init方法里面注册和TInit.Uninit里面来释放。当然,这时也需要在X3X.Init之后才能调用。(TInit.Uninit是由系统自动调用的,不需要使用者考虑。)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-4-27 12:50 , Processed in 0.051949 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表