From: Chris Hanson <org/chris-hanson/cph>
Date: Tue, 16 May 1995 09:21:28 +0000 (+0000)
Subject: Add primitives to create and manage menus.
X-Git-Tag: 20090517-FFI~6307
X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=1305057c2c9de1821b37c305bee4fbe8e01fab47;p=mit-scheme.git

Add primitives to create and manage menus.
---

diff --git a/v7/src/edwin/edwin.pkg b/v7/src/edwin/edwin.pkg
index e8ffde6c3..22d143fba 100644
--- a/v7/src/edwin/edwin.pkg
+++ b/v7/src/edwin/edwin.pkg
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: edwin.pkg,v 1.174 1995/05/06 02:22:02 cph Exp $
+$Id: edwin.pkg,v 1.175 1995/05/16 09:21:12 cph Exp $
 
 Copyright (c) 1989-95 Massachusetts Institute of Technology
 
@@ -1204,7 +1204,9 @@ MIT in each case. |#
 	    event-type
 	    event-type:button
 	    event-type:close
+	    event-type:command
 	    event-type:focus
+	    event-type:help
 	    event-type:key
 	    event-type:paint
 	    event-type:resize
diff --git a/v7/src/edwin/os2term.scm b/v7/src/edwin/os2term.scm
index 627b2420b..f3b519c64 100644
--- a/v7/src/edwin/os2term.scm
+++ b/v7/src/edwin/os2term.scm
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;	$Id: os2term.scm,v 1.7 1995/04/22 21:20:13 cph Exp $
+;;;	$Id: os2term.scm,v 1.8 1995/05/16 09:21:28 cph Exp $
 ;;;
 ;;;	Copyright (c) 1994-95 Massachusetts Institute of Technology
 ;;;
@@ -830,7 +830,12 @@
 				(inner (fix:+ index 1)))))))))))))))
 
 (define (process-special-event event)
-  (let ((handler (vector-ref event-handlers (event-type event)))
+  (let ((handler
+	 (let ((type (event-type event)))
+	   (and (fix:fixnum? type)
+		(fix:>= type 0)
+		(fix:< type (vector-length event-handlers))
+		(vector-ref event-handlers type))))
 	(screen (wid->screen (event-wid event))))
     (and handler
 	 screen
diff --git a/v7/src/microcode/os2msg.h b/v7/src/microcode/os2msg.h
index d48f8b09c..70290981c 100644
--- a/v7/src/microcode/os2msg.h
+++ b/v7/src/microcode/os2msg.h
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: os2msg.h,v 1.9 1995/05/02 20:53:30 cph Exp $
+$Id: os2msg.h,v 1.10 1995/05/16 09:20:22 cph Exp $
 
 Copyright (c) 1994-95 Massachusetts Institute of Technology
 
@@ -108,6 +108,7 @@ typedef enum
   mt_window_focusp_reply,
   mt_window_set_state,		/* raise/lower/hide/min/max/restore window */
   mt_window_set_title,		/* set title-bar text */
+  mt_window_update_frame,	/* do WM_UPDATEFRAME on the window */
 
   /* These are also PM thread commands, but they operate on
      presentation spaces rather than on windows.  */
@@ -146,6 +147,21 @@ typedef enum
   mt_clipboard_read_text_request, /* read text from clipboard */
   mt_clipboard_read_text_reply,
 
+  mt_menu_create_request,	/* create menu */
+  mt_menu_create_reply,
+  mt_menu_destroy,		/* destroy menu */
+  mt_menu_insert_item_request,	/* add item to menu, returns item index */
+  mt_menu_insert_item_reply,
+  mt_menu_remove_item_request,	/* remove item from menu, returns new length */
+  mt_menu_remove_item_reply,
+  mt_menu_n_items_request,	/* number of items in menu */
+  mt_menu_n_items_reply,
+  mt_menu_nth_item_id_request,	/* get menu item ID from index */
+  mt_menu_nth_item_id_reply,
+  mt_menu_get_item_attributes_request, /* get menu item attributes */
+  mt_menu_get_item_attributes_reply,
+  mt_menu_set_item_attributes,	/* set menu item attributes */
+
   /* These are messages that are automatically generated by the PM
      thread when the corresponding events occur.  */
   mt_button_event,		/* mouse button press */
@@ -155,6 +171,8 @@ typedef enum
   mt_paint_event,		/* window needs painting */
   mt_resize_event,		/* window resized */
   mt_visibility_event,		/* window visibility change */
+  mt_command_event,		/* WM_COMMAND message */
+  mt_help_event,		/* WM_HELP message */
 
   /* This requests the thread on the other end of the connection to
      kill itself.  At present this request is not used.  */
diff --git a/v7/src/microcode/os2pm.c b/v7/src/microcode/os2pm.c
index 0a6d21464..b31e7113c 100644
--- a/v7/src/microcode/os2pm.c
+++ b/v7/src/microcode/os2pm.c
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: os2pm.c,v 1.14 1995/05/13 11:10:10 cph Exp $
+$Id: os2pm.c,v 1.15 1995/05/16 09:20:06 cph Exp $
 
 Copyright (c) 1994-95 Massachusetts Institute of Technology
 
@@ -350,6 +350,15 @@ typedef struct
 } sm_set_title_t;
 #define SM_SET_TITLE_WINDOW(m) (((sm_set_title_t *) (m)) -> window)
 #define SM_SET_TITLE_TITLE(m) (((sm_set_title_t *) (m)) -> title)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  window_t * window;
+  USHORT flags;
+} sm_update_frame_t;
+#define SM_UPDATE_FRAME_WINDOW(m) (((sm_update_frame_t *) (m)) -> window)
+#define SM_UPDATE_FRAME_FLAGS(m) (((sm_update_frame_t *) (m)) -> flags)
 
 typedef struct
 {
@@ -712,6 +721,174 @@ typedef struct
 #define SM_CLIPBOARD_READ_TEXT_REPLY_TEXT(m)				\
   (((sm_clipboard_read_text_reply_t *) (m)) -> text)
 
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  HWND owner;
+  USHORT style;
+  USHORT id;
+} sm_menu_create_request_t;
+#define SM_MENU_CREATE_REQUEST_OWNER(m)				\
+  (((sm_menu_create_request_t *) (m)) -> owner)
+#define SM_MENU_CREATE_REQUEST_STYLE(m)				\
+  (((sm_menu_create_request_t *) (m)) -> style)
+#define SM_MENU_CREATE_REQUEST_ID(m)				\
+  (((sm_menu_create_request_t *) (m)) -> id)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  HWND menu;
+} sm_menu_create_reply_t;
+#define SM_MENU_CREATE_REPLY_MENU(m)				\
+  (((sm_menu_create_reply_t *) (m)) -> menu)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  HWND menu;
+} sm_menu_destroy_t;
+#define SM_MENU_DESTROY_MENU(m) (((sm_menu_destroy_t *) (m)) -> menu)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  HWND menu;
+  USHORT position;
+  USHORT style;
+  USHORT attributes;
+  USHORT id;
+  HWND submenu;
+  PSZ text;
+} sm_menu_insert_item_request_t;
+#define SM_MENU_INSERT_ITEM_REQUEST_MENU(m)				\
+  (((sm_menu_insert_item_request_t *) (m)) -> menu)
+#define SM_MENU_INSERT_ITEM_REQUEST_POSITION(m)				\
+  (((sm_menu_insert_item_request_t *) (m)) -> position)
+#define SM_MENU_INSERT_ITEM_REQUEST_STYLE(m)				\
+  (((sm_menu_insert_item_request_t *) (m)) -> style)
+#define SM_MENU_INSERT_ITEM_REQUEST_ATTRIBUTES(m)			\
+  (((sm_menu_insert_item_request_t *) (m)) -> attributes)
+#define SM_MENU_INSERT_ITEM_REQUEST_ID(m)				\
+  (((sm_menu_insert_item_request_t *) (m)) -> id)
+#define SM_MENU_INSERT_ITEM_REQUEST_SUBMENU(m)				\
+  (((sm_menu_insert_item_request_t *) (m)) -> submenu)
+#define SM_MENU_INSERT_ITEM_REQUEST_TEXT(m)				\
+  (((sm_menu_insert_item_request_t *) (m)) -> text)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  USHORT position;
+} sm_menu_insert_item_reply_t;
+#define SM_MENU_INSERT_ITEM_REPLY_POSITION(m)				\
+  (((sm_menu_insert_item_reply_t *) (m)) -> position)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  HWND menu;
+  USHORT id;
+  USHORT submenup;
+  USHORT deletep;
+} sm_menu_remove_item_request_t;
+#define SM_MENU_REMOVE_ITEM_REQUEST_MENU(m)				\
+  (((sm_menu_remove_item_request_t *) (m)) -> menu)
+#define SM_MENU_REMOVE_ITEM_REQUEST_ID(m)				\
+  (((sm_menu_remove_item_request_t *) (m)) -> id)
+#define SM_MENU_REMOVE_ITEM_REQUEST_SUBMENUP(m)				\
+  (((sm_menu_remove_item_request_t *) (m)) -> submenup)
+#define SM_MENU_REMOVE_ITEM_REQUEST_DELETEP(m)				\
+  (((sm_menu_remove_item_request_t *) (m)) -> deletep)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  USHORT length;
+} sm_menu_remove_item_reply_t;
+#define SM_MENU_REMOVE_ITEM_REPLY_LENGTH(m)				\
+  (((sm_menu_remove_item_reply_t *) (m)) -> length)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  HWND menu;
+} sm_menu_n_items_request_t;
+#define SM_MENU_N_ITEMS_REQUEST_MENU(m)					\
+  (((sm_menu_n_items_request_t *) (m)) -> menu)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  USHORT length;
+} sm_menu_n_items_reply_t;
+#define SM_MENU_N_ITEMS_REPLY_LENGTH(m)					\
+  (((sm_menu_n_items_reply_t *) (m)) -> length)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  HWND menu;
+  USHORT position;
+} sm_menu_nth_item_id_request_t;
+#define SM_MENU_NTH_ITEM_ID_REQUEST_MENU(m)				\
+  (((sm_menu_nth_item_id_request_t *) (m)) -> menu)
+#define SM_MENU_NTH_ITEM_ID_REQUEST_POSITION(m)				\
+  (((sm_menu_nth_item_id_request_t *) (m)) -> position)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  USHORT id;
+} sm_menu_nth_item_id_reply_t;
+#define SM_MENU_NTH_ITEM_ID_REPLY_ID(m)					\
+  (((sm_menu_nth_item_id_reply_t *) (m)) -> id)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  HWND menu;
+  USHORT id;
+  USHORT submenup;
+  USHORT mask;
+} sm_menu_get_item_attributes_request_t;
+#define SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_MENU(m)			\
+  (((sm_menu_get_item_attributes_request_t *) (m)) -> menu)
+#define SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_ID(m)			\
+  (((sm_menu_get_item_attributes_request_t *) (m)) -> id)
+#define SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_SUBMENUP(m)			\
+  (((sm_menu_get_item_attributes_request_t *) (m)) -> submenup)
+#define SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_MASK(m)			\
+  (((sm_menu_get_item_attributes_request_t *) (m)) -> mask)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  USHORT attributes;
+} sm_menu_get_item_attributes_reply_t;
+#define SM_MENU_GET_ITEM_ATTRIBUTES_REPLY_ATTRIBUTES(m)			\
+  (((sm_menu_get_item_attributes_reply_t *) (m)) -> attributes)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  HWND menu;
+  USHORT id;
+  USHORT submenup;
+  USHORT mask;
+  USHORT attributes;
+} sm_menu_set_item_attributes_t;
+#define SM_MENU_SET_ITEM_ATTRIBUTES_MENU(m)				\
+  (((sm_menu_set_item_attributes_t *) (m)) -> menu)
+#define SM_MENU_SET_ITEM_ATTRIBUTES_ID(m)				\
+  (((sm_menu_set_item_attributes_t *) (m)) -> id)
+#define SM_MENU_SET_ITEM_ATTRIBUTES_SUBMENUP(m)				\
+  (((sm_menu_set_item_attributes_t *) (m)) -> submenup)
+#define SM_MENU_SET_ITEM_ATTRIBUTES_MASK(m)				\
+  (((sm_menu_set_item_attributes_t *) (m)) -> mask)
+#define SM_MENU_SET_ITEM_ATTRIBUTES_ATTRIBUTES(m)			\
+  (((sm_menu_set_item_attributes_t *) (m)) -> attributes)
+
 static void sync_transaction (qid_t, msg_t *);
 static void sync_reply (qid_t);
 
