title: TMenuItem ownerdrawing when calling PopUp
body: <p>I have a question regarding TPopoupMenu and OwnerDraw. I am trying to do some custom drawing and I set OwnerDraw to true and assigned event handler OnDrawItem. I programatically call MyPopup.Popup(X, Y) but OnDrawItem never gets called. What am I doing wrong here? </p>
  
  <p>Thanks for your help.</p>
  
  <p>EDIT:</p>
  
  <p>My further discoveries showed out that there is some issue when using VCL styles. I assigned OnDrawItem and OnMeasureItem. Now those handlers are called. The regular way of implementing OnDrawItem is not working so I tried with using VCL styles but my popup menu does not show any text. </p>
  
  <p>My event handler code (OnDrawItem):</p>
  
  <pre><code>procedure TMyDisplay.EngineMenuDraw(Sender: TObject; ACanvas: TCanvas; ARect: TRect; Selected: Boolean);
  var LStyles: TCustomStyleServices;
      Text: string;
  const
    ColorStates: array[Boolean] of TStyleColor = (scComboBoxDisabled, scComboBox);
    FontColorStates: array[Boolean] of TStyleFont = (sfPopupMenuItemTextDisabled, sfPopupMenuItemTextNormal);
  
  
  begin
  
   LStyles := StyleServices;
  
   Text := (Sender as TMenuItem).Caption;
  
   ACanvas.Brush.Color := LStyles.GetStyleColor(ColorStates[(Sender as TMenuItem).Enabled]);
   ACanvas.Font.Color  := LStyles.GetStyleFontColor(FontColorStates[(Sender as TMenuItem).Enabled]);
  
   if Selected then
   begin
     ACanvas.Brush.Color := LStyles.GetSystemColor(clHighlight);
     ACanvas.Font.Color  := LStyles.GetSystemColor(clHighlightText);
   end;
  
   ACanvas.FillRect(ARect);
   ACanvas.TextOut(ARect.Left + 2, ARect.Top, Text);
  
  end;
  </code></pre>