Menu items attached to controls (not forms)
Posted: Fri Aug 07, 2009 2:20 pm
by Craig Shearer >> Thu, 11 Nov 1999 3:39:22 GMT
Yo, Windows API Gurus...
We are currently developing a whizzy new control in JADE and we want to be able to have context sensitive menus on it. Context sensitive menus are easy on Forms - you simply design a hidden menu in the Painter then call popupMenu(contextMenu, x, y) in response to a right-mouse down event.
However, we want to have a popup menu attached to a control. This control can be painted on any form, so it will be inconvenient (to say the least!) to have to define its menu on the form on which it is painted. We thought we could create a menuItem object at runtime as follows:
MyConrol::windowCreated(blah...)
begin
if not isInPainter then
create myMenuItem transient;
myMenuItem.caption := "test'";
myMenuItem.form := form;
endif;
.....
end;
then...
mouseDown(blah...)
begin
if button = 2 then
form.popupMenu(myMenuItem, x.Integer, y.Integer);
endif;
.....
end;
However, when this is tested, we get a 14017 exception: Menu Item not found - This error is returned when the physical menu associated with a menu object cannot be found.
JADE Support doesn't have any answers to this problem.
Is there an easy set of Windows API calls that could be used to implement this functionality?
Here's hoping!
Craig.
Yo, Windows API Gurus...
We are currently developing a whizzy new control in JADE and we want to be able to have context sensitive menus on it. Context sensitive menus are easy on Forms - you simply design a hidden menu in the Painter then call popupMenu(contextMenu, x, y) in response to a right-mouse down event.
However, we want to have a popup menu attached to a control. This control can be painted on any form, so it will be inconvenient (to say the least!) to have to define its menu on the form on which it is painted. We thought we could create a menuItem object at runtime as follows:
MyConrol::windowCreated(blah...)
begin
if not isInPainter then
create myMenuItem transient;
myMenuItem.caption := "test'";
myMenuItem.form := form;
endif;
.....
end;
then...
mouseDown(blah...)
begin
if button = 2 then
form.popupMenu(myMenuItem, x.Integer, y.Integer);
endif;
.....
end;
However, when this is tested, we get a 14017 exception: Menu Item not found - This error is returned when the physical menu associated with a menu object cannot be found.
JADE Support doesn't have any answers to this problem.
Is there an easy set of Windows API calls that could be used to implement this functionality?
Here's hoping!
Craig.