I would really like to see the TsPaintBox…

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #70157
    UniSoft
    Participant

    I would really like to see the TsPaintBox control (this is really really missing).
    But unlike the standard TPaintBox, that it inherits from TCustomControl.
    Support AlphaControls and draws (optionally) the Background, draws the Border/Frame,
    sets the Font and its color, in accordance with the selected skin and SkinSection, etc.
    and only then calls OnPaint.

    #70160
    Stephane Senecal
    Participant

    TsPanel has an OnPaint event. You might wan’t to try that.

    Stephane Senecal
    CIS Group
    Delphi programmer since 2001

    #70166
    Support
    Keymaster

    Hello, Unisoft!
    What you think about the TsPanel component and his OnPaint event?
    This solution helps?

    #70193
    UniSoft
    Participant

    yes, TsPanel can be used…
    but better if it will be another class.
    I already made component myself (demo exe included),
    take a look, maybe you can add it?

    Attachments:
    You must be logged in to view attached files.
    #70196
    Support
    Keymaster

    Thank you. This control is inherited from TCustomPanel and have duplicated a code of the TsPanel control.
    Maybe we can just inherit TsPaintBox from the TsPanel?

    #70200
    Stephane Senecal
    Participant

    My two cents here (i’m not affiliated with AlphaSkins).
    Your control seems to be way more complicated than a TPaintBox. And since your demo is based on a TsPanel, I don’t understand what benefit a TsPaintBox could bring you.

    Stephane Senecal
    CIS Group
    Delphi programmer since 2001

    #70201
    UniSoft
    Participant

    Maybe we can just inherit TsPaintBox from the TsPanel?

    Initially I inherit it from TCustomControl.
    But when I write the code to draw the background
    I found that the code will be too version dependent (latest uses styles etc..)
    (while you keep compatibility with old versions of delphi).
    Why I don’t inherit it from TsPanel?
    Actually TsPanel is a container and therefore contains a lot of code to support/draw/update/repaint child controls,
    what will slow down. Need to remove all code related to child controls.
    I would also like to add frame highlighting (Glow?) on mouse hover, like on TsEdit.

    Your control seems to be way more complicated than a TPaintBox.

    So that is the main Idea!
    If need a simple there is standard TPaintBox,
    if need advanced functionality use TsPaintBox (or what ever else, the name can be changed TsAdvPaintBox, TsDrawBox, …).

    And since your demo is based on a TsPanel, I don’t understand what benefit a TsPaintBox could bring you.

    TsPanel is a container…
    just advanced PaintBox, which can be used as a base to draw whatever you want, if you can’t find ready component.
    Example, see screenshot…
    I didn’t found ready controls as I want, so I draw it myself on TPaintBox,
    cause I have few TPaintBox and all of them have the same features,
    I subclass the class… (or how is it calling right?) (Sorry, I can be incorrect in terminology)
    BTW: That is why it is not good if it will be TsPanel,
    no need that added functionality affects all TsPanel(s) on the form.

    type
      TPaintBox = class(Vcl.ExtCtrls.TPaintBox)
        // ...
      end;
    
      TMainForm = class(TForm)
        ...
        pboxOutVoltage: TPaintBox;
        pboxOutCurrent: TPaintBox;
        pboxOutCurrent: TPaintBox;
        ...
      end;

    Now why TPaintBox is shit…
    1. It does’t have a window,
    2. extra flickering if place it on Panel/GroupBox/TabSheet/etc (when skinning disabled, even if AC not used at all), and to redraw need to call direct Paint(), but it cause some another crazy problems
    (for example it can randomly disappear suddenly, just empty space…
    Only DoubleBuffered=False helps to solve it, but it starts super extra flickering)
    3. Cause I have some animation, repeat, delay I need a 4 timers, so what to do? create 4 TTimers?
    Instead of 4 TTimer(s) I use FWindowHandle := AllocateHWnd(TimerWndProc);
    And can use SetTimer/KillTimer
    4. It doesn’t get mouse wheel messages, key press, etc…
    5. Not fill background according to the selected skin
    6. etc

    Attachments:
    You must be logged in to view attached files.
    #70203
    Stephane Senecal
    Participant

    Now why TPaintBox is shit…
    1. It does’t have a window,
    4. It doesn’t get mouse wheel messages, key press, etc…

    Those are features that comes with a TWinControl based controls like the TPanel.
    What makes the TPaintBox so light is that it doesn’t have a window handle. It uses its parent control window handle, but with the concequences of not being able to have focus and receive any window messages.

    Actually TsPanel is a container and therefore contains a lot of code to support/draw/update/repaint child controls,
    what will slow down. Need to remove all code related to child controls.

    I might be wrong, but I think that if there’s no child controls, it should not impact performance in any meaningful way.

    I subclass the class… (or how is it calling right?)

    You were looking for deriving a class.

    In my humble opinion, I think it could be a good idea to have a TsPaintBox optimized to combine the application’s drawing with AlphaSkins’ painting in a non flickering maner.
    I’m just afraid that it might not be what you are looking for.

    Stephane Senecal
    CIS Group
    Delphi programmer since 2001

    #70204
    UniSoft
    Participant

    In my humble opinion, I think it could be a good idea to have a TsPaintBox optimized to combine the application’s drawing with AlphaSkins’ painting in a non flickering maner.

    Container (example TPanel) draws its background and then draws child controls (TPaintBox)
    region of all windowed child controls excluded, and therefore there is no flicker,
    but not TPaintBox! if exclude it’s region as well then you will have to draw background yourself,
    but TPaintBox doesn’t have any drawing and therefore it is just transparent (if you don’t draw anything)
    cause parent already take care of draw background.
    That is the reason of flickering (it is a pause between draw parent background and draw PaintBox content).
    You can’t easy avoid it.
    So it is not the problem of AlphaControls.
    With AlphaControls (active and skinned) there will not be any flicker, cause all drawing done
    in shadow buffer (FCommonData.FCacheBmp).
    So if to inherit it from TGraphicControl then there are nothing to change…
    If inherit it from TWinControl then you will get almost the same what I did
    (I just add some common function, like the draw caption and Marquee rect)

    • This reply was modified 3 years, 4 months ago by UniSoft.
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.