这是演示如何更改主菜单项的背景颜色的脚本,而菜单的其余部分仍保持灰色
void __fastcall TForm1::AdvancedDrawNewItemMain(TObject *Sender, TCanvas *ACanvas, const TRect &ARect,
TOwnerDrawState State)
{
TMenuItem *MenuItem = ((TMenuItem*)Sender);
TRect TempRctN = ARect;
TempRectN.top=TempRctN.top+2;
ACanvas->Brush->Color =clRed;
ACanvas->FillRect(ARect);
DrawTextW(ACanvas->Handle,MenuItem->Caption.w_str(),MenuItem->Caption.Length(),&TempRctN, DT_CENTER);
if((State.Contains(odSelected) || State.Contains(odHotLight) ) && !State.Contains(odDisabled) )
{
ACanvas->Brush->Color =static_cast<TColor>RGB(49,106,197);
ACanvas->FillRect(ARect);
ACanvas->Font->Color=clWhite;
DrawTextW(ACanvas->Handle,MenuItem->Caption.w_str(),MenuItem->Caption.Length(),&TempRctN, DT_CENTER);
}
}
有人知道如何更改整个主菜单背景颜色吗?