![]() |
Einzelnes StatusPanel neu zeichnen
Wie kann ich bewirken, dass ein einzelnes Panel einer StatusBar neu gezeichnet wird.
Eine Möglichkeit, die ich sehe ist:
Delphi-Quellcode:
Ich kann mir aber vorstellen, dass es eine simplere Möglichkeit gibt, z.B.
PROCEDURE RepaintPanel(StatusBar:TStatusBar; Index:Integer);
var Rect:TRect; Panel:TStatusPanel; begin Panel:=StatusBar.Panels[Index]; SendGetStructMessage(StatusBar.Handle, SB_GETRECT,Index,Rect); StatusBar.Canvas.Brush.Color:=StatusBar.Color; StatusBar.Canvas.FillRect(Rect); case Panel.Bevel of pbLowered : Frame3D(StatusBar.Canvas,Rect,clGray,clWhite,1); pbRaised : Frame3D(StatusBar.Canvas,Rect,clWhite,clGray,1); end; StatusBar.Canvas.Font:=StatusBar.Font; StatusBar.OnDrawPanel(StatusBar,Panel,Rect); end;
Delphi-Quellcode:
SendMessage(StatusBar.Handle,??,??,??);
|
AW: Einzelnes StatusPanel neu zeichnen
Very interesting question, and i liked it !
From what i see, you have two option either 1) WM_DRAWITEM as it sound strange but many of these are not documented or the documentation is not clear, ![]() But that page doesn't mention Status Bars, with this older version documentation ![]() a detail explain on how to use it, notice that SB_XXX message are not supported on older Windows, but WM_DRAWITEM will work with them all Windows versions. 2) InvalidateRect , This one is my best choice, yet i have no idea if it is still working as intended on latest Windows with Status Bars (as for other (1) it is working and will work forever), InvalidateRect is different, as it schedule the paint of the rectangle instead forcing an immediate draw, meaning it is fast and and the draw will happen on the next WM_PAINT, so you can over-call it with much less performance consequences, as the OS will handle the intersections as it see fit, while next WM_PAINT will do the perfect job. ![]() yet again, you need to understand how fast it in signaling repaint and when it will happen, so it might or might-not fit your need, also InvalidateRect is the best companion for double buffering, to reduce flickering. These what comes to mind as i recall them working, there is other approaches though, but need a recall and tests. |
AW: Einzelnes StatusPanel neu zeichnen
Liste der Anhänge anzeigen (Anzahl: 2)
Thank you Kas Op.
InvalidateRect is not applicable for my purposes because I need the repainting immediately. WM_DrawItem Interesting. However the part with the DRAWITEMSTRUCT sounds a bit complex (for me) (Pic1.jpg). Seems that needs comparable efforts as my Procedure. Just for Info: In my StatusBar I can drag a panel to certain other positions, and I draw the dragged panel with different colors compared to other panels (Pic2.jpg). |
AW: Einzelnes StatusPanel neu zeichnen
Zitat:
My reason here is that you have many parts and combining them all in one draw is the best, and also the timer will ensure the update close to 60hz and will be smooth without affecting the overall performance, and that of course if you are not doing heavy processing/logic when custom draw is invoked. |
AW: Einzelnes StatusPanel neu zeichnen
Again thank you Kas OP.
Works perfectly. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:27 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz