Exact match. Not showing close matches.
PICList
Thread
'[OT]:Creating Objects at runtime in Delphi 5'
2000\09\26@055630
by
Jamie Dainton
|
Hello PICLIST,
I'm trying to create a TButton object at run time in Delphi 5. The
code generates no errors but nothing happens. Here's the sample code:
unit createObjectsMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
type
TTFormCreateObjects = class(TForm)
StatusBar1: TStatusBar;
procedure FormClick(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure CreateBalls;
private
{ Private declarations }
public
{ Public declarations }
end;
var
TFormCreateObjects: TTFormCreateObjects;
num:integer;
implementation
{$R *.DFM}
{ TTFormCreateObjects }
procedure ttformcreateobjects.CreateBalls;
var
objectThing:TButton; //instance variable of type TButton
begin
objectThing:=TButton.Create(TFormCreateObjects); //use the form as the owner
{I have tried using self and other owners but the manual says to use the form.}
objectThing.left:=Mouse.CursorPos.x;
objectThing.Top:=Mouse.CursorPos.y;
objectThing.height:=25;
objectThing.Width:=125;
objectThing.Caption:='Test Caption';
objectThing.Visible:=true;
//if objectthing.show is called the stack overflows.
end;
procedure TTFormCreateObjects.FormClick(Sender: TObject);
begin
CreateBalls;
end;
procedure TTFormCreateObjects.FormMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
StatusBar1.Panels.Items[0].text:=((inttostr(mouse.cursorpos.x)) + ':' + (inttostr(mouse.cursorpos.y)));
end;
end.
============================END OF CODE==============================
Can anyone help?
-- From Jamie Dainton
Tuesday, September 26, 2000 10:37:50 The Bat!
1.46 Beta/5 Windows 98 4.10 2222
spam_OUTpgpTakeThisOuT
dainton.org.uk?subject=sendKey
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2000\09\26@182119
by
Tony Nixon
Jamie Dainton wrote:
>
> Hello PICLIST,
>
> I'm trying to create a TButton object at run time in Delphi 5. The
> code generates no errors but nothing happens. Here's the sample code:
>
This is Delphi4 code.
procedure TYourForm.Button1Click(Sender: TObject);
var
B : TButton;
begin
B:=TButton.Create(Self); // Create it and set the owner to form);
B.Parent := Self; // Make it visible on the form.
B.SetBounds(0, 0, 10, 10); // Position it
B.OnClick := UserButtonClick;
B.Caption := 'New Button';
end;
procedure TYourForm.UserButtonClick(Sender : TObject);
begin
// user buttons code
end;
--
Best regards
Tony
ICmicro's
http://www.picnpoke.com
.....salesKILLspam
@spam@picnpoke.com
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- Today
- New search...