全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1807
推到 Plurk!
推到 Facebook!

我是新手,問幾個DELPHI ActiveForm比較低級的問題,請各位大哥不吝指點,謝謝。

尚未結案
yzml
一般會員


發表:4
回覆:4
積分:1
註冊:2004-12-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-12-26 21:41:51 IP:218.91.xxx.xxx 未訂閱
問題一: 在不添加任何的屬性情況下,DELPHI的ActiveForm自帶了很多屬性,如下:    Visible,AutoScroll,AutoSize, AxBorderStyle, Caption, Color, Font, KeyPreview, PixelsPerInch, PrintScale, Scaled, Active, DropTarget, HelpFile, ScreenSnap, SnapBuffer, DoubleBuffered, AlignDisabled, VisibleDockClientCount, Enabled. 在用FrontPage等網頁製作軟體中插入用DELPHI開發的ActiveX控制項時,這些DELPHI自帶的屬性參數被帶入HTML,如下: 〈object classid="clsid:977AEDDD-6591-49D6-8EA3-C0DF2440EE23" id="AddressDialogActiveForm1" width="594" height="401"〉 〈param name="Visible" value="0"〉 〈param name="AutoScroll" value="0"〉 〈param name="AutoSize" value="0"〉 〈param name="AxBorderStyle" value="1"〉 〈param name="Caption" value="AddressDialogActiveForm"〉 〈param name="Color" value="2147483663"〉 〈param name="Font" value="MS Sans Serif"〉 〈param name="KeyPreview" value="0"〉 〈param name="PixelsPerInch" value="96"〉 〈param name="PrintScale" value="1"〉 〈param name="Scaled" value="-1"〉 〈param name="DropTarget" value="0"〉 〈param name="HelpFile" value〉 〈param name="DoubleBuffered" value="0"〉 〈param name="Enabled" value="-1"〉 〈param name="Cursor" value="0"〉 〈param name="HelpType" value="1"〉 〈param name="HelpKeyword" value〉 〈/object〉 請問如果程式中不使用這些屬性,通過DELPHI的VIEW->Type Library 介面將它們刪除,會影響其工作嗎? 同樣,DELPHI的ActiveForm也自帶了如下事件,如果刪除,會影響其工作嗎? OnActivate, OnClick, OnCreate, OnDblClick, OnDestroy, OnDeactivate, OnKeyPress, OnPaint. 問題二: 在定義屬性和事件時,通過DELPHI的VIEW->Type Library 介面查看,Flag中有許多選項: Replaceable,DisplayBindable,NonBrowsable,Restricted,DefaultBindable,ImmediateBindable,Source,Hidden,Uses Get Last Error,Bindable,Default Collection Element,Request Edit,UI default. 這些選項的作用分別是什麼?同樣,某個Interface也有許多Flag選項: Hidden,Preddefined,NonExtensible,Can Create,Control,Replaceable,Application Object,Dual,Aggregatable,Licensed,OleAutomation. 這些Flag選項的作用又是什麼?
yzml
一般會員


發表:4
回覆:4
積分:1
註冊:2004-12-26

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-12-26 22:06:47 IP:218.91.xxx.xxx 未訂閱
問題三: HTML向ActiveX控制項傳送參數有以下幾種方式:    (1)載入時通過Param傳入: 〈object classid="clsid:xxxx-xxxx-xxxx-xxxx-xxxx" id="ActiveX1" width="594" height="401"〉 〈param name="Visible" value="0"〉 〈/object〉 (2)載入後通過函數傳出、傳入: 〈object classid="clsid:xxxx-xxxx-xxxx-xxxx-xxxx" id="ActiveX1" width="594" height="401"〉 傳入 ActiveX1.Visible=0 傳出 CanBeSee=ActiveX1.Visible 在關於DELPHI的有關資料中有多種方式實現參數傳送: (1)在Type Library的pas檔中定義: IYzFTP = interface(IDispatch) ['{D0B55322-B569-4A7E-B256-AEB5B1EC2828}'] function Get_ServerName: WideString; safecall; procedure Set_ServerName(const Value: WideString); safecall; property ServerName: WideString read Get_ServerName write Set_ServerName; 在impl的pas檔中定義: type TYzFTP = class(TActiveForm, IYzFTP) …… protected function Get_ServerName: WideString; safecall; procedure Set_ServerName( Value:WideString); safecall; ……. end; implementation …… function TYzFTP.Get_ServerName: WideString; begin Result := WideString(ServerName); end; procedure TYzFTP.Set_ServerName(const Value: WideString); begin ServerName := Value; end; (2)在Type Library的pas檔中定義: TYzFTP = class(TOleControl) …… published property ServerName: WideString index 201 read GetWideStringProp write SetWideStringProp stored False; …… end; 但GetWideStringProp、SetWideStringProp是幹什麼用的?應該如何實現?與Get_ServerName和Set_ServerName是什麼關係? (3)在Impl的pas檔中定義,如: TActiveFormNewX = class(TActiveFormX,IPersistPropertyBag) public ServerName:String; protected function IPersistPropertyBag.Load =PersistPropertyBagLoad; end; function TActiveFormNewX.PersistPropertyBagLoad(const pPropBag:IPropertyBag; Const pErrorLog:IErrorLog):HResult;stdCall; var Str:OleVariant; begin if pPropBag.Read('ServerName', Str ,pErrorLog) = S_OK then ServerName :=Str; Result:=S_OK; end; 請問這幾種方法的關係、適用場合?如何為某些屬性分配預設值,既既不通過〈param name='XXXX' value='YYYY' 〉也不通過ActiveX1.XXX=YYY 給屬性XXX賦值時,XXX有個原始的預設值?
yzml
一般會員


