How to skin custom button

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36176
    tomkrysl
    Participant

    Hi,

    I have a custom button created as descendant of TCustomControl, its name is TMyButton.

    I am handling the various states (normal, disabled, defaulted, pressed) myself.

    I need to add this button to an application which is skinned with Alphacontrols.

    However I have problem that this button is not automatically skinned.

    I need only skinning of the button shape which I render with DrawFrameControl/ThemeServices.DrawElement.

    Do I need to add this button somehow specially to Thirdparty list (I tried but no success)?

    Or do I need to replace DrawFrameControl/ThemeServices.DrawElement with some function from alpha controls?

    I have looked into sBitBtn (have registered version) but it is WAY TOO complicated and I don't understand what's going on there…

    I thought there is some easy function which just draws BUTTON skin part to Canvas…

    I don't need special timing effects for this button.

    Please explain easiest method.

    Thank you

    TK

    #52061
    tomkrysl
    Participant

    I found a solution myself. It can be extracted from the TsBitBtn source.

    It is not so easy as native DrawFrameControl but it is not so difficult as I first thought when looking into the source code.

    A few notes for anybody who might be interested:

    You must be a registered user to have sources.

    Just start with PaintItemBG function which is located in the PrepareCache function.

    This function draws the entire button background into a cache bitmap, which must be then copied to button canvas.

    Initialize the cache bitmap exactly like it is done in the PrepareCache function.

    Furthermore CommonData must be properly initialized (don't forget the AfterConstruction and Loaded methods).

    Finally State parameter signals the button shape.

    It is even quite easy to implement timed fading, just take look at the DoChangePaint function.

    To add this, you need the PrepareCache function and call it in the AC_PREPARECACHE message handler.

    This button might later be part of my KControls package so you might take a look.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.