My friend inform me how to set TDateTimePicker font properties. Not in Create constructor but in CreateWindowHandle procedure. something came to my mind, I tried to add DateTimePicker1.Parent := Self;
and it works... TDateTimePicker always be painted in TTabSheet as i want..... SOLVED... On 8/7/10, Niksen Harjanto <[email protected]> wrote: > Owh.... > sorry for my bad english... what I mean was, I create my own component > derived from TWinCOntrol, and inside that TWinControl I added > TDateTimePicker (that's why I set TDateTimePicker Parent to Self). > Last night I recognized that the TDateTimePicker always be painted > behind TTabSheet. When I moved the TPageControl, I saw that > TDateTimePicker behind TPageControl (painted on TForm). > > > > unit dtp; > > interface > > uses > SysUtils, Classes, Controls, StdCtrls, ExtCtrls, ComCtrls, MConnect, > UnitEncryption, Dialogs, > Unit_MessageDialog, Messages, Types, Graphics, Windows; > > type > Tdtp = class(TWinControl) > private > { Private declarations } > DateTimePicker1 : TDateTimePicker; > > ... > ... > protected > { Protected declarations } > ... > ... > public > { Public declarations } > Constructor Create(AOwner : TComponent); OverRide; > Destructor Destroy; OverRide; > ... > ... > published > { Published declarations } > ... > ... > end; > > Const > Hijau = $00C4FFC7; > Merah = $00D5D5FF; > > procedure Register; > > implementation > > Constructor Tdtp.Create(AOwner: TComponent); > Begin > Inherited Create(AOwner); > OnResize := OnComponentResize; > Height := 23; > Width := 121; > boolEnabled := True; > > ... > ... > ... > ... > DateTimePicker1 := TDateTimePicker.Create(Self); > DateTimePicker1.Parent := Self; > DateTimePicker1.Left := 0; > DateTimePicker1.Top := 0; > DateTimePicker1.Align := alClient; > Try > DateTimePicker1.Font.Name := 'Verdana'; > Except > End; > DateTimePicker1.Visible := True; > DateTimePicker1.TabStop := True; > > DateTimePicker1.OnEnter := onDTPEnter; > DateTimePicker1.OnExit := onDTPExit; > OnComponentResize(Self); > ... > ... > ... > ... > Try > DateTimePicker1.Font.Size := 9; > Except > End; > End; > > Destructor Tdtp.Destroy; > Begin > Inherited Destroy; > End; > > ... > ... > ... > ... > ... > ... > procedure Register; > begin > RegisterComponents('NOSTOC', [Tdtp]); > end; > > end. > > On 8/6/10, Robert Jenkins <[email protected]> wrote: >> I think you need to set DateTimePicker1.Parent := [Your TWinControl] >> Not to self. >> >> Also, I think it works better to set the parent property last to avoid >> redrawing the DateTimePicker1 after each property gets set/updated. >> >> Robert >> >> On Fri, Aug 6, 2010 at 8:52 AM, David Smith <[email protected]> >> wrote: >> >>> >>> >>> Also, your specifying the owner as a Tcomponent class, then referencing >>> Self as the owner of the instance of the constructor. Self refers to the >>> form which is why it's disappearing. You've got to reference the >>> TWinControl >>> which you chould create a variable for and reference that. >>> >>> Dave >>> >>> --- On Fri, 8/6/10, Niksen Harjanto >>> <[email protected]<niksenh%40gmail.com>> >>> wrote: >>> >>> From: Niksen Harjanto <[email protected] <niksenh%40gmail.com>> >>> Subject: [delphi-en] WTA - TDateTimePicker inside TWinControl is >>> invisible >>> To: "delphi-en" <[email protected] >>> <delphi-en%40yahoogroups.com>> >>> Date: Friday, August 6, 2010, 1:32 AM >>> >>> >>> >>> Dear all... >>> >>> I have created my own custom component. >>> >>> It used TWinControl as it's "canvas" and a TDateTimePicker on top of it. >>> >>> When I dropped onto a TForm, everything was ok. >>> >>> But if I dropped it onto the TTabSheet (tab in TPageControl), the >>> >>> TDateTimePicker will visible ONLY WHEN I dropped it. >>> >>> If I close the application and then re-open it again, the >>> >>> TDateTimePicker will invisible. >>> >>> Is this a bug or I made some mistake? >>> >>> this is my script >>> >>> Constructor Tdtp.Create(AOwner: TComponent); >>> >>> Begin >>> >>> Inherited Create(AOwner); >>> >>> OnResize := OnComponentResize; >>> >>> Height := 23; >>> >>> Width := 121; >>> >>> boolEnabled := True; >>> >>> DateTimePicker1 := TDateTimePicker.Create(Self); >>> >>> DateTimePicker1.Parent := Self; >>> >>> DateTimePicker1.Left := 0; >>> >>> DateTimePicker1.Top := 0; >>> >>> DateTimePicker1.Align := alClient; >>> >>> // DateTimePicker1.Font.Name := 'Verdana'; // Error !!! >>> >>> // DateTimePicker1.Font.Size := 9; // Error !!! >>> >>> Try >>> >>> DateTimePicker1.Font.Name := 'Verdana'; // I made trick in here, >>> >>> and it works >>> >>> Except >>> >>> End; >>> >>> DateTimePicker1.Visible := True; >>> >>> DateTimePicker1.TabStop := True; >>> >>> DateTimePicker1.OnEnter := onDTPEnter; >>> >>> DateTimePicker1.OnExit := onDTPExit; >>> >>> OnComponentResize(Self); >>> >>> DateTimePicker1.OnChange := EventChange; >>> >>> DateTimePicker1.OnClick := EventClick; >>> >>> DateTimePicker1.OnCloseUp := EventCloseUp; >>> >>> DateTimePicker1.OnContextPopup := EventContextPopup; >>> >>> DateTimePicker1.OnDblClick := EventDblClick; >>> >>> DateTimePicker1.OnDragDrop := EventDragDrop; >>> >>> DateTimePicker1.OnDragOver := EventDragOver; >>> >>> DateTimePicker1.OnDropDown := EventDropDown; >>> >>> DateTimePicker1.OnEndDock := EventEndDock; >>> >>> DateTimePicker1.OnEndDrag := EventEndDrag; >>> >>> DateTimePicker1.OnKeyDown := EventKeyDown; >>> >>> DateTimePicker1.OnKeyPress := EventKeyPress; >>> >>> DateTimePicker1.OnKeyUp := EventKeyUp; >>> >>> DateTimePicker1.OnStartDock := EventStartDock; >>> >>> DateTimePicker1.OnStartDrag := EventStartDrag; >>> >>> DateTimePicker1.OnUserInput := EventUserInput; >>> >>> Try >>> >>> DateTimePicker1.Font.Size := 9; // I made trick in here, and it works >>> >>> Except >>> >>> End; >>> >>> End; >>> >>> Thank You..... >>> >>> -- >>> >>> "Sabbe Satta Bhavantu Sukhitatta - Semoga Semua Makhluk Hidup >>> Berbahagia" >>> >>> Se Hai Ce Nei, Kai Siung Ti Ye - Di Empat Penjuru Lautan, Kita Semua >>> Bersaudara >>> >>> Ko Ko Cay Siang - Yang Tinggi Masih Ada Pula Yang Melebihi Oleh Karena >>> >>> Itu Jangan Takabur, Jumawa, dan Terlalu Berbangga Diri >>> >>> Niksen - Pulsarian Bandung 782 >>> >>> members of KORMOT COMMUNITY KC #008 >>> >>> D 5470 WQ >>> >>> [Non-text portions of this message have been removed] >>> >>> >>> >> >> >> [Non-text portions of this message have been removed] >> >> >> >> ------------------------------------ >> >> ----------------------------------------------------- >> Home page: http://groups.yahoo.com/group/delphi-en/ >> To unsubscribe: [email protected]! Groups Links >> >> >> >> > > > -- > "Sabbe Satta Bhavantu Sukhitatta - Semoga Semua Makhluk Hidup Berbahagia" > > Se Hai Ce Nei, Kai Siung Ti Ye - Di Empat Penjuru Lautan, Kita Semua > Bersaudara > > Ko Ko Cay Siang - Yang Tinggi Masih Ada Pula Yang Melebihi Oleh Karena > Itu Jangan Takabur, Jumawa, dan Terlalu Berbangga Diri > > Niksen - Pulsarian Bandung 782 > members of KORMOT COMMUNITY KC #008 > D 5470 WQ > -- "Sabbe Satta Bhavantu Sukhitatta - Semoga Semua Makhluk Hidup Berbahagia" Se Hai Ce Nei, Kai Siung Ti Ye - Di Empat Penjuru Lautan, Kita Semua Bersaudara Ko Ko Cay Siang - Yang Tinggi Masih Ada Pula Yang Melebihi Oleh Karena Itu Jangan Takabur, Jumawa, dan Terlalu Berbangga Diri Niksen - Pulsarian Bandung 782 members of KORMOT COMMUNITY KC #008 D 5470 WQ

