TMainMenu Ownerdraw - How to paint the background? lazarus / 31-LCL ---------------------------------------------------------------------- knuckles · 2017-09-20 00:02 Hi, I noticed TMainMenu allows to ownerdraw so I experiment a little with this like so: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.MainMenu1DrawItem(Sender: TObject; ACanvas: TCanvas;  ARect: TRect; AState: TOwnerDrawState);begin  ACanvas.GradientFill(ARect, clSilver, clWhite, gdVertical);end; Of course there is no code here for checking the state of the items etc I will handle those later, the main thing I would like to know is how to paint the menu background? I can only see a way of painting the menu items not the actual background? And I dont mean the item background, but the menu strip if you like to call it that, eg from 0 position to form clientwidth. This routine is also named DrawItem so I know I cannot paint the background here but equally i see no other place to do this? Any suggestions or is it simply not possible? ---------------------------------------------------------------------- knuckles · 2017-09-20 09:09 To clarify I have included a screenshot, as you can see the gradient only paints where items exist. What I hoped to achieve is paint the whole area highlighted in orange, and then paint the menu items seperately but I see no way of painting the background, just the items only? ---------------------------------------------------------------------- knuckles · 2017-09-21 10:35 So for the sake of it I added a little extra basic code but in the end I think I will abandon this, not only is painting the actual background proving difficult to impossible I also see no obvious way to draw the menu captions back. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.MainMenu1DrawItem(Sender: TObject; ACanvas: TCanvas;  ARect: TRect; AState: TOwnerDrawState);begin  ACanvas.GradientFill(ARect, clSilver, clWhite, gdVertical);   if (odSelected in AState) then  begin    ACanvas.Brush.Color := $00F3DBBC;    ACanvas.Pen.Color := $00EBB983;    ACanvas.Rectangle(ARect);  end;   ACanvas.TextOut(ARect.Left + 3, ARect.Top + 3, 'test');end; So I guess what I need is a 3rd party menu and Toolbar I guess but I don't seem able to find any, something like toolbar97 or SXSkinComponents I think it was called which allowed OfficeXP menu and toolbar themes etc would have been a good test. ---------------------------------------------------------------------- wp · 2017-09-21 12:33 Set the Brush.Style to bsClear to paint transparent text. ---------------------------------------------------------------------- taazz · 2017-09-21 12:53 which control is that? TMainmenu in my installation of lazarus 1.6.4 and 1.4.4 does not have an OnDrawItem event. ---------------------------------------------------------------------- knuckles · 2017-09-21 13:22 Quote from: wp on September 21, 2017, 02:33:08 pmSet the Brush.Style to bsClear to paint transparent text. Yes I know this, this was just quick test ---------------------------------------------------------------------- knuckles · 2017-09-21 13:23 Quote from: taazz on September 21, 2017, 02:53:23 pmwhich control is that? TMainmenu in my installation of lazarus 1.6.4 and 1.4.4 does not have an OnDrawItem event. Ah sorry I should have said this is Lazarus 1.8RC4 the standard TMainMenu component