제가 ActiveX Control을 만드는중에 문제가 발생하여 답을 구하고자 합니
다.
제가 TPanel을 Base Class로 하는 ActiveX Control을 생성하여 그위에 string
grid를 생성 하였습니다. 그리고 string grid의 Double Click Event를 만들려구
했더니 에러가 발생하여 Double Click Event를 생성 할수가 없더군요.
제소스를 좀 보시고 답변좀 부탁 드리겠습니다.
Test는 VB6.0에서 했습니다. String grid를 Double click했을 경우에
Control '' has no Parent Window라는 에러 메세지가 발생 합니다.
type
TShipSchedule = class(TActiveXControl, IShipSchedule)
private
{ Private declarations }
FDelphiControl: TPanel;
FEvents: IShipScheduleEvents;
g_spl : TSplitter;
procedure ClickEvent(Sender: TObject);
procedure DblClickEvent(Sender: TObject);
procedure ResizeEvent(Sender: TObject);
procedure g_SDblClickCell(Sender: TObject; Arow,Acol: Integer);
protected
{ Protected declarations }
procedure InitializeControl; override;
procedure EventSinkChanged(const EventSink: IUnknown); override;
procedure DefinePropertyPages(DefinePropertyPage:
TDefinePropertyPage); override;
function Get_Alignment: TxAlignment; safecall;
function Get_BevelInner: TxPanelBevel; safecall;
function Get_BevelOuter: TxPanelBevel; safecall;
function Get_BevelWidth: Integer; safecall;
function Get_BorderStyle: TxBorderStyle; safecall;
function Get_BorderWidth: Integer; safecall;
function Get_Caption: WideString; safecall;
function Get_Color: TColor; safecall;
function Get_Ctl3D: WordBool; safecall;
function Get_Cursor: Smallint; safecall;
function Get_DragCursor: Smallint; safecall;
published
property OnDbClick: TNotifyEvent read FOnDbClick write FOnDbClick;
end;
var
G_Schedule : tadvstringgrid; //그리드 1
G_stock : tadvstringgrid; // 그리드 2
implementation
{ TShipSchedule }
procedure TShipSchedule.InitializeControl;
begin
FDelphiControl := Control as TPanel;
FDelphiControl.OnClick := ClickEvent;
FDelphiControl.OnDblClick := DblClickEvent;
FDelphiControl.OnResize := ResizeEvent;
FDelphiControl.Ctl3D := FALSE;
//************************************//
//** 그리드 1 **//
//************************************//
G_Stock := tadvstringgrid.Create(nil);
with G_Stock do begin
parent := FDelphiControl;
FixedCols := 0;
Align := alRight;
DefaultRowHeight := 15;
ShowHint := TRUE;
Width := 120;
Cells[0,0] := '재 고';
OnGetCellColor := g_SGetCellColor;
//****************************************************//
//** Grid를 click하면 아래의 이벤트가 발생 하질 않고
//** Control '' has no Parent Window 라는 에러 메세지만 발생을
//** 합니다.
//** 저는 동적으로 생성된 그리드의 Double Click 이벤트를 생성 하구 싶습
니다.
//*****************************************************//
OnDblClickCell := g_SDblClickCell;
ONGetAlignment := g_SGetAlignment;
OnGridHint := g_SGridHint;
end; //with
G_spl := TSplitter.Create(nil);
with G_spl do begin
Align := alRight;
Parent := FDelphiControl;
end; //with
//************************************//
//**그리드 2 **//
//************************************//
G_Schedule := tadvstringgrid.Create(nil);
with G_Schedule do begin
parent := FDelphiControl;
Align := alClient;
FixedCols := 2;
ShowHint := TRUE;
DefaultRowHeight := 15;
Cells[0,0] := '일 자';
Cells[1,0] := '요 일';
OnGetCellColor := g_MGetCellColor;
OnGridHint := g_MGridHint;
end; //with
end;
procedure TShipSchedule.g_SDblClickCell(Sender: TObject; Arow,Acol:
Integer);
begin
Showmessage('Test Double Click');
end;