//调整主菜单项尺寸 procedure MeasureMainItem(Sender: TObject; ACanvas: TCanvas; var Width, Height: Integer); begin Width := Width + 6; Height := Height + 2; end; //调整子菜单项尺寸 procedure MeasureSubItem(Sender: TObject; ACanvas: TCanvas; var Width, Height: Integer); begin Width := Width + 20; Height := Height + 2; end; //绘制主菜单内容 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 //鼠标划过 BrushColor := MainMenuHotLightBackColor; PenColor := MainMenuHotLightBorderColor; end |