@@ -754,6 +931,7 @@ static void set_window_size (window_t *, unsigned short, unsigned short);
 static int window_focusp (window_t *);
 static void set_window_state (window_t *, window_state_t);
 static void set_window_title (window_t *, PSZ);
+static void update_frame_window (window_t *, USHORT);
 
 static ps_t * create_memory_ps (qid_t);
 static void destroy_memory_ps (ps_t *);
@@ -790,6 +968,16 @@ static font_metrics_t * ps_set_font (ps_t *, unsigned short, const char *);
 static void clipboard_write_text (const char *);
 static const char * clipboard_read_text (void);
 
+static HWND menu_create (HWND, USHORT, USHORT);
+static void menu_destroy (HWND);
+static USHORT menu_insert_item
+  (HWND, USHORT, USHORT, USHORT, USHORT, HWND, PSZ);
+static USHORT menu_remove_item (HWND, USHORT, USHORT, USHORT);
+static USHORT menu_n_items (HWND);
+static USHORT menu_nth_item_id (HWND, USHORT);
+static USHORT menu_get_item_attributes (HWND, USHORT, USHORT, USHORT);
+static void menu_set_item_attributes (HWND, USHORT, USHORT, USHORT, USHORT);
+
 static msg_t * make_button_event
   (wid_t, unsigned char, unsigned char, unsigned short, unsigned short,
    unsigned short);
@@ -801,6 +989,8 @@ static msg_t * make_paint_event
   (wid_t, unsigned short, unsigned short, unsigned short, unsigned short);
 static msg_t * make_resize_event (wid_t, unsigned short, unsigned short);
 static msg_t * make_visibility_event (wid_t, int);
+static msg_t * make_command_event (wid_t, USHORT);
+static msg_t * make_help_event (wid_t, USHORT);
 
 #define ID_RESOURCES 1
 #define ID_FRAME 1
@@ -886,6 +1076,7 @@ OS2_initialize_pm_thread (void)
   SET_MSG_TYPE_LENGTH (mt_window_focusp_reply, sm_focusp_reply_t);
   SET_MSG_TYPE_LENGTH (mt_window_set_state, sm_set_state_t);
   SET_MSG_TYPE_LENGTH (mt_window_set_title, sm_set_title_t);
+  SET_MSG_TYPE_LENGTH (mt_window_update_frame, sm_update_frame_t);
 
   SET_MSG_TYPE_LENGTH (mt_create_memory_ps_request,
 		       sm_create_memory_ps_request_t);
@@ -929,6 +1120,32 @@ OS2_initialize_pm_thread (void)
   SET_MSG_TYPE_LENGTH (mt_clipboard_read_text_reply,
 		       sm_clipboard_read_text_reply_t);
 
+  SET_MSG_TYPE_LENGTH (mt_menu_create_request, sm_menu_create_request_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_create_reply, sm_menu_create_reply_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_destroy, sm_menu_destroy_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_insert_item_request,
+		       sm_menu_insert_item_request_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_insert_item_reply,
+		       sm_menu_insert_item_reply_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_remove_item_request,
+		       sm_menu_remove_item_request_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_remove_item_reply,
+		       sm_menu_remove_item_reply_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_n_items_request,
+		       sm_menu_n_items_request_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_n_items_reply,
+		       sm_menu_n_items_reply_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_nth_item_id_request,
+		       sm_menu_nth_item_id_request_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_nth_item_id_reply,
+		       sm_menu_nth_item_id_reply_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_get_item_attributes_request,
+		       sm_menu_get_item_attributes_request_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_get_item_attributes_reply,
+		       sm_menu_get_item_attributes_reply_t);
+  SET_MSG_TYPE_LENGTH (mt_menu_set_item_attributes,
+		       sm_menu_set_item_attributes_t);
+
   SET_MSG_TYPE_LENGTH (mt_button_event, sm_button_event_t);
   SET_MSG_TYPE_LENGTH (mt_close_event, sm_close_event_t);
   SET_MSG_TYPE_LENGTH (mt_focus_event, sm_focus_event_t);
