[lazarus] Q: CreateWnd, CreateHandle, HandleNeeded: which to override

Marc Weustink weus at quicknet.nl
Sun Dec 26 17:56:39 EST 1999


At 10:33 26-12-99 +0100, you wrote:
>Hi,
>
>I just started to update TTrackbar & TProgressbar to the new interface

Great

>but I'm not sure how to do things.
>Currently both crash whenever the first action takes place which needs the
>instantiated object, which has not been created at that time. Since I don't
>know the new functions in detail I'd like to know:

>- which of the above methots have to be overriden?

None!

You only need to override InitializeWnd and/or AttachSignals. The control
is created based upon FCompStyle (however in the future it might be based
upon CreateParams (and API))

AttachSignals: Here you place your calls to SetCallBack for all events not
yet defined by TWinControl. (In most cases only some specific events for
your control) Allways call inherited.

InitializeWnd: (Shouldn't be used it but I'll describe the initial idea)
The control caches values as long as no visual component is needed. For
instance to set the value of a trackbar, you dont need the visual part. The
code in InitializeWnd gets called after the component is created. Here you
can code to initialize to newly created component. On second toughts this
routine shouldn't be needed. The routine (your create routine in gtkobject)
which creates the visual part should take care of this.

>- Is it neccessary to call HandleNeeded in every method which requires
>  the object instance?

Yes, but I think in most cases you only need it for the visual property
(and thats handled in TWinControl). For properties like height width value
and thinks like tat you don't need the visual part (and no call to
handleneeded)

>- What about BeginUpdate / EndUpdate methods?

????

I hope this clears most of your questions, if still unclear you can allways
ask.

Marc









More information about the Lazarus mailing list