一个COM组件的问题,可能有点难 Delphi本身提供对Color,font,的调度,所以你可以直接设置IFONT接口的FONT属性具体的可以看一下书 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 to qqcxg(爱谁谁):我试过 IFont*,但不知道还要什么代码,买不起书看... 使用IFont吧好用的!很方便的 哎!你自己写IFont 的的数据呵呵一点都不难! var fnt:tfont;begin fnt:=iinterface1.Font; form1.Font:=fnt;end; 我很奇怪这个问题,很难吗?在你的myimage中定义的myfont属性,设其类型为ifont不就可以了??? unit Unit2;interfaceuses ComObj, ActiveX,windows, Project1_TLB,Graphics, StdVcl;type TFontX=Class(TFont,IFont) protected function get_Name(out name: WideString): HResult; stdcall; function put_Name(name: WideString): HResult; stdcall; function get_Size(out size: Currency): HResult; stdcall; function put_Size(size: Currency): HResult; stdcall; function get_Bold(out bold: BOOL): HResult; stdcall; function put_Bold(bold: BOOL): HResult; stdcall; function get_Italic(out italic: BOOL): HResult; stdcall; function put_Italic(italic: BOOL): HResult; stdcall; function get_Underline(out underline: BOOL): HResult; stdcall; function put_Underline(underline: BOOL): HResult; stdcall; function get_Strikethrough(out strikethrough: BOOL): HResult; stdcall; function put_Strikethrough(strikethrough: BOOL): HResult; stdcall; function get_Weight(out weight: Smallint): HResult; stdcall; function put_Weight(weight: Smallint): HResult; stdcall; function get_Charset(out charset: Smallint): HResult; stdcall; function put_Charset(charset: Smallint): HResult; stdcall; function get_hFont(out font: HFont): HResult; stdcall; function Clone(out font: IFont): HResult; stdcall; function IsEqual(const fontOther: IFont): HResult; stdcall; function SetRatio(cyLogical, cyHimetric: Longint): HResult; stdcall; function QueryTextMetrics(out tm: TTextMetricOle): HResult; stdcall; function AddRefHfont(font: HFont): HResult; stdcall; function ReleaseHfont(font: HFont): HResult; stdcall; function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; function _AddRef: Integer; stdcall; function _Release: Integer; stdcall; end; TTestFont = class(TAutoObject, ITestFont) protected procedure Font(const Value: IFont); safecall; { Protected declarations } end;implementationuses ComServ,Unit1;procedure TTestFont.Font(const Value: IFont);var XFont:TFontX; p:pointer;begin XFont:=p; p:=XFont; Form1.Font:=p; end;function TFontX.get_Name(out name: WideString): HResult; stdcall;beginname:=Self.Name;end;function TFontX.put_Name(name: WideString): HResult; stdcall;beginself.Name:=Name;end;Function TFontX.get_Size(out size: Currency): HResult; stdcall;begin self.Size:=size;end;function TFontX.put_Size( size: Currency): HResult; stdcall;beginself.Size:=size;end;initialization TAutoObjectFactory.Create(ComServer, TTestFont, Class_TestFont, ciMultiInstance, tmApartment);end.你吧TFontX的方法全实现了就可以这样用了,没时间来搞现在转告软件工程了! 非常感谢各位的支持,尤其是 manboo(横刀) 大侠。转了个小弯总算实现了要的结果,美中不足的是,属性的属性还不能被 InterDev 这样的智能IDE自动列出,只能是:set obj2 = obj1.property1 obj2.property2 = x看来还得多看些书 一个很简单却又是很难的问题 一个迷惑的问题请教! 超级郁闷--〉郁闷!动态连接库与内存管理问题,高手请指点,up有分! bde中access的用户名和密码是多少啊,急!!!! 一个关于string分配内存的问题 又是报表问题!急!在线等待…… 求助!!!!delphi用ADO连接数据库时,密码或用户等出错,直接退出程序??为何? 有关文件存储格式的问题(一位站在门槛上的。。。) 求分发工具 如何在Delphi中得到所有的错误 如何实现TMediaPlayer控件的全屏显示? 急。。。。有关ADODataSet的问题。。
我试过 IFont*,但不知道还要什么代码,买不起书看...
fnt:tfont;
begin
fnt:=iinterface1.Font;
form1.Font:=fnt;
end;
在你的myimage中定义的myfont属性,设其类型为ifont不就可以了???
ComObj, ActiveX,windows, Project1_TLB,Graphics, StdVcl;type
TFontX=Class(TFont,IFont)
protected
function get_Name(out name: WideString): HResult; stdcall;
function put_Name(name: WideString): HResult; stdcall;
function get_Size(out size: Currency): HResult; stdcall;
function put_Size(size: Currency): HResult; stdcall;
function get_Bold(out bold: BOOL): HResult; stdcall;
function put_Bold(bold: BOOL): HResult; stdcall;
function get_Italic(out italic: BOOL): HResult; stdcall;
function put_Italic(italic: BOOL): HResult; stdcall;
function get_Underline(out underline: BOOL): HResult; stdcall;
function put_Underline(underline: BOOL): HResult; stdcall;
function get_Strikethrough(out strikethrough: BOOL): HResult; stdcall;
function put_Strikethrough(strikethrough: BOOL): HResult; stdcall;
function get_Weight(out weight: Smallint): HResult; stdcall;
function put_Weight(weight: Smallint): HResult; stdcall;
function get_Charset(out charset: Smallint): HResult; stdcall;
function put_Charset(charset: Smallint): HResult; stdcall;
function get_hFont(out font: HFont): HResult; stdcall;
function Clone(out font: IFont): HResult; stdcall;
function IsEqual(const fontOther: IFont): HResult; stdcall;
function SetRatio(cyLogical, cyHimetric: Longint): HResult; stdcall;
function QueryTextMetrics(out tm: TTextMetricOle): HResult; stdcall;
function AddRefHfont(font: HFont): HResult; stdcall;
function ReleaseHfont(font: HFont): HResult; stdcall;
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
end;
TTestFont = class(TAutoObject, ITestFont)
protected
procedure Font(const Value: IFont); safecall;
{ Protected declarations }
end;implementationuses ComServ,Unit1;procedure TTestFont.Font(const Value: IFont);
var
XFont:TFontX;
p:pointer;
begin
XFont:=p;
p:=XFont;
Form1.Font:=p;
end;
function TFontX.get_Name(out name: WideString): HResult; stdcall;
begin
name:=Self.Name;
end;
function TFontX.put_Name(name: WideString): HResult; stdcall;
begin
self.Name:=Name;end;
Function TFontX.get_Size(out size: Currency): HResult; stdcall;
begin
self.Size:=size;
end;
function TFontX.put_Size( size: Currency): HResult; stdcall;
begin
self.Size:=size;
end;initialization
TAutoObjectFactory.Create(ComServer, TTestFont, Class_TestFont,
ciMultiInstance, tmApartment);
end.
你吧TFontX的方法全实现了就可以这样用了,没时间来搞现在转告软件工程了!
obj2.property2 = x看来还得多看些书