@@ -936,6 +1153,8 @@ OS2_initialize_pm_thread (void)
   SET_MSG_TYPE_LENGTH (mt_paint_event, sm_paint_event_t);
   SET_MSG_TYPE_LENGTH (mt_resize_event, sm_resize_event_t);
   SET_MSG_TYPE_LENGTH (mt_visibility_event, sm_visibility_event_t);
+  SET_MSG_TYPE_LENGTH (mt_command_event, sm_command_event_t);
+  SET_MSG_TYPE_LENGTH (mt_help_event, sm_help_event_t);
 
   initialize_id_table (& psid_table);
   initialize_id_table (& wid_table);
@@ -1208,6 +1427,7 @@ static void handle_window_set_size_request (msg_t *);
 static void handle_window_focusp_request (msg_t *);
 static void handle_window_set_state_request (msg_t *);
 static void handle_window_set_title_request (msg_t *);
+static void handle_window_update_frame_request (msg_t *);
 
 static void handle_create_memory_ps_request (msg_t *);
 static void handle_destroy_memory_ps_request (msg_t *);
@@ -1236,6 +1456,15 @@ static void handle_ps_set_bitmap_bits_request (msg_t *);
 static void handle_clipboard_write_text_request (msg_t *);
 static void handle_clipboard_read_text_request (msg_t *);
 
+static void handle_menu_create_request (msg_t *);
+static void handle_menu_destroy_request (msg_t *);
+static void handle_menu_insert_item_request (msg_t *);
+static void handle_menu_remove_item_request (msg_t *);
+static void handle_menu_n_items_request (msg_t *);
+static void handle_menu_nth_item_id_request (msg_t *);
+static void handle_menu_get_item_attributes_request (msg_t *);
+static void handle_menu_set_item_attributes_request (msg_t *);
+
 static MRESULT EXPENTRY
 object_window_procedure (HWND window, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
@@ -1301,6 +1530,9 @@ object_window_procedure (HWND window, ULONG msg, MPARAM mp1, MPARAM mp2)
 	case mt_window_set_title:
 	  handle_window_set_title_request (message);
 	  break;
+	case mt_window_update_frame:
+	  handle_window_update_frame_request (message);
+	  break;
 
 	case mt_create_memory_ps_request:
 	  handle_create_memory_ps_request (message);
@@ -1371,6 +1603,7 @@ object_window_procedure (HWND window, ULONG msg, MPARAM mp1, MPARAM mp2)
 	case mt_ps_set_bitmap_bits_request:
 	  handle_ps_set_bitmap_bits_request (message);
 	  break;
+
 	case mt_clipboard_write_text:
 	  handle_clipboard_write_text_request (message);
 	  break;
@@ -1378,6 +1611,31 @@ object_window_procedure (HWND window, ULONG msg, MPARAM mp1, MPARAM mp2)
 	  handle_clipboard_read_text_request (message);
 	  break;
 
+	case mt_menu_create_request:
+	  handle_menu_create_request (message);
+	  break;
+	case mt_menu_destroy:
+	  handle_menu_destroy_request (message);
+	  break;
+	case mt_menu_insert_item_request:
+	  handle_menu_insert_item_request (message);
+	  break;
+	case mt_menu_remove_item_request:
+	  handle_menu_remove_item_request (message);
+	  break;
+	case mt_menu_n_items_request:
+	  handle_menu_n_items_request (message);
+	  break;
+	case mt_menu_nth_item_id_request:
+	  handle_menu_nth_item_id_request (message);
+	  break;
+	case mt_menu_get_item_attributes_request:
+	  handle_menu_get_item_attributes_request (message);
+	  break;
+	case mt_menu_set_item_attributes:
+	  handle_menu_set_item_attributes_request (message);
+	  break;
+
 	default:
 	  OS2_logic_error ("Unknown message type sent to PM thread.");
 	  break;
@@ -1850,6 +2108,34 @@ handle_window_set_title_request (msg_t * message)
   OS2_destroy_message (message);
   simple_reply (sender);
 }
+
+HWND
+OS2_window_frame_handle (wid_t wid)
+{
+  /* This is needed by the OS2_menu_create, to supply an owner for the
+     top-level menu bar.  */
+  return (WINDOW_FRAME (wid_to_window (wid)));
+}
+
+void
+OS2_window_update_frame (wid_t wid, USHORT flags)
+{
+  window_t * window = (wid_to_window (wid));
+  msg_t * message = (OS2_create_message (mt_window_update_frame));
+  (SM_UPDATE_FRAME_WINDOW (message)) = window;
+  (SM_UPDATE_FRAME_FLAGS (message)) = flags;
+  simple_transaction ((WINDOW_QID (window)), message);
+}
+
+static void
+handle_window_update_frame_request (msg_t * message)
+{
+  qid_t sender = (MSG_SENDER (message));
+  update_frame_window ((SM_UPDATE_FRAME_WINDOW (message)),
+		       (SM_UPDATE_FRAME_FLAGS (message)));
+  OS2_destroy_message (message);
+  simple_reply (sender);
+}
 
 psid_t
 OS2_create_memory_ps (qid_t qid)
@@ -2477,6 +2763,229 @@ handle_clipboard_read_text_request (msg_t * request)
   OS2_send_message (sender, reply);
 }
 
