[MSEide-MSEgui-talk] create component at runtime

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[MSEide-MSEgui-talk] create component at runtime

code dz
Hi Martin
i tried to create a slider at runtime with this code , but nothing appears

procedure tmainfo.onbuttonclick(const sender: TObject);
var sd : tslider;
begin
        sd := tslider.create(tscrollbox1);
        sd.top := 10;
        sd.left := 10;
        sd.width := 100;
        sd.height := 25;
end;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] create component at runtime

mse
Administrator
On 07/26/2018 07:15 PM, code dz wrote:
> Hi Martin
> i tried to create a slider at runtime with this code , but nothing appears
>
> procedure tmainfo.onbuttonclick(const sender: TObject);
> var sd : tslider;
> begin
> sd := tslider.create(tscrollbox1);//<<<---tscollbox1 is the owner not the parentwidget

"
 sd:= tslider.create(self,tscrollbox1,true);
 //or
 // sd:= tslider.createandinit(self,tscrollbox1,true);
 //if the effect should be the same as placing a component from
 //componentpalette in MSEide
"

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] create component at runtime

code dz
In reply to this post by code dz
2018-07-26 18:15 UTC+01:00, code dz <[hidden email]>:

> Hi Martin
> i tried to create a slider at runtime with this code , but nothing appears
>
> procedure tmainfo.onbuttonclick(const sender: TObject);
> var sd : tslider;
> begin
> sd := tslider.create(tscrollbox1);
> sd.top := 10;
> sd.left := 10;
> sd.width := 100;
> sd.height := 25;
> end;
>

seems widget constructor does not assign the parent widget . sorry i
followed the delphi way

this code works

procedure tmainfo.on_create(const sender: TObject);
var
        bt : tSlider;
begin
        bt := tSlider.create(nil);
        bt.bounds_x := 10;
        bt.bounds_y := 10;
        bt.bounds_cx := 80;
        bt.bounds_cy:= 20;
        bt.parentwidget := self; <----
end;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] create component at runtime

code dz
In reply to this post by mse
2018-07-26 20:25 UTC+01:00, Martin Schreiber <[hidden email]>:

> On 07/26/2018 07:15 PM, code dz wrote:
>> Hi Martin
>> i tried to create a slider at runtime with this code , but nothing
>> appears
>>
>> procedure tmainfo.onbuttonclick(const sender: TObject);
>> var sd : tslider;
>> begin
>> sd := tslider.create(tscrollbox1);//<<<---tscollbox1 is the owner not the
>> parentwidget
>
> "
>  sd:= tslider.create(self,tscrollbox1,true);
>  //or
>  // sd:= tslider.createandinit(self,tscrollbox1,true);
>  //if the effect should be the same as placing a component from
>  //componentpalette in MSEide
> "
>
> Martin
>

aha , thanks

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk