Modify Xpmenu to let Toolbutton display correctly at Down=true

Source: Internet
Author: User

Xpmenu is a good program interface effect control, but it also has a lot of shortcomings. I recently made a little change to it.
The reason is that I have a toolbutton in the program, its Style=tbsbutton, when down=true, xpmenu the effect of drawing the same as the down=false, that is to say that it is not at all pressed. When the style is changed to Tbscheck, but it can show the effect, but the background is very deep.
This button comes to me to indicate whether a panel can be displayed, and I want it to be like a officexp tool button, and when the toolbar is displayed, draw a border on the button instead of a deep background.
The Xpmenu Drawing toolbar button is done by the Txpmenu.toolbardrawbutton function, and the prototype is as follows:

procedure  Txpmenu.toolbardrawbutton (Sender:ttoolbar; Button:ttoolbutton; State:tcustomdrawstate; var Defaultdraw:boolean);
within the function, the following code determines whether the button displays a border, and what color to use for the background:
if (Cdshot in State) Then
begin
if (cdschecked in state) or (Button.down) or (cdsselected in State) Then
ACanvas.Brush.Color: = Fcheckedareaselectcolor
Else
ACanvas.brush.color: = Fbselectcolor;
Hasborder: = true;
HASBKG: = true;
end;

if ((cdschecked in state) and not (Cdshot in)) Then
begin
ACanvas.Brush.Color: = Fcheckedareacolor;
Hasborder: = true;
HASBKG: = true;
End;

if (Cdsindeterminate in State)  and  not (Cdshot in state) Then
begin
ACanvas.Brush.Color: = Fbselectcolor;
HASBKG: = true;
End;

It ignores the handling of cdshot, non-cdschecked-state button down=true cases. So just add the corresponding judgment, and let hasborder=true can achieve the effect I want. The modified code is as follows:
if (cdshot) then
Begin
if (cdschecked in state) or (Button.down) or (cdsselected.) Then
ACanvas.Brush.Color: = Fcheckedareaselectcolor
Else
ACanvas.brush.color: = Fbselectcolor;
Hasborder: = true;
HASBKG: = true;
End;

if (cdschecked in state) and not (Cdshot in state) then
Begin
ACanvas.Brush.Color: = Fcheckedareacolor;
Hasborder: = true;
HASBKG: = true;
End

{Modify:conch 2005-3-10 draw a border on the Down=true button}
if (button.down) and not (Cdshot .) then
begin
Hasborder: = true;
HASBKG: = false;
End;
Conch

if (cdsindeterminate in state) and not (Cdshot in state) then
Begin
ACanvas.Brush.Color: = Fbselectcolor;
HASBKG: = true;
End

http://blog.csdn.net/nhconch/article/details/317429

Modify Xpmenu to let Toolbutton display correctly at Down=true

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.