Rectangles/Text and popups

Neil McLaughlin

New Member
Progress 8.3B/GUI
OS: Win98

I want to have a popup for a screen rectangle but there is no popup attribute for rectangles or text. I have experimented with using the right click trigger for the rectangle to run a procedure persistently which will:

1) Assign a field specific popup to the frame
2) Apply the "right-mouse-click" to the frame to invoke the popup.
3) Clear the frame popup assignment.

Actual code:

Assign
FRAME DESIGN-FRAME:popup-menu =
/* Function to build popup and return handle */
int_rectangle_menu(P_WIDGET_TYPE, P_WIDGET_HANDLE) .

Apply "RIGHT-MOUSE-CLICK" to FRAME DESIGN-FRAME.

Assign FRAME DESIGN-FRAME:popup-menu = ?.

This doesn't work.
Any suggestions on ways to tackle this problem?
 
Hi Neil,

Apply the "right-mouse-click" to the frame to invoke the popup.

As you've discovered, this doesn't work. The reason is because the Progress 4GL operates in a purely passive mode and as the popup menu is a windows (i.e. external) object to Progress, you can not communicate with it through the 4GL. It can pass messages (events such as CHOOSE) to the 4GL through Progress but you can't pass messages directly to it. The same goes for any Progress widget.

To get this to work, you will need to make an API call, using the following prototype:

PROCEDURE SendMessageA EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER win-handle AS LONG NO-UNDO.
DEFINE INPUT PARAMETER win-msg AS LONG NO-UNDO.
DEFINE INPUT PARAMETER win-param1 AS LONG NO-UNDO.
DEFINE INPUT PARAMETER win-param2 AS LONG NO-UNDO.
END PROCEDURE.

For example, to view the popup-menu, apply the MENU-DROP event to it. This won't bring it into view, but will provide a convenient place to set menu-item sensitivity and for the API call.

ON "MENU-DROP" OF MENU mymenu
DO:
DEFINE VARIABLE hOwner AS HANDLE NO-UNDO.

ASSIGN hOwner = SELF:OWNER.

IF VALID-HANDLE(hOwner) THEN
DO:
/* Set menu-items sensitivity here */
...

/* Make popup-menu visible */
RUN SendMessageA (hOwner:hWnd, 517, 0, 0).
END.
END.

To detach a popup menu from one widget and attach it to another, first detach it from the current owner, and then attach it to the new:

DEFINE VARIABLE hOwner AS HANDLE NO-UNDO.

ASSIGN hOwner = MENU MyMenu:OWNER.

IF VALID-HANDLE(hOwner) THEN
ASSIGN hOwner:pOPUP-MENU = ?. /* Detach */

ASSIGN <new-owner-handle>:pOPUP-MENU = MENU mymenu:HANDLE.
 

Neil McLaughlin

New Member
Thanks for your help, coincidently I'd reached the same point with some prompting from a workmate. However I've run into some further problems. I have posted these to the PEG group and have included the oposting below - any further suggestions would be helpful. TIA.


PEG Posting 2 >>>>>

As a result of some more experimenting I have some more info:

The code fragment below works as the mouse-menu-down trigger with _static_ rectangle widgets but not when used as the persistent procedure for the
mouse-menu-down trigger of a _dynamically_ created rectangle widget.

PEG Posting 1 >>>>>

-----Original Message-----
From: Neil McLaughlin [mailto:n.mclaughlin@solicitec.com]
Sent: 22 November 2000 12:18
To: peg@peg.com
Subject: Rectangles/Text and popup menus


Progress 8.3B/GUI
OS: Win98
XPosted: api@peg.com

I want to have a popup for a dynamically created screen rectangle but there
is no popup attribute for rectangles or text.

I have experimented with using the right click and menu down triggers for
the rectangle to run a procedure persistently which will:

1) Assign a specific popup to the frame
2) Apply the "right-mouse-click" to the frame to invoke the popup, I
couldn't get this to work so am using a call to the windows API routine
SendMessageA.
3) Clear the frame popup assignment.

Actual code:
/***************************************************************************
*/
Assign
FRAME DESIGN-FRAME:popup-menu =
/* Function to build popup and return handle */
int_rectangle_menu(P_WIDGET_TYPE, P_WIDGET_HANDLE)
.

Run SendMessageA (input frame DESIGN-FRAME:HWND,
input 517, /* WM_RBUTTONUP */
input 0,
input 0,
output L-RESULT).

Assign
FRAME DESIGN-FRAME:popup-menu = ?
.
/***************************************************************************
*/

This displays the popup but doesn't fire the ON CHOOSE trigger for any
selected items in the menu. The popup is dynamically created but I've tried
with static menues - same problem.
If I comment out the assignment of ? to the frame popup attribute then later
right clicks within the frame display the popup and correctly fire the
choose triggers.

Any suggestions on ways to tackle this problem?

TIA
 
When a widget is dynamically created, then the triggers that you create must be persistent, otherwise they exist only as long as the creating procedure (or internal procedure). e.g.

CREATE MENU-ITEM wh
ASSIGN ...
TRIGGERS:
ON "CHOOSE" PERSISTENT RUN itemchoose IN THIS-PROCEDURE PROCEDURE (wh).
END TRIGGERS.

If you can't attach a popup menu to text or rectangles, then why not use a FILL-IN that is viewed as text? This might suffice if you don't want to display a graphical edge.
 
Top