Searching \ for '[OT]:Creating Objects at runtime in Delphi 5' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=creating+objects
Search entire site for: 'Creating Objects at runtime in Delphi 5'.

Exact match. Not showing close matches.
PICList Thread
'[OT]:Creating Objects at runtime in Delphi 5'
2000\09\26@055630 by Jamie Dainton

flavicon
face
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_OUTpgpTakeThisOuTspamdainton.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

flavicon
picon face
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
.....salesKILLspamspam@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...