Self-painted XP style menu

xiaoxiao2021-03-06  97

This is the previously written code, the self-painted XP style menu, the hard disk is broken, I don't have it, the last written software should be customized to customize the style, "Full box-inverted" finally found it on my lovely antique machine ^ _ ^ found a Application example. Blog or put it up, but also as a backup to share the OnMeasureItem :) main menu point MeasureMainItem, OnAdvancedDrawItem point DrawMainItem, OnMeasureItem submenu point MeasureSubItem, OnAdvancedDrawItem point DrawSubItem, or adjust the color effect can be achieved using the default color {================================================================================================================================================================================================================ ============================= Design By: Peng Guohui Site: http://kacarton.yeah.net/ blog: http://blog.9cbs.net/ NHCONCH Email: kacarton@sohu.com

The article is the author original. Please contact him before reprinting, reprint, please indicate the article, retain the author information, thank you for your support! ============================================================================================================================================================================================================= =======================}

// Adjust the main menu Size Procedure MeasureMainItem (Sender: Tobject; Acanvas: Tcanvas; Var Width, Height: Integer); Begin Width: = Width 6; Height: = HEIGHT 2; END;

// Adjust the submenu item size Procedure MeasureSuBItem (Sender: Tobject; Acanvas: Tcanvas; Var Width, Height: Integer); Begin Width: = Width 20; Height: = HEIGHT 2; END;

// Draw main menu contents procedure DrawMainItem (Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState); const MainMenuBackColor: TColor = $ DEEDEF; MainMenuBorderColor: TColor = $ DEEDEF; MainMenuSelectedBackColor: TColor = $ DFA988; MainMenuSelectedBorderColor: TColor = $ C08000; MainMenuHotLightBackColor: TColor = $ DEEDEF; MainMenuHotLightBorderColor: TColor = $ 800080; MainMenuGrayedBackColor: TColor = $ DEEDEF; var BrushColor, PenColor: TColor; textRect: TRECT; begin if odGrayed in State then begin BrushColor: = MainMenuGrayedBackColor; PenColor: = MainMenuGrayedBackColor; end else if odHotLight in State then begin // the mouse across BrushColor: = MainMenuHotLightBackColor; PenColor: = MainMenuHotLightBorderColor; end else if odSelected in State then begin BrushColor: = MainMenuSelectedBackColor; PenColor: = MainMenuSelectedBorderColor; end else begin BrushColor: = MainMenuBackColor; Pencolor: = MainMenuBack Color; if tmenuitem (sender) .caption = 'Help (& H)' Ten allT.right: = all; an; acuS.brush.color: = brushcolor; acanvas.pen.color: = pencolor; // Acanvas.FillRect (all); acanvas.rectangle (all); acanvas.brush.style: = bsclear; // Painted text if ing odgrayed in state kilnvas.font.color: = CLBTNSHADOW Else Acanvas.font.color: = CLBLACK SETRECT (TextRect, Arect.Left 10, Arect.top 3, Arect.right, all, distribution (TMENUITEM (Sender), Length (TMenuItem (Sender) .caption ), TextRect, DT_LEFT; END;

// Draw the sub-menu content procedure DrawSubItem (Sender: TObject; ACanvas: TCanvas; ARect: TRect; State: TOwnerDrawState); const SubMenuBackColor: TColor = $ F7F8F9; SubMenuBorderColor: TColor = $ DEEDEF; SubMenuSelectedBackColor: TColor = $ EED2C1; SubMenuSelectedBorderColor: TColor = $ C08000; SubMenuLineColor: TColor = $ C8D0D4; // SubMenuHotLightBorderColor: TColor = $ C08000; SubMenuGrayedBackColor: TColor = $ F7F8F9; // $ DEEDEF; var BrushColor, PenColor: TColor; textRect: TRECT; str: String; ImageList: TCustomImageList; begin if (odGrayed in State) and not (TMenuItem (Sender) .IsLine) then begin BrushColor: = SubMenuGrayedBackColor; {if odSelected in State then PenColor: = SubMenuSelectedBorderColor else} PenColor: = SubMenuGrayedBackColor; end else if odSelected in State then BEGIN brushcolor: = SubmenuselectedBackColor; Pencolor: = SubmenuselectedBorderColor; Else Begin Brushcolor: = SubMenuBackColor; Pencolor: = Submen Ubackcolor; end; acanvas.brush.color: = brushcolor; acanvas.pen.color: = pencolor; acanvas.Rectangle (all); if not (odselected in state) or (ODGRAYED in State) The begin acuSh.color: = SubmenuborderColor; Acanvas.FillRect (Rect (all, all, all 20, all, all; // Painting and shortcuts if tmenuitem (sender) .isline dam acanvas.brush .Color: = submenulineColor; acanvas.pen.color: = SubmenulineColor; acanvas.fillRect (Rect (all, all, all, all, all, all, all, all, all, far, Arect.top (all); end else begin acanvas.brush.style: = bsclear;

转载请注明原文地址:https://www.9cbs.com/read-123848.html

New Post(0)