+HWND
+OS2_menu_create (qid_t qid, HWND owner, USHORT style, USHORT id)
+{
+  msg_t * message = (OS2_create_message (mt_menu_create_request));
+  HWND menu;
+  (SM_MENU_CREATE_REQUEST_OWNER (message)) = owner;
+  (SM_MENU_CREATE_REQUEST_STYLE (message)) = style;
+  (SM_MENU_CREATE_REQUEST_ID (message)) = id;
+  message = (OS2_message_transaction (qid, message, mt_menu_create_reply));
+  menu = (SM_MENU_CREATE_REPLY_MENU (message));
+  OS2_destroy_message (message);
+  return (menu);
+}
+
+static void
+handle_menu_create_request (msg_t * request)
+{
+  qid_t sender = (MSG_SENDER (request));
+  msg_t * reply = (OS2_create_message (mt_menu_create_reply));
+  (SM_MENU_CREATE_REPLY_MENU (reply))
+    = (menu_create ((SM_MENU_CREATE_REQUEST_OWNER (request)),
+		    (SM_MENU_CREATE_REQUEST_STYLE (request)),
+		    (SM_MENU_CREATE_REQUEST_ID (request))));
+  OS2_destroy_message (request);
+  OS2_send_message (sender, reply);
+}
+
+void
+OS2_menu_destroy (qid_t qid, HWND menu)
+{
+  msg_t * message = (OS2_create_message (mt_menu_destroy));
+  (SM_MENU_DESTROY_MENU (message)) = menu;
+  simple_transaction (qid, message);
+}
+
+static void
+handle_menu_destroy_request (msg_t * request)
+{
+  qid_t sender = (MSG_SENDER (request));
+  menu_destroy (SM_MENU_DESTROY_MENU (request));
+  OS2_destroy_message (request);
+  simple_reply (sender);
+}
+
+USHORT
+OS2_menu_insert_item (qid_t qid, HWND menu, USHORT position, USHORT style,
+		      USHORT attributes, USHORT id, HWND submenu, PSZ text)
+{
+  msg_t * message = (OS2_create_message (mt_menu_insert_item_request));
+  USHORT reply_position;
+  (SM_MENU_INSERT_ITEM_REQUEST_MENU (message)) = menu;
+  (SM_MENU_INSERT_ITEM_REQUEST_POSITION (message)) = position;
+  (SM_MENU_INSERT_ITEM_REQUEST_STYLE (message)) = style;
+  (SM_MENU_INSERT_ITEM_REQUEST_ATTRIBUTES (message)) = attributes;
+  (SM_MENU_INSERT_ITEM_REQUEST_ID (message)) = id;
+  (SM_MENU_INSERT_ITEM_REQUEST_SUBMENU (message)) = submenu;
+  (SM_MENU_INSERT_ITEM_REQUEST_TEXT (message)) = text;
+  message
+    = (OS2_message_transaction (qid, message, mt_menu_insert_item_reply));
+  reply_position = (SM_MENU_INSERT_ITEM_REPLY_POSITION (message));
+  OS2_destroy_message (message);
+  return (reply_position);
+}
+
+static void
+handle_menu_insert_item_request (msg_t * request)
+{
+  qid_t sender = (MSG_SENDER (request));
+  msg_t * reply = (OS2_create_message (mt_menu_insert_item_reply));
+  (SM_MENU_INSERT_ITEM_REPLY_POSITION (reply))
+    = (menu_insert_item ((SM_MENU_INSERT_ITEM_REQUEST_MENU (request)),
+			 (SM_MENU_INSERT_ITEM_REQUEST_POSITION (request)),
+			 (SM_MENU_INSERT_ITEM_REQUEST_STYLE (request)),
+			 (SM_MENU_INSERT_ITEM_REQUEST_ATTRIBUTES (request)),
+			 (SM_MENU_INSERT_ITEM_REQUEST_ID (request)),
+			 (SM_MENU_INSERT_ITEM_REQUEST_SUBMENU (request)),
+			 (SM_MENU_INSERT_ITEM_REQUEST_TEXT (request))));
+  OS2_destroy_message (request);
+  OS2_send_message (sender, reply);
+}
+
+USHORT
+OS2_menu_remove_item (qid_t qid, HWND menu, USHORT id, USHORT submenup,
+		      USHORT deletep)
+{
+  msg_t * message = (OS2_create_message (mt_menu_remove_item_request));
+  USHORT length;
+  (SM_MENU_REMOVE_ITEM_REQUEST_MENU (message)) = menu;
+  (SM_MENU_REMOVE_ITEM_REQUEST_ID (message)) = id;
+  (SM_MENU_REMOVE_ITEM_REQUEST_SUBMENUP (message)) = submenup;
+  (SM_MENU_REMOVE_ITEM_REQUEST_DELETEP (message)) = deletep;
+  message
+    = (OS2_message_transaction (qid, message, mt_menu_remove_item_reply));
+  length = (SM_MENU_REMOVE_ITEM_REPLY_LENGTH (message));
+  OS2_destroy_message (message);
+  return (length);
+}
+
+static void
+handle_menu_remove_item_request (msg_t * request)
+{
+  qid_t sender = (MSG_SENDER (request));
+  msg_t * reply = (OS2_create_message (mt_menu_remove_item_reply));
+  (SM_MENU_REMOVE_ITEM_REPLY_LENGTH (reply))
+    = (menu_remove_item ((SM_MENU_REMOVE_ITEM_REQUEST_MENU (request)),
+			 (SM_MENU_REMOVE_ITEM_REQUEST_ID (request)),
+			 (SM_MENU_REMOVE_ITEM_REQUEST_SUBMENUP (request)),
+			 (SM_MENU_REMOVE_ITEM_REQUEST_DELETEP (request))));
+  OS2_destroy_message (request);
+  OS2_send_message (sender, reply);
+}
+
+USHORT
+OS2_menu_n_items (qid_t qid, HWND menu)
+{
+  msg_t * message = (OS2_create_message (mt_menu_n_items_request));
+  USHORT length;
+  (SM_MENU_N_ITEMS_REQUEST_MENU (message)) = menu;
+  message
+    = (OS2_message_transaction (qid, message, mt_menu_n_items_reply));
+  length = (SM_MENU_N_ITEMS_REPLY_LENGTH (message));
+  OS2_destroy_message (message);
+  return (length);
+}
+
+static void
+handle_menu_n_items_request (msg_t * request)
+{
+  qid_t sender = (MSG_SENDER (request));
+  msg_t * reply = (OS2_create_message (mt_menu_n_items_reply));
+  (SM_MENU_N_ITEMS_REPLY_LENGTH (reply))
+    = (menu_n_items (SM_MENU_N_ITEMS_REQUEST_MENU (request)));
+  OS2_destroy_message (request);
+  OS2_send_message (sender, reply);
+}
+
+USHORT
+OS2_menu_nth_item_id (qid_t qid, HWND menu, USHORT position)
+{
+  msg_t * message = (OS2_create_message (mt_menu_nth_item_id_request));
+  USHORT id;
+  (SM_MENU_NTH_ITEM_ID_REQUEST_MENU (message)) = menu;
+  (SM_MENU_NTH_ITEM_ID_REQUEST_POSITION (message)) = position;
+  message
+    = (OS2_message_transaction (qid, message, mt_menu_nth_item_id_reply));
+  id = (SM_MENU_NTH_ITEM_ID_REPLY_ID (message));
+  OS2_destroy_message (message);
+  return (id);
+}
+
+static void
+handle_menu_nth_item_id_request (msg_t * request)
+{
+  qid_t sender = (MSG_SENDER (request));
+  msg_t * reply = (OS2_create_message (mt_menu_nth_item_id_reply));
+  (SM_MENU_NTH_ITEM_ID_REPLY_ID (reply))
+    = (menu_nth_item_id ((SM_MENU_NTH_ITEM_ID_REQUEST_MENU (request)),
+			 (SM_MENU_NTH_ITEM_ID_REQUEST_POSITION (request))));
+  OS2_destroy_message (request);
+  OS2_send_message (sender, reply);
+}
+
+USHORT
+OS2_menu_get_item_attributes (qid_t qid, HWND menu, USHORT id, USHORT submenup,
+			      USHORT mask)
+{
+  msg_t * message = (OS2_create_message (mt_menu_get_item_attributes_request));
+  USHORT attributes;
+  (SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_MENU (message)) = menu;
+  (SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_ID (message)) = id;
+  (SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_SUBMENUP (message)) = submenup;
+  (SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_MASK (message)) = mask;
+  message
+    = (OS2_message_transaction (qid,
+				message,
+				mt_menu_get_item_attributes_reply));
+  attributes = (SM_MENU_GET_ITEM_ATTRIBUTES_REPLY_ATTRIBUTES (message));
+  OS2_destroy_message (message);
+  return (attributes);
+}
+
+static void
+handle_menu_get_item_attributes_request (msg_t * request)
+{
+  qid_t sender = (MSG_SENDER (request));
+  msg_t * reply = (OS2_create_message (mt_menu_get_item_attributes_reply));
+  (SM_MENU_GET_ITEM_ATTRIBUTES_REPLY_ATTRIBUTES (reply))
+    = (menu_get_item_attributes
+       ((SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_MENU (request)),
+	(SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_ID (request)),
+	(SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_SUBMENUP (request)),
+	(SM_MENU_GET_ITEM_ATTRIBUTES_REQUEST_MASK (request))));
+  OS2_destroy_message (request);
+  OS2_send_message (sender, reply);
+}
+
+void
+OS2_menu_set_item_attributes (qid_t qid, HWND menu, USHORT id, USHORT submenup,
+			      USHORT mask, USHORT attributes)
+{
+  msg_t * message = (OS2_create_message (mt_menu_set_item_attributes));
+  (SM_MENU_SET_ITEM_ATTRIBUTES_MENU (message)) = menu;
+  (SM_MENU_SET_ITEM_ATTRIBUTES_ID (message)) = id;
+  (SM_MENU_SET_ITEM_ATTRIBUTES_SUBMENUP (message)) = submenup;
+  (SM_MENU_SET_ITEM_ATTRIBUTES_MASK (message)) = mask;
+  (SM_MENU_SET_ITEM_ATTRIBUTES_ATTRIBUTES (message)) = attributes;
+  simple_transaction (qid, message);
+}
+
+static void
+handle_menu_set_item_attributes_request (msg_t * request)
+{
+  qid_t sender = (MSG_SENDER (request));
+  menu_set_item_attributes
+    ((SM_MENU_SET_ITEM_ATTRIBUTES_MENU (request)),
+     (SM_MENU_SET_ITEM_ATTRIBUTES_ID (request)),
+     (SM_MENU_SET_ITEM_ATTRIBUTES_SUBMENUP (request)),
+     (SM_MENU_SET_ITEM_ATTRIBUTES_MASK (request)),
+     (SM_MENU_SET_ITEM_ATTRIBUTES_ATTRIBUTES (request)));
+  OS2_destroy_message (request);
+  simple_reply (sender);
+}
+
 static window_t * make_window (qid_t, qid_t);
 
 static wid_t
