That one I can help with:

MyGBx.Parent := Self;

should do it

rossiaurelio wrote:

>--- In [email protected], "Walter  Prins" <[EMAIL PROTECTED]> wrote:
>  
>
>>----- Original Message ----- 
>>From: "Dave Sellers" <[EMAIL PROTECTED]>
>>To: <[email protected]>
>>Sent: Monday, May 02, 2005 11:19 AM
>>Subject: [list] Re: [delphi-en] Creating/adding GroupBox at runtime
>>
>>
>>    
>>
>>>You'll need to manually assign event handlers to relevant events:
>>>
>>>GBx.OnMouseDown := MyMouseDownEventHandler;
>>>      
>>>
>>Actually in this case that's probably not what you want/should do,
>>    
>>
>as the 
>  
>
>>question example given declares a descendant from TGroupbox,  and
>>    
>>
>thus, one 
>  
>
>>should really be overriding the appropriate method (and not be
>>    
>>
>assigning to 
>  
>
>>event handler properties.)   In the example code the Reintroduce
>>    
>>
>keyword is 
>  
>
>>used (and there's no override keyword in sight) - this is the key
>>    
>>
>problem. 
>  
>
>>The code should not use reintroduce and should use override.
>>
>>Simple working example code would be (create a new project and replace 
>>unit1.pas's source with this):
>>
>>unit Unit1;
>>
>>interface
>>
>>uses
>>  Windows, Messages, SysUtils, Variants, Classes, Graphics,
>>    
>>
>Controls, Forms,
>  
>
>>  Dialogs, StdCtrls;
>>
>>type
>>  TGbx = class(TGroupBox)
>>  protected
>>    { This method was identified by looking at StdCtrls.pas and 
>>Controls.pas, tracing up the TGroupbox inehritance hierarchy to see
>>    
>>
>which 
>  
>
>>method to override }
>>    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: 
>>Integer); override;
>>  end;
>>  TForm1 = class(TForm)
>>    procedure FormCreate(Sender: TObject);
>>  private
>>    { Private declarations }
>>    FGbx : TGBx;
>>  public
>>    { Public declarations }
>>  end;
>>
>>var
>>  Form1: TForm1;
>>
>>implementation
>>
>>{$R *.dfm}
>>
>>{ TGbx }
>>
>>procedure TGbx.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
>>  Y: Integer);
>>begin
>>  { call inherited MouseDown method, that checks for assigned
>>    
>>
>"OnMouseDown" 
>  
>
>>and fires if needed.}
>>  inherited;
>>
>>  { now add our own mousedown behaviour }
>>  ShowMessage('boo');
>>
>>  { you can of course change this whichever way you want (not call
>>    
>>
>inherited 
>  
>
>>for example, only call it sometimes etc etc) }
>>end;
>>
>>procedure TForm1.FormCreate(Sender: TObject);
>>begin
>>  FGbx := TGbx.Create(self);
>>  FGbx.Parent := self;
>>end;
>>
>>end.
>>
>>
>>
>>Regards
>>
>>Walter
>>    
>>
>
>Ok, thanks you people for the reply ... i've tried this code, adding
>some code and a button to create the groupbox at runtime :
>
>var
>...
>MyGBx : TGbx;
>
>procedure TForm1.Button1Click(Sender: TObject);
>begin
>  MyGBx := TGbx.Create(Form1);
>  MyGBx.Caption := 'My GroupBox';
>  MyGBx.Visible := True;
>  MyGBx.Show;
>  MyGBx.top := 100;
>  MyGBx.left := 100;
>end;
>
>... but i dont see any groupbox on the form ... aaahhhh ... where i go
>wrong ?
>
>
>
>
>
>
>
>-----------------------------------------------------
>Home page: http://groups.yahoo.com/group/delphi-en/
>To unsubscribe: [EMAIL PROTECTED] 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>
>  
>



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to