For Russell on OnMeasureItem answer

1. Make sure the menu/popupmenu has OwnerDraw set to true.
2. You have to handle the OnMeasureItem for the menu items, and change the Width Setting there.  The easiest way to do this is to create one method and assign all the menu items OnMeasureItem to it.

I can't find the OnMeasureItem for PopupMenu, it is under PopupMenu.Items.

Can you show me smoe sample code? Thanks.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MyMenuItem1.OnMeasureItem := MyMeasureItem;
MyMenuItem2.OnMeasureItem := MyMeasureItem;
MyMenuItem3.OnMeasureItem := MyMeasureItem;

Or you can do it visually by creating an event handler for the first handler, then clicking on the event handler for the rest of the menu items and selecting the one created first. The Sender parameter will then contain the menuitem that it is measuring.

Geoff M.
Russell LibbySoftware Engineer, Advisory Commented:

The OnMeasureItem is not an event of the popupmenu/menu, but rather of the menu items (TMenuItem).

Simple example that binds all the popup menu items OnMeasureItem to a forms method

  TForm1            =  class(TForm)
     PopupMenu1:    TPopupMenu;
     miOne:         TMenuItem;
     miTwo:         TMenuItem;
     miThree:       TMenuItem;
     procedure      FormCreate(Sender: TObject);
     // Added to handle the OnMeasureItem for the menu items
     procedure      OnMeasureItem(Sender: TObject; ACanvas: TCanvas; var Width, Height: Integer);
     // Added so you can bind the popupup menu items to the forms OnMeasureItem handler
     procedure      BindPopupMenu(PopupMenu: TPopupMenu);
     // Private declarations
     // Public declarations

  Form1:            TForm1;

{$R *.DFM}

procedure TForm1.BindPopupMenu(PopupMenu: TPopupMenu);
var  dwIndex:    Integer;

  // Make sure OwnerDraw is set

  // Iterate the items
  for dwIndex:=0 to Pred(PopupMenu.Items.Count) do
     // Set the OnMeasureItem event handler


procedure TForm1.OnMeasureItem(Sender: TObject; ACanvas: TCanvas; var Width, Height: Integer);

  // Adjust the width only (set to your desired width)


procedure TForm1.FormCreate(Sender: TObject);

  // Bind PopupMenu1 to the form handler for OnMeasureItem


Hope this helps,

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jlisloAuthor Commented:
Thanks again Russell
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.