@@ -2789,6 +3298,14 @@ set_window_title (window_t * window, PSZ title)
   if (!WinSetWindowText ((WINDOW_FRAME (window)), title))
     window_warning (WinSetWindowText);
 }
+
+static void
+update_frame_window (window_t * window, USHORT flags)
+{
+  (void) WinSendMsg ((WINDOW_FRAME (window)), WM_UPDATEFRAME,
+		     (MPFROMSHORT (flags)),
+		     0);
+}
 
 static ps_t *
 create_memory_ps (qid_t qid)
@@ -3189,6 +3706,89 @@ clipboard_read_text (void)
   return (result);
 }
 
+static HWND
+menu_create (HWND owner, USHORT style, USHORT id)
+{
+  HWND menu
+    = (WinCreateWindow (owner,	/* parent window */
+			WC_MENU, /* class name */
+			"",	/* window text */
+			style,	/* window style */
+			0, 0, 0, 0, /* size and position */
+			owner,	/* owner window */
+			HWND_TOP, /* sibling window */
+			id,	/* ID */
+			0,	/* control data */
+			0	/* presentation parameters */
+			));
+  if (menu == NULLHANDLE)
+    window_error (WinCreateWindow);
+  return (menu);
+}
+
+static void
+menu_destroy (HWND menu)
+{
+  if (!WinDestroyWindow (menu))
+    window_error (WinDestroyWindow);
+}
+
+static USHORT
+menu_insert_item (HWND menu, USHORT position, USHORT style, USHORT attributes,
+		  USHORT id, HWND submenu, PSZ text)
+{
+  MENUITEM item;
+  (item . iPosition) = position;
+  (item . afStyle) = style;
+  (item . afAttribute) = attributes;
+  (item . id) = id;
+  (item . hwndSubMenu) = submenu;
+  (item . hItem) = 0;
+  return (SHORT1FROMMR (WinSendMsg (menu, MM_INSERTITEM,
+				    (MPFROMP (&item)),
+				    (MPFROMP (text)))));
+}
+
+static USHORT
+menu_remove_item (HWND menu, USHORT id, USHORT submenup, USHORT deletep)
+{
+  return (SHORT1FROMMR (WinSendMsg (menu,
+				    (deletep ? MM_DELETEITEM : MM_REMOVEITEM),
+				    (MPFROM2SHORT (id, submenup)),
+				    0)));
+}
+
+static USHORT
+menu_n_items (HWND menu)
+{
+  return (SHORT1FROMMR (WinSendMsg (menu, MM_QUERYITEMCOUNT, 0, 0)));
+}
+
+static USHORT
+menu_nth_item_id (HWND menu, USHORT position)
+{
+  return (SHORT1FROMMR (WinSendMsg (menu, MM_ITEMIDFROMPOSITION,
+				    (MPFROMSHORT (position)),
+				    0)));
+}
+
+static USHORT
+menu_get_item_attributes (HWND menu, USHORT id, USHORT submenup, USHORT mask)
+{
+  return (SHORT1FROMMR (WinSendMsg (menu, MM_QUERYITEMATTR,
+				    (MPFROM2SHORT (id, submenup)),
+				    (MPFROMSHORT (mask)))));
+}
+
+static void
+menu_set_item_attributes (HWND menu, USHORT id, USHORT submenup, USHORT mask,
+			  USHORT attributes)
+{
+  (void) WinSendMsg (menu, MM_SETITEMATTR,
+		     (MPFROM2SHORT (id, submenup)),
+		     (MPFROM2SHORT (mask, attributes)));
+}
+
 static int parse_font_spec (const char *, PSZ *, LONG *, USHORT *);
 static int ps_set_font_1 (ps_t * ps, PSZ, LONG, USHORT, LONG);
 static PLONG ps_make_char_increments (LONG);
@@ -3583,6 +4183,22 @@ window_procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 					    (SHORT1FROMMP (mp1)))));
 	return (MRVOID);
       }
+    case WM_COMMAND:
+      {
+	window_t * window = (hwnd_to_window (hwnd));
+	SEND_EVENT (window,
+		    (make_command_event ((WINDOW_ID (window)),
+					 (SHORT1FROMMP (mp1)))));
+	return (MRVOID);
+      }
+    case WM_HELP:
+      {
+	window_t * window = (hwnd_to_window (hwnd));
+	SEND_EVENT (window,
+		    (make_help_event ((WINDOW_ID (window)),
+				      (SHORT1FROMMP (mp1)))));
+	return (MRVOID);
+      }
     case WM_BUTTON1DOWN:
       if (process_button (hwnd, mp1, mp2, 0, BUTTON_EVENT_DOWN))
 	return (MRTRUE);
@@ -3756,3 +4372,21 @@ make_visibility_event (wid_t wid, int shownp)
   (SM_VISIBILITY_EVENT_SHOWNP (message)) = shownp;
   return (message);
 }
+
+static msg_t *
+make_command_event (wid_t wid, USHORT command)
+{
+  msg_t * message = (OS2_create_message (mt_command_event));
+  (SM_COMMAND_EVENT_WID (message)) = wid;
+  (SM_COMMAND_EVENT_COMMAND (message)) = command;
+  return (message);
+}
+
+static msg_t *
+make_help_event (wid_t wid, USHORT command)
+{
+  msg_t * message = (OS2_create_message (mt_help_event));
+  (SM_HELP_EVENT_WID (message)) = wid;
+  (SM_HELP_EVENT_COMMAND (message)) = command;
+  return (message);
+}
diff --git a/v7/src/microcode/os2pm.h b/v7/src/microcode/os2pm.h
index 217f2be34..c37f5360c 100644
--- a/v7/src/microcode/os2pm.h
+++ b/v7/src/microcode/os2pm.h
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: os2pm.h,v 1.7 1995/05/02 20:53:43 cph Exp $
+$Id: os2pm.h,v 1.8 1995/05/16 09:20:15 cph Exp $
 
 Copyright (c) 1994-95 Massachusetts Institute of Technology
 
@@ -141,6 +141,24 @@ typedef struct
 #define SM_VISIBILITY_EVENT_WID(m) (((sm_visibility_event_t *) (m)) -> wid)
 #define SM_VISIBILITY_EVENT_SHOWNP(m)					\
   (((sm_visibility_event_t *) (m)) -> shownp)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  wid_t wid;
