Recent

Author Topic: Custom TPopUp Enhancement.  (Read 379 times)

Josh

  • Hero Member
  • *****
  • Posts: 1424
Custom TPopUp Enhancement.
« on: October 07, 2025, 04:12:21 pm »
I had to customize the tpopup menu, recently for my needs, so thought I would share.

It has gradient fill for background, scales item bitmaps, and imagelist to fit, will cache bitmaps of disabled item and cache them as it grayscales them.
You can make an item a heading by preceding the caption with <head>

its simple to use, I think so anyhow.  ;)
Add the unit to your uses clause.
Code: Pascal  [Select][+][-]
  1. uses ......, custommenuhandler;
Define the popupmenu as you wish, then before you call it for first time the items need hooking in, so then call, you only do this once.
Code: Pascal  [Select][+][-]
  1. CustomMenuHandlers.SetupPopUpMenuEvents(PopupMenu1,True);
Then in the popupmenu on popupevent, add this is to allow customized settings for tpopup you have defined.
Code: Pascal  [Select][+][-]
  1. CustomMenuHandlers.SetDisplayValues(clNone,clNone,'Gill Sans MT',18,1.0,clWhite,clNone,[],[fsBold],[fsItalic]);
  2. CustomMenuHandlers.SetDefaultGradientValues;  

Thats it, it should work, all the colors for gradient, fonts, are customizeable.

I've only tested on win32 widget so be interesting to see how it works on others.

Hope you enjoy

Changing one line to

Code: Pascal  [Select][+][-]
  1. CustomMenuHandlers.SetDisplayValues(RGBToColor(128,32,64),RGBToColor(64,4,8),'Comic Sans MS',18,1.8,clLime,clYellow,[],[fsBold],[fsItalic]);
Produces something totally different.
« Last Edit: October 08, 2025, 12:59:16 am by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1424
Re: Custom TPopUp Enhancement.
« Reply #1 on: October 08, 2025, 09:31:17 am »
Just noticed the uploaed version hada bit of code removed, I was checking an issue with the subist arrow and removed the transparancy, so i could see the actual size of the arrow bitmap.

Attached version that has it back in.
« Last Edit: October 08, 2025, 09:40:46 am by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

 

TinyPortal © 2005-2018