發表:4
回覆:4
積分:1
註冊:2004-12-26

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-12-26 22:26:56 IP:218.91.xxx.xxx 未訂閱
問題四:    我增加了屬性ServerName和事件OnTestEnd,但編譯時出錯,明明這屬性和事件在Type Library中已經定義,為什麼還出錯呢?該如何修改?    ============================================================= YzFTPImpl.pas ============================================================= unit YzFTPImpl; {$WARN SYMBOL_PLATFORM OFF} interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ActiveX, AxCtrls, YzFTP_TLB, StdVcl; type TYzFTP = class(TActiveForm, IYzFTP) private { Private declarations } FEvents: IYzFTPEvents; procedure TestEndEvent(Sender: TObject); protected { Protected declarations } procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override; procedure EventSinkChanged(const EventSink: IUnknown); override; function Get_ServerName: WideString; safecall; procedure Set_ServerName(const Value:WideString); safecall; public { Public declarations } procedure Initialize; override; end; implementation uses ComObj, ComServ; {$R *.DFM} { TYzFTP } procedure TYzFTP.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); begin { Define property pages here. Property pages are defined by calling DefinePropertyPage with the class id of the page. For example, DefinePropertyPage(Class_YzFTPPage); } end; procedure TYzFTP.EventSinkChanged(const EventSink: IUnknown); begin FEvents := EventSink as IYzFTPEvents; inherited EventSinkChanged(EventSink); end; procedure TYzFTP.Initialize; begin inherited Initialize; OnTestEnd := TestEndEvent; end; function TYzFTP.Get_ServerName: WideString; begin Result := WideString(ServerName); end; procedure TYzFTP.TestEndEvent(Sender: TObject); begin if FEvents <> nil then FEvents.OnTestEnd; end; procedure TYzFTP.Set_ServerName(const Value: WideString); begin ServerName := Value; end; initialization TActiveFormFactory.Create( ComServer, TActiveFormControl, TYzFTP, Class_YzFTP, 1, '', OLEMISC_SIMPLEFRAME or OLEMISC_ACTSLIKELABEL, tmApartment); end. ============================================================== Error.TXT ============================================================== Build [Error] YzFTPImpl.pas(x1x): Undeclared identifier: 'OnTestEnd' [Error] YzFTPImpl.pas(x2x): Not enough actual parameters [Error] YzFTPImpl.pas(x3x): Undeclared identifier: 'ServerName' [Error] YzFTPImpl.pas(x4x): Undeclared identifier: 'ServerName' [Fatal Error] YzFTP.dpr(6): Could not compile used unit 'YzFTPImpl.pas'
Ktop_Robot
站務副站長


發表:0
回覆:3511
積分:0
註冊:2007-04-17

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-04-26 13:51:13 IP:000.000.xxx.xxx 未訂閱
提問者您好:


以上回應是否已得到滿意的答覆?


若已得到滿意的答覆,請在一週內結案,否則請在一週內回覆還有什麼未盡事宜,不然,
將由版主(尚無版主之區域將由副站長或站長)自由心證,選擇較合適之解答予以結案處理,
被選上之答題者同樣會有加分獎勵同時發問者將受到扣 1 分的處分。不便之處,請見諒。


有問有答有結案,才能有良性的互動,良好的討論環境需要大家共同維護,感謝您的配合。

------
我是機器人,我不接受簡訊.
系統時間:2024-07-05 9:22:28
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!