+  unsigned short command;
+} sm_command_event_t;
+#define SM_COMMAND_EVENT_WID(m) (((sm_command_event_t *) (m)) -> wid)
+#define SM_COMMAND_EVENT_COMMAND(m) (((sm_command_event_t *) (m)) -> command)
+
+typedef struct
+{
+  DECLARE_MSG_HEADER_FIELDS;
+  wid_t wid;
+  unsigned short command;
+} sm_help_event_t;
+#define SM_HELP_EVENT_WID(m) (((sm_help_event_t *) (m)) -> wid)
+#define SM_HELP_EVENT_COMMAND(m) (((sm_help_event_t *) (m)) -> command)
 
 typedef enum
 {
@@ -187,6 +205,8 @@ extern void OS2_window_set_size (wid_t, unsigned short, unsigned short);
 extern int OS2_window_focusp (wid_t);
 extern void OS2_window_set_state (wid_t, window_state_t);
 extern void OS2_window_set_title (wid_t, const char *);
+extern HWND OS2_window_frame_handle (wid_t);
+extern void OS2_window_update_frame (wid_t, USHORT);
 
 extern psid_t OS2_create_memory_ps (qid_t);
 extern void OS2_destroy_memory_ps (psid_t);
@@ -219,4 +239,16 @@ extern unsigned long OS2_ps_set_bitmap_bits
 extern void OS2_clipboard_write_text (qid_t, const char *);
 extern const char * OS2_clipboard_read_text (qid_t);
 
+extern HWND OS2_menu_create (qid_t, HWND, USHORT, USHORT);
+extern void OS2_menu_destroy (qid_t, HWND);
+extern USHORT OS2_menu_insert_item
+  (qid_t, HWND, USHORT, USHORT, USHORT, USHORT, HWND, PSZ);
+extern USHORT OS2_menu_remove_item (qid_t, HWND, USHORT, USHORT, USHORT);
+extern USHORT OS2_menu_n_items (qid_t, HWND);
+extern USHORT OS2_menu_nth_item_id (qid_t, HWND, USHORT);
+extern USHORT OS2_menu_get_item_attributes
+  (qid_t, HWND, USHORT, USHORT, USHORT);
+extern void OS2_menu_set_item_attributes
+  (qid_t, HWND, USHORT, USHORT, USHORT, USHORT);
+
 #endif /* SCM_OS2PM_H */
diff --git a/v7/src/microcode/pros2pm.c b/v7/src/microcode/pros2pm.c
index 713f96965..145c31272 100644
--- a/v7/src/microcode/pros2pm.c
+++ b/v7/src/microcode/pros2pm.c
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: pros2pm.c,v 1.7 1995/05/02 20:54:09 cph Exp $
+$Id: pros2pm.c,v 1.8 1995/05/16 09:19:55 cph Exp $
 
 Copyright (c) 1994-95 Massachusetts Institute of Technology
 
@@ -111,6 +111,7 @@ dimension_arg (unsigned int arg_number)
 
 #define COORDINATE_ARG SSHORT_ARG
 #define DIMENSION_ARG dimension_arg
+#define HWND_ARG(n) ((HWND) (arg_integer (n)))
 
 void
 OS2_initialize_window_primitives (void)
@@ -299,6 +300,20 @@ DEFINE_PRIMITIVE ("OS2WIN-SET-TITLE", Prim_OS2_window_set_title, 2, 2, 0)
   OS2_window_set_title ((wid_argument (1)), (STRING_ARG (2)));
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
+
+DEFINE_PRIMITIVE ("OS2WIN-FRAME-HANDLE", Prim_OS2_window_frame_handle, 1, 1, 0)
+{
+  PRIMITIVE_HEADER (1);
+  PRIMITIVE_RETURN
+    (long_to_integer (OS2_window_frame_handle (wid_argument (1))));
+}
+
+DEFINE_PRIMITIVE ("OS2WIN-UPDATE-FRAME", Prim_OS2_window_update_frame, 2, 2, 0)
+{
+  PRIMITIVE_HEADER (2);
+  OS2_window_update_frame ((wid_argument (1)), (USHORT_ARG (2)));
+  PRIMITIVE_RETURN (UNSPECIFIC);
+}
 
 DEFINE_PRIMITIVE ("OS2WIN-PS", Prim_OS2_window_ps, 1, 1, 0)
 {
@@ -655,7 +670,7 @@ DEFINE_PRIMITIVE ("OS2PS-SET-BITMAP-BITS", Prim_OS2_ps_set_bitmap_bits, 5, 5, 0)
 			      (STRING_ARG (4)),
 			      (STRING_ARG (5)))));
 }
-
+
 DEFINE_PRIMITIVE ("OS2-CLIPBOARD-WRITE-TEXT", Prim_OS2_clipboard_write_text, 1, 1, 0)
 {
   PRIMITIVE_HEADER (1);
@@ -680,6 +695,87 @@ DEFINE_PRIMITIVE ("OS2-CLIPBOARD-READ-TEXT", Prim_OS2_clipboard_read_text, 0, 0,
   }
 }
 
+DEFINE_PRIMITIVE ("OS2MENU-CREATE", Prim_OS2_menu_create, 3, 3, 0)
+{
+  PRIMITIVE_HEADER (3);
+  PRIMITIVE_RETURN
+    (long_to_integer (OS2_menu_create (pm_qid,
+				       (HWND_ARG (1)),
+				       (USHORT_ARG (2)),
+				       (USHORT_ARG (3)))));
+}
+
+DEFINE_PRIMITIVE ("OS2MENU-DESTROY", Prim_OS2_menu_destroy, 1, 1, 0)
+{
+  PRIMITIVE_HEADER (1);
+  OS2_menu_destroy (pm_qid, (HWND_ARG (1)));
+  PRIMITIVE_RETURN (UNSPECIFIC);
+}
+
+DEFINE_PRIMITIVE ("OS2MENU-INSERT-ITEM", Prim_OS2_menu_insert_item, 7, 7, 0)
+{
+  PRIMITIVE_HEADER (7);
+  PRIMITIVE_RETURN
+    (long_to_integer (OS2_menu_insert_item (pm_qid,
+					    (HWND_ARG (1)),
+					    (USHORT_ARG (2)),
+					    (USHORT_ARG (3)),
+					    (USHORT_ARG (4)),
+					    (USHORT_ARG (5)),
+					    (HWND_ARG (6)),
+					    (STRING_ARG (7)))));
+}
+
+DEFINE_PRIMITIVE ("OS2MENU-REMOVE-ITEM", Prim_OS2_menu_remove_item, 4, 4, 0)
+{
+  PRIMITIVE_HEADER (4);
+  PRIMITIVE_RETURN
+    (long_to_integer (OS2_menu_remove_item (pm_qid,
+					    (HWND_ARG (1)),
+					    (USHORT_ARG (2)),
+					    (BOOLEAN_ARG (3)),
+					    (BOOLEAN_ARG (4)))));
+}
+
+DEFINE_PRIMITIVE ("OS2MENU-N-ITEMS", Prim_OS2_menu_n_items, 1, 1, 0)
+{
+  PRIMITIVE_HEADER (1);
+  PRIMITIVE_RETURN
+    (long_to_integer (OS2_menu_n_items (pm_qid, (HWND_ARG (1)))));
+}
+
+DEFINE_PRIMITIVE ("OS2MENU-NTH-ITEM-ID", Prim_OS2_menu_nth_item_id, 2, 2, 0)
+{
+  PRIMITIVE_HEADER (2);
+  PRIMITIVE_RETURN
+    (long_to_integer (OS2_menu_nth_item_id (pm_qid,
+					    (HWND_ARG (1)),
+					    (USHORT_ARG (2)))));
+}
+
+DEFINE_PRIMITIVE ("OS2MENU-GET-ITEM-ATTRIBUTES", Prim_OS2_menu_get_item_attributes, 4, 4, 0)
+{
+  PRIMITIVE_HEADER (4);
+  PRIMITIVE_RETURN
+    (long_to_integer (OS2_menu_get_item_attributes (pm_qid,
+						    (HWND_ARG (1)),
+						    (USHORT_ARG (2)),
+						    (BOOLEAN_ARG (3)),
+						    (USHORT_ARG (4)))));
+}
+
+DEFINE_PRIMITIVE ("OS2MENU-SET-ITEM-ATTRIBUTES", Prim_OS2_menu_set_item_attributes, 5, 5, 0)
+{
+  PRIMITIVE_HEADER (5);
+  OS2_menu_set_item_attributes (pm_qid,
+				(HWND_ARG (1)),
+				(USHORT_ARG (2)),
+				(BOOLEAN_ARG (3)),
+				(USHORT_ARG (4)),
+				(USHORT_ARG (5)));
+  PRIMITIVE_RETURN (UNSPECIFIC);
+}
+
 DEFINE_PRIMITIVE ("OS2WIN-OPEN-EVENT-QID", Prim_OS2_window_open_event_qid, 0, 0, 0)
 {
   qid_t local;
@@ -704,6 +800,8 @@ DEFINE_PRIMITIVE ("OS2WIN-CLOSE-EVENT-QID", Prim_OS2_window_close_event_qid, 1,
 #define ET_PAINT	4
 #define ET_RESIZE	5
 #define ET_VISIBILITY	6
+#define ET_COMMAND	7
+#define ET_HELP		8
 
 #define CVT_UNSIGNED(n, v)						\
   VECTOR_SET (result, n, (LONG_TO_UNSIGNED_FIXNUM (v)))
@@ -788,6 +886,22 @@ DEFINE_PRIMITIVE ("OS2WIN-GET-EVENT", Prim_OS2_window_get_event, 2, 2, 0)
 	      CVT_BOOLEAN  (2, (SM_VISIBILITY_EVENT_SHOWNP (message)));
 	      break;
 	    }
+	  case mt_command_event:
+	    {
+	      result = (allocate_marked_vector (TC_VECTOR, 3, 0));
+	      CVT_UNSIGNED (0, ET_COMMAND);
+	      CVT_UNSIGNED (1, (SM_COMMAND_EVENT_WID (message)));
+	      CVT_UNSIGNED  (2, (SM_COMMAND_EVENT_COMMAND (message)));
+	      break;
+	    }
+	  case mt_help_event:
+	    {
+	      result = (allocate_marked_vector (TC_VECTOR, 3, 0));
+	      CVT_UNSIGNED (0, ET_HELP);
+	      CVT_UNSIGNED (1, (SM_HELP_EVENT_WID (message)));
+	      CVT_UNSIGNED  (2, (SM_HELP_EVENT_COMMAND (message)));
+	      break;
+	    }
 	  default:
 	    OS2_destroy_message (message);
 	    OS2_error_anonymous ();
diff --git a/v7/src/runtime/os2winp.scm b/v7/src/runtime/os2winp.scm
index 08d256a9f..be4496f4b 100644
--- a/v7/src/runtime/os2winp.scm
+++ b/v7/src/runtime/os2winp.scm
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: os2winp.scm,v 1.6 1995/05/02 20:58:41 cph Exp $
+$Id: os2winp.scm,v 1.7 1995/05/16 09:21:01 cph Exp $
 
 Copyright (c) 1995 Massachusetts Institute of Technology
 
@@ -40,6 +40,14 @@ MIT in each case. |#
 (define-primitives
   (os2-clipboard-read-text 0)
   (os2-clipboard-write-text 1)
+  (os2menu-create 3)
+  (os2menu-destroy 1)
+  (os2menu-get-item-attributes 4)
+  (os2menu-insert-item 7)
+  (os2menu-n-items 1)
+  (os2menu-nth-item 2)
+  (os2menu-remove-item 4)
+  (os2menu-set-item-attributes 5)
   (os2pm-synchronize 0)
   (os2ps-bitblt 6)
   (os2ps-clear 5)
@@ -76,6 +84,7 @@ MIT in each case. |#
   (os2win-desktop-width 0)
   (os2win-event-ready? 2)
   (os2win-focus? 1)
+  (os2win-frame-handle 1)
   (os2win-get-event 2)
   (os2win-get-frame-size 1)
   (os2win-get-pos 1)
@@ -94,7 +103,7 @@ MIT in each case. |#
   (os2win-shape-cursor 4)
   (os2win-show 2)
   (os2win-show-cursor 2)
-  )
+  (os2win-update-frame 2))
 
 (define-integrable (event-type event) (vector-ref event 0))
 (define-integrable (event-wid event) (vector-ref event 1))
