H
huanzhugege
Unregistered / Unconfirmed
GUEST, unregistred user!
请问一个关于在自定义控件中包含ACTIVEX控件的问题。下面的TLincoBarCode是一个ACTIVEX控件,为什么当我把我定义的这个控件注册并拖放到窗体上时,会发生“Could not obtain OLE control window handle”错误?难道在自定义控件中不能包含ACTIVEX控件吗?
type
TQRBarCode = class(TQRPrintable)
private
{ Private declarations }
FBarCode: TLincoBarCode;
protected
{ Protected declarations }
………………
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
……………………………………
end;
procedure Register;
implementation
constructor TQRBarCode.Create(AOwner: TComponent);
Const
INITWIDTH = 60;
INITHEIGHT = 30;
begin
inherited Create(AOwner);
FBarCode := TLincoBarCode.Create(nil);
FBarCode.Width := INITWIDTH;
FBarCode.Height := INITHEIGHT;
self.Width := INITWIDTH;
self.Height := INITHEIGHT;
end;
destructor TQRBarCode.Destroy;
begin
FBarCode.Free;
inherited;
end;
………………………………
procedure TQRBarCode.Paint;
var
srcdc, destdc: HDC;
begin
srcdc := GetDc(FBarCode.Handle);
destdc := GetDC(self.Handle);
BitBlt(destdc, 0, 0, FBarCode.Width, FBarCode.Height,
srcdc, 0, 0, SRCCOPY);
ReleaseDC(FBarCode.Handle, srcdc);{ TODO : ole }
ReleaseDC(self.Handle, destdc);
end;
…………………………………………
procedure TQRBarCode.Refresh;
begin
FBarCode.Refresh;
Invalidate();
end;
其中的
type
TQRBarCode = class(TQRPrintable)
private
{ Private declarations }
FBarCode: TLincoBarCode;
protected
{ Protected declarations }
………………
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
……………………………………
end;
procedure Register;
implementation
constructor TQRBarCode.Create(AOwner: TComponent);
Const
INITWIDTH = 60;
INITHEIGHT = 30;
begin
inherited Create(AOwner);
FBarCode := TLincoBarCode.Create(nil);
FBarCode.Width := INITWIDTH;
FBarCode.Height := INITHEIGHT;
self.Width := INITWIDTH;
self.Height := INITHEIGHT;
end;
destructor TQRBarCode.Destroy;
begin
FBarCode.Free;
inherited;
end;
………………………………
procedure TQRBarCode.Paint;
var
srcdc, destdc: HDC;
begin
srcdc := GetDc(FBarCode.Handle);
destdc := GetDC(self.Handle);
BitBlt(destdc, 0, 0, FBarCode.Width, FBarCode.Height,
srcdc, 0, 0, SRCCOPY);
ReleaseDC(FBarCode.Handle, srcdc);{ TODO : ole }
ReleaseDC(self.Handle, destdc);
end;
…………………………………………
procedure TQRBarCode.Refresh;
begin
FBarCode.Refresh;
Invalidate();
end;
其中的