title: How can I use a different text color for disabled menu items that are owner-drawn?
body: <p>I have this code for colourize a MainMenu in Delphi. It works well with OnDrawItem events, but I need even something and I don’t know how can I make it. I would like that the font of a MainMenu item if the item became disabled (enabled = False) let be clSilver…</p>
  
  <pre><code>procedure TForm1.Nouveau1DrawItem(Sender: TObject; ACanvas: TCanvas;
    ARect: TRect; Selected: Boolean);
  begin
    // déterminer la couleur et la font de la item séléctionnée    
    if Selected  Then
    begin
      // changer la couleur du canevas on lui attribuer la couleur de
      // séléction du style XP
      ACanvas.Brush.Color := $0084E3FF;
      // créer le rectangle qui sera afficher
      MRect.Left := Arect.Left+28;
      MRect.Top := ARect.Top+1;
      MRect.Right := ARect.Right-1;
      MRect.Bottom := ARect.Bottom-1;
      // redéssiner la Item
      ACanvas.FillRect(MRect);
  
      // créer la bordure du réctangle séléctionné
      ACanvas.Brush.Color := clMaroon;    
  
      // affichage du text
  
      // passer en mode affichage trensparent
      setBkMode(ACanvas.Handle, Transparent);
      // définition de la font
      ACanvas.Font.Style := [fsBold];
      ACanvas.Font.Color := $000000C1;
  
      // affichage du text
      DrawMenuText(30, ACanvas, ARect, (sender as TMenuItem).Hint);
  
      // créer la Frame qui presente la bordure de la séléction
      ACanvas.FrameRect(MRect);
    end else
  
    // déterminer la couleur et la font de la item
    begin
      // réctangle du glyph
  
      // 1)- réctangle principal ou sera affiché le text (Captions) des (items)
      ACanvas.Brush.Color := $0060D3F0;
      ACanvas.FillRect(ARect);
  
      begin
        // Réctangle qui représente le canevas du menu (arričre plan)
        ACanvas.Brush.Color := $0060D3F0;
        PRect.Left := ARect.Left + 1;
        PRect.Top := ARect.Top + 1;
        PRect.Right := PRect.Left + 25;
        PRect.Bottom := ARect.Bottom - 1;
  
        ACanvas.FillRect(PRect);
  
        // réctangle qui est comme étant l'arričre du text Caption
        ACanvas.Brush.Color := $00009FCE; // $0060D3F0;
  
        GRect.Left := ARect.Left + 27;
        GRect.Top := ARect.Top;
        GRect.Right := ARect.Right;
        GRect.Bottom := ARect.Bottom;
  
        ACanvas.FillRect(GRect);
  
        SetBKMode(ACanvas.Handle, Transparent);
  
        ACanvas.Font.Color := ClNavy;
  
        if not (Sender as TMenuItem).checked then
          DrawMenuText(30, ACanvas, GRect, (Sender as TMenuItem).Hint)
        else
        begin
          ACanvas.Brush.Color := $000000C1;
          MRect.Left := ARect.Left + 5;
          MRect.Top := ARect.Top + 5;
          MRect.Right := MRect.Left + 20;
          MRect.Bottom := ARect.Bottom - 5;
  
          ACanvas.FillRect(MRect);
  
          ACanvas.Brush.Color := clMaroon;
  
          ACanvas.FrameRect(MRect);
  
          SetBKMode(ACanvas.Handle, Transparent);
  
          // dessin du radioButton
          begin
            // 1)---------
            ACanvas.Pen.Color := $00CCF3FF;
  
            ACanvas.MoveTo(MRect.Left + 3, MRect.Top + 5);
            ACanvas.LineTo(MRect.Left + 5, MRect.Bottom - 3);
  
            // 2)---------
            ACanvas.MoveTo(MRect.Left + 3, MRect.Top + 5);
            ACanvas.LineTo(MRect.Left + 7, MRect.Bottom - 3);
  
            // 3)---------
            ACanvas.MoveTo(MRect.Left + 4, MRect.Bottom - 3);
            ACanvas.LineTo(MRect.Right -3, MRect.Top+2);
  
            // 4)---------
            ACanvas.MoveTo(MRect.Left + 6, MRect.Bottom - 3);
            ACanvas.LineTo(MRect.Right -3, MRect.Top +2);
  
            // 5)---------
          end;
          DrawMenuText(30, ACanvas, GRect, (Sender as TMenuItem).Hint)
        end;
      end;
    end;
  end;
  </code></pre>