@@ -119,8 +128,10 @@ MIT in each case. |#
 (define-event paint      4 xl xh yl yh)
 (define-event resize     5 width height)
 (define-event visibility 6 shown?)
+(define-event command    7 code)
+(define-event help       8 code)
 
-(define-integrable number-of-event-types 7)
+(define-integrable number-of-event-types 9)
 
 (define-integrable button-event-type:down 0)
 (define-integrable button-event-type:up 1)
@@ -402,4 +413,78 @@ MIT in each case. |#
 (define-integrable BBO_AND           1)
 (define-integrable BBO_IGNORE        2)
 (define-integrable BBO_PAL_COLORS    4)
-(define-integrable BBO_NO_COLOR_INFO 8)
\ No newline at end of file
+(define-integrable BBO_NO_COLOR_INFO 8)
+
+;; Menu item positions:
+(define-integrable MIT_END                    #xFFFF)
+(define-integrable MIT_NONE                   #xFFFF)
+(define-integrable MIT_MEMERROR               #xFFFF)
+(define-integrable MIT_ERROR                  #xFFFF)
+(define-integrable MIT_FIRST                  #xFFFE)
+(define-integrable MIT_LAST                   #xFFFD)
+
+;; Menu item styles:
+(define-integrable MIS_TEXT                   #x0001)
+(define-integrable MIS_BITMAP                 #x0002)
+(define-integrable MIS_SEPARATOR              #x0004)
+(define-integrable MIS_OWNERDRAW              #x0008)
+(define-integrable MIS_SUBMENU                #x0010)
+(define-integrable MIS_MULTMENU               #x0020) ;multiple choice submenu
+(define-integrable MIS_SYSCOMMAND             #x0040)
+(define-integrable MIS_HELP                   #x0080)
+(define-integrable MIS_STATIC                 #x0100)
+(define-integrable MIS_BUTTONSEPARATOR        #x0200)
+(define-integrable MIS_BREAK                  #x0400)
+(define-integrable MIS_BREAKSEPARATOR         #x0800)
+(define-integrable MIS_GROUP                  #x1000) ;multiple choice group
+;; In multiple choice submenus a style of 'single' denotes the item is
+;; a radiobutton.  Absence of this style defaults the item to a
+;; checkbox.
+(define-integrable MIS_SINGLE                 #x2000)
+
+;; Menu item attributes:
+(define-integrable MIA_NODISMISS              #x0020)
+(define-integrable MIA_FRAMED                 #x1000)
+(define-integrable MIA_CHECKED                #x2000)
+(define-integrable MIA_DISABLED               #x4000)
+(define-integrable MIA_HILITED                #x8000)
+
+(define-integrable FID_SYSMENU                #x8002)
+(define-integrable FID_TITLEBAR               #x8003)
+(define-integrable FID_MINMAX                 #x8004)
+(define-integrable FID_MENU                   #x8005)
+(define-integrable FID_VERTSCROLL             #x8006)
+(define-integrable FID_HORZSCROLL             #x8007)
+(define-integrable FID_CLIENT                 #x8008)
+
+;; Menu control styles */
+(define-integrable MS_ACTIONBAR               #x0001)
+(define-integrable MS_TITLEBUTTON             #x0002)
+(define-integrable MS_VERTICALFLIP            #x0004)
+(define-integrable MS_CONDITIONALCASCADE      #x0040)
+
+;; Frame window styles:
+(define-integrable FCF_TITLEBAR               #x00000001)
+(define-integrable FCF_SYSMENU                #x00000002)
+(define-integrable FCF_MENU                   #x00000004)
+(define-integrable FCF_SIZEBORDER             #x00000008)
+(define-integrable FCF_MINBUTTON              #x00000010)
+(define-integrable FCF_MAXBUTTON              #x00000020)
+(define-integrable FCF_MINMAX                 #x00000030)
+(define-integrable FCF_VERTSCROLL             #x00000040)
+(define-integrable FCF_HORZSCROLL             #x00000080)
+(define-integrable FCF_DLGBORDER              #x00000100)
+(define-integrable FCF_BORDER                 #x00000200)
+(define-integrable FCF_SHELLPOSITION          #x00000400)
+(define-integrable FCF_TASKLIST               #x00000800)
+(define-integrable FCF_NOBYTEALIGN            #x00001000)
+(define-integrable FCF_NOMOVEWITHOWNER        #x00002000)
+(define-integrable FCF_ICON                   #x00004000)
+(define-integrable FCF_ACCELTABLE             #x00008000)
+(define-integrable FCF_SYSMODAL               #x00010000)
+(define-integrable FCF_SCREENALIGN            #x00020000)
+(define-integrable FCF_MOUSEALIGN             #x00040000)
+(define-integrable FCF_HIDEBUTTON             #x01000000)
+(define-integrable FCF_HIDEMAX                #x01000020)
+(define-integrable FCF_AUTOICON               #x40000000)
+(define-integrable FCF_STANDARD               #x0000CC3F)
\ No newline at end of file
diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg
index 5d05b053e..6388aca6d 100644
--- a/v7/src/runtime/runtime.pkg
+++ b/v7/src/runtime/runtime.pkg
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: runtime.pkg,v 14.256 1995/05/03 07:34:31 cph Exp $
+$Id: runtime.pkg,v 14.257 1995/05/16 09:20:48 cph Exp $
 
 Copyright (c) 1988-95 Massachusetts Institute of Technology
 
@@ -2462,6 +2462,7 @@ MIT in each case. |#
 	  caps_width			;pels
 	  caps_width_in_chars
 	  caps_window_byte_alignment
+	  command-event/code
 	  cursor_flash
 	  cursor_frame
 	  cursor_halftone
@@ -2469,12 +2470,45 @@ MIT in each case. |#
 	  event-type
 	  event-type:button
 	  event-type:close
+	  event-type:command
 	  event-type:focus
+	  event-type:help
 	  event-type:key
 	  event-type:paint
 	  event-type:resize
 	  event-type:visibility
 	  event-wid
+	  fcf_acceltable
+	  fcf_autoicon
+	  fcf_border
+	  fcf_dlgborder
+	  fcf_hidebutton
+	  fcf_hidemax
+	  fcf_horzscroll
+	  fcf_icon
+	  fcf_maxbutton
+	  fcf_menu
+	  fcf_minbutton
+	  fcf_minmax
+	  fcf_mousealign
+	  fcf_nobytealign
+	  fcf_nomovewithowner
+	  fcf_screenalign
+	  fcf_shellposition
+	  fcf_sizeborder
+	  fcf_standard
+	  fcf_sysmenu
+	  fcf_sysmodal
+	  fcf_tasklist
+	  fcf_titlebar
+	  fcf_vertscroll
+	  fid_client
+	  fid_horzscroll
+	  fid_menu
+	  fid_minmax
+	  fid_sysmenu
+	  fid_titlebar
+	  fid_vertscroll
 	  fm_and
 	  fm_default
 	  fm_invert
@@ -2496,6 +2530,7 @@ MIT in each case. |#
 	  font-metrics/descender
 	  font-metrics/height
 	  font-metrics/width
+	  help-event/code
 	  kc_alt
 	  kc_char
 	  kc_composite
@@ -2524,7 +2559,44 @@ MIT in each case. |#
 	  linetype_longdash
 	  linetype_shortdash
 	  linetype_solid
+	  mia_checked
+	  mia_disabled
+	  mia_framed
+	  mia_hilited
+	  mia_nodismiss
+	  mis_bitmap
+	  mis_break
+	  mis_breakseparator
+	  mis_buttonseparator
+	  mis_group
+	  mis_help
+	  mis_multmenu
+	  mis_ownerdraw
+	  mis_separator
+	  mis_single
+	  mis_static
+	  mis_submenu
+	  mis_syscommand
+	  mis_text
+	  mit_end
+	  mit_error
+	  mit_first
+	  mit_last
+	  mit_memerror
+	  mit_none
+	  ms_actionbar
+	  ms_conditionalcascade
+	  ms_titlebutton
+	  ms_verticalflip
 	  number-of-event-types
+	  os2menu-create
+	  os2menu-destroy
+	  os2menu-get-item-attributes
+	  os2menu-insert-item
+	  os2menu-n-items
+	  os2menu-nth-item
+	  os2menu-remove-item
+	  os2menu-set-item-attributes
 	  os2pm-synchronize
 	  os2ps-bitblt
 	  os2ps-clear
@@ -2561,6 +2633,7 @@ MIT in each case. |#
 	  os2win-desktop-width
 	  os2win-event-ready?
 	  os2win-focus?
+	  os2win-frame-handle
 	  os2win-get-event
 	  os2win-get-frame-size
 	  os2win-get-pos
@@ -2579,6 +2652,7 @@ MIT in each case. |#
 	  os2win-shape-cursor
 	  os2win-show
 	  os2win-show-cursor
+	  os2win-update-frame
 	  paint-event/xh
 	  paint-event/xl
 	  paint-event/yh
@@ -2680,7 +2754,8 @@ MIT in each case. |#
 	  ws_parentclip
 	  ws_savebits
 	  ws_syncpaint
-	  ws_visible))
+	  ws_visible
+	  ))
 
 (define-package (runtime state-space)
   (files "wind")
diff --git a/v8/src/runtime/runtime.pkg b/v8/src/runtime/runtime.pkg
index 5d05b053e..6388aca6d 100644
--- a/v8/src/runtime/runtime.pkg
+++ b/v8/src/runtime/runtime.pkg
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: runtime.pkg,v 14.256 1995/05/03 07:34:31 cph Exp $
+$Id: runtime.pkg,v 14.257 1995/05/16 09:20:48 cph Exp $
 
 Copyright (c) 1988-95 Massachusetts Institute of Technology
 
@@ -2462,6 +2462,7 @@ MIT in each case. |#
 	  caps_width			;pels
 	  caps_width_in_chars
 	  caps_window_byte_alignment
+	  command-event/code
 	  cursor_flash
 	  cursor_frame
 	  cursor_halftone
@@ -2469,12 +2470,45 @@ MIT in each case. |#
 	  event-type
 	  event-type:button
 	  event-type:close
+	  event-type:command
 	  event-type:focus
+	  event-type:help
 	  event-type:key
 	  event-type:paint
 	  event-type:resize
 	  event-type:visibility
 	  event-wid
+	  fcf_acceltable
+	  fcf_autoicon
+	  fcf_border
+	  fcf_dlgborder
+	  fcf_hidebutton
+	  fcf_hidemax
+	  fcf_horzscroll
+	  fcf_icon
+	  fcf_maxbutton
+	  fcf_menu
+	  fcf_minbutton
+	  fcf_minmax
+	  fcf_mousealign
+	  fcf_nobytealign
+	  fcf_nomovewithowner
+	  fcf_screenalign
+	  fcf_shellposition
+	  fcf_sizeborder
+	  fcf_standard
+	  fcf_sysmenu
+	  fcf_sysmodal
+	  fcf_tasklist
+	  fcf_titlebar
+	  fcf_vertscroll
+	  fid_client
+	  fid_horzscroll
+	  fid_menu
+	  fid_minmax
+	  fid_sysmenu
+	  fid_titlebar
+	  fid_vertscroll
 	  fm_and
 	  fm_default
 	  fm_invert
@@ -2496,6 +2530,7 @@ MIT in each case. |#
 	  font-metrics/descender
 	  font-metrics/height
 	  font-metrics/width
+	  help-event/code
 	  kc_alt
 	  kc_char
 	  kc_composite
@@ -2524,7 +2559,44 @@ MIT in each case. |#
 	  linetype_longdash
 	  linetype_shortdash
 	  linetype_solid
+	  mia_checked
+	  mia_disabled
+	  mia_framed
+	  mia_hilited
+	  mia_nodismiss
+	  mis_bitmap
+	  mis_break
+	  mis_breakseparator
+	  mis_buttonseparator
+	  mis_group
+	  mis_help
+	  mis_multmenu
+	  mis_ownerdraw
+	  mis_separator
+	  mis_single
+	  mis_static
+	  mis_submenu
+	  mis_syscommand
+	  mis_text
+	  mit_end
+	  mit_error
+	  mit_first
+	  mit_last
+	  mit_memerror
+	  mit_none
+	  ms_actionbar
+	  ms_conditionalcascade
+	  ms_titlebutton
+	  ms_verticalflip
 	  number-of-event-types
+	  os2menu-create
+	  os2menu-destroy
+	  os2menu-get-item-attributes
+	  os2menu-insert-item
+	  os2menu-n-items
+	  os2menu-nth-item
+	  os2menu-remove-item
+	  os2menu-set-item-attributes
 	  os2pm-synchronize
 	  os2ps-bitblt
 	  os2ps-clear
@@ -2561,6 +2633,7 @@ MIT in each case. |#
 	  os2win-desktop-width
 	  os2win-event-ready?
 	  os2win-focus?
+	  os2win-frame-handle
 	  os2win-get-event
 	  os2win-get-frame-size
 	  os2win-get-pos
@@ -2579,6 +2652,7 @@ MIT in each case. |#
 	  os2win-shape-cursor
 	  os2win-show
 	  os2win-show-cursor
+	  os2win-update-frame
 	  paint-event/xh
 	  paint-event/xl
 	  paint-event/yh
@@ -2680,7 +2754,8 @@ MIT in each case. |#
 	  ws_parentclip
 	  ws_savebits
 	  ws_syncpaint
-	  ws_visible))
+	  ws_visible
+	  ))
 
 (define-package (runtime state-space)
   (files "wind")