K
killjava
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
TPopupcontrol = class(TCustomcontrol)
private
protected
procedure Paint; override;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
end;
procedure TPopupcontrol.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do begin
ExStyle := WS_EX_TOOLWINDOW or WS_EX_CONTROLPARENT;
AddBiDiModeExStyle(ExStyle);
WindowClass.style := CS_SAVEBITS;
end;
end;
procedure TPopupcontrol.CreateWnd;
begin
inherited CreateWnd;
Windows.SetParent(Handle, 0);
CallWindowProc(DefWndProc, Handle, wm_SetFocus, 0, 0);
end;
procedure TPopupcontrol.Paint;
begin
Canvas.Brush.Color := clRed;
Canvas.FillRect(Canvas.ClipRect);
end;
var
c : TPopupcontrol;
procedure TForm1.Button3Click(Sender: TObject);
begin
Showmessage('ccc');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
c := TPopupcontrol.Create(Self);
c.Parent := Self;
c.SetBounds(10, 10, 100, 100);
Button3.Parent := c;
Button3.SetBounds(20, 20, 50, 20);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
c.Free;
end;
end.
如何让 Button3 有反应?要能控制 Form1。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
TPopupcontrol = class(TCustomcontrol)
private
protected
procedure Paint; override;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
end;
procedure TPopupcontrol.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do begin
ExStyle := WS_EX_TOOLWINDOW or WS_EX_CONTROLPARENT;
AddBiDiModeExStyle(ExStyle);
WindowClass.style := CS_SAVEBITS;
end;
end;
procedure TPopupcontrol.CreateWnd;
begin
inherited CreateWnd;
Windows.SetParent(Handle, 0);
CallWindowProc(DefWndProc, Handle, wm_SetFocus, 0, 0);
end;
procedure TPopupcontrol.Paint;
begin
Canvas.Brush.Color := clRed;
Canvas.FillRect(Canvas.ClipRect);
end;
var
c : TPopupcontrol;
procedure TForm1.Button3Click(Sender: TObject);
begin
Showmessage('ccc');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
c := TPopupcontrol.Create(Self);
c.Parent := Self;
c.SetBounds(10, 10, 100, 100);
Button3.Parent := c;
Button3.SetBounds(20, 20, 50, 20);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
c.Free;
end;
end.
如何让 Button3 有反应?要能控制 Form1。