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