Implement the flat style of statusbar

Source: Internet
Author: User
See the picture on the right. officexp is like this. In fact, the implementation is very simple. You don't have to look for other controls on the Internet.
Set simplepanel of statusbar to false, click panels to add statuspanel, set bevel of all statusanel to pbnone, and style to psownerdraw because we need to draw the flat style by ourselves. The ondrawpanel Event code of stutasbar is as follows:

ProcedureTform1.statusbar1drawpanel (statusbar: tstatusbar;
Panel: tstatuspanel;ConstRect: trect );
VaR
Ualign: uint;
R: trect;
Begin
CasePanel. AlignmentOf
Taleftjustify:Ualign: = dt_left;
Tacenter:Ualign: = dt_center;
Tarightjustify:Ualign: = dt_right;
End;
Ualign: = ualignOrDt_vcenter;
WithStatusbar. CanvasDo Begin
Pen. Color: = $ e1e1e1;
Brush. Color: = statusbar. color;
Rectangle (rect );
Brush. Style: = bsclear;
R. Left: = rect. Left + 1;
R. Right: = rect. Right-1;
R. Top: = rect. Top + 1;
R. Bottom: = rect. Bottom-1;
Drawtext (statusbar. Canvas. Handle, pchar (panel. Text),-1, R, ualign );
End;
End;

In the interface on the right, the first statusanel should be automatically adjusted, so the statusbar. onresize event must be processed. The Code is as follows:
ProcedureTform1.statusbar1resize (Sender: tobject );
VaR
I, W:Integer;
Begin
W: = statusbar1.width;
ForI: = 1ToStatusbar1.panels. Count-1Do
W: = W-statusbar1.panels [I]. width;
Statusbar1.panels [0]. Width: = W;
End;

The effect is good.

// Article from: workshop!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.