Forum > LCL

[CLOSED] Custom PopUpMenu

(1/1)

Pe3s:
How can I fix the code to get rid of this gray frame.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.PopupMenu1DrawItem(Sender: TObject; ACanvas: TCanvas;  ARect: TRect; AState: TOwnerDrawState);var  x, y: Integer;begin  ACanvas.Font.Assign(Screen.MenuFont);   if AState * [odSelected, odFocused] <> [] then begin    ACanvas.Brush.Color := RGBToColor(216, 215, 255);    ACanvas.Pen.Color := RGBToColor(190, 190, 230);    ACanvas.Rectangle(ARect);    //ACanvas.Font.Style := [fsBold];  end  else    ACanvas.GradientFill(ARect, clSkyBlue, clSkyBlue, gdHorizontal);   x := 2;  y := (ARect.Top + ARect.Bottom - ImageList1.Height) div 2;  ImageList1.Draw(ACanvas, x, y, TMenuItem(Sender).ImageIndex, TMenuItem(Sender).Enabled);;   x := x + ImageList1.Width + 4;  ACanvas.Pen.Color := clGray;  ACanvas.Line(x, ARect.Top, x, ARect.Bottom);   x := x + 4;  y := (ARect.Top + ARect.Bottom - ACanvas.TextHeight('Tg')) div 2;  ACanvas.Brush.Style := bsClear;  ACanvas.TextOut(x, y,  TMenuItem(Sender).Caption); end;                                      

jamie:
I am not really sure if you can rid the frame..

It's obvious you are attempting a flat menu and even if you succeed in doing so you still have the shadow.

I have done this before but its not that simply..

what I did was get the top window and then do a screen draw around it to match the color you wish.

in windows you can play with the host window that is being used but this sure won't work across the pond.

I'll look in my old notes for this see if I can find something..

Pe3s:
@Jamie My point was to fill the entire background of the menu with color.  I don't want to remove the shadow. Remove white border

jamie:
Yes, I know exactly what you want and like I said, it will be futile  :(

In any case if you want to play..

use "WindowFromDC(Canvas.Handle)"

That gives you the window the menu is drawing on..

Then use "GetWindowInfo(TheHandleThatwasReuturned, the WIndowINfo record);

In that you can find all the details about the window being used for the menu.

have fun.

Pe3s:
Thank you

Navigation

[0] Message Index

Go to full version