// updates: Jun 20 1993 (AB) : Save/Load Menu Template functions
// Jul 10 1993 (AB) : Pop-up menus (Settings)
// Aug 04 1993 (AB) : Drag and Drop support
// Oct 04 1993 (GLS): UCS_ styles
// Feb 01 1994 (GLS): More Drag and Drop support
// ===> Build Version 2.01
// Mar 07 1995 (MAM): Fixed drag/drop of MIS_SPACER items
// Mar 07 1995 (MAM): Added new bitmap for dragging of spacers (diff from no-bmp items)
// Mar 07 1995 (MAM): Don't draw edges of adjacent spacer items
// Mar 15 1995 (MAM): Delete bitmap loaded for drag/drop (plug possible memory leak)
// Mar 15 1995 (MAM): Fix truncated text on customization dialog
// Mar 15 1995 (MAM): Added OK/Cancel buttons to customzation dlg, remove confirm box
// Mar 15 1995 (MAM): Clarified some messages (NLS_xxxx in ucmenus.rc)
// Mar 21 1995 (MAM): Fixed some missing notify messages when items drag/dropped
// -- e.g. only UCN_ADDEDITEM was generated, no UCN_DELETEDITEM
// Mar 23 1995 (MAM): Fixed many problems with submenus:
// -- was unable to drag/drop reoder items in a submenu
// -- drag from a submenu left some junk pixels when menu dismissed
// -- drag from a submenu did not delete source item (e.g. copied)
// -- context menu left dark grey line on main menu
// -- missing many UCN_* notify messages when submenus customized
// -- mouse-move notify messages gave incorrect item IDs
// -- style changes did not change already-opened submenus. changing
// text of a submenu item did not resize the submenu (autoresize style)
// -- SUBMENU placeholders cannot be MIA_NODISMISS, each individual item of
// the submenu to be non-dismissable must have MIA_NODISMISS attribute.
// (This is different than std PM menus, but necessary to prevent
// dismiss of submenus during drag/drop operations).
// Mar 23 1995 (MAM): UCMenuIdFromCoord() off by one pixel on right/top edges
// Mar 23 1995 (MAM): Made checkmark (thick brdr) visible on hilited items (3-pel thick bdr)
// Mar 24 1995 (MAM): Remove ability to use MIS_BREAK on submenus
// -- PM bug gives wrong coordinates on MM_QUERYITEMRECT for submenus w/BREAK
// Mar 24 1995 (MAM): Updated version to "2.02" (ucmenus.h)
// ----------------------------- Version 2.02 Build (DevCon CD, Volumne 7) ----------------------------------------
// Mar 27 1995 (MAM): Dismiss submenu before sending WM_CONTROL msg to owner (non-NODISMISS items).
// Mar 29 1995 (MAM): Dismiss submenu before deleting parent menu item.
// Mar 29 1995 (MAM): Dismiss submenu before processing WM_DESTROY.
// Mar 29 1995 (MAM): Remove MIA_NODISMISS attribute when copy/moving parent item of a submenu
// ----------------------------- Version 2.03 Build (Compuserve) ----------------------------------------
// Apr 04 1995 (MAM): Improved UCN_MOUSEMOVE control messages:
// - Only get message when ID changes instead of every movement
// - Always get final msg with ID=0 when mouse leaves menu window
// Apr 05 1995 (MAM): Replace (HWND)0 with NULLHANDLE for better portability.
// Apr 05 1995 (MAM): Fix prototype of UCMenuGetVersion() and include <stddef.h> (Thanks Bill K.)
// Apr 10 1995 (MAM): Use WinDrawText() to measure space needed for text strings. GpiQueryTextBox() not always accurate.
// Apr 12 1995 (MAM): Add support for bubble-help
// - UCS_BUBBLEHELP style flag
// - UCN_QRYBUBBLEHELP WM_CONTROL message to application
// update passed structure w/string (freed by UCmenus when done --
// app must allocate string with UCMenuAlloc()).
// - UCMENU_SETBUBBLETIMERS:
// mp1 = (LONG) new delay in msec, maximum of 65000 (65 seconds)
// mp2 = (LONG) new read-time in msec
// returns 0 (reserved)
// App must supply initial delay in UCMINFO data
// ---NOTE--- Need to recompile apps to get larger UCMINFO structure size
// Apr 13 1995 (MAM): Remove code to un-hilight current item when context menu invoked
// (did not work, no longer needed anyway)
// Apr 13 1995 (MAM): Add support for application-supplied context menu:
// - UCN_QRYCONTEXTHWND message
// mp1 = (UCMenu ID, UCN_QRYCONTEXTHWND)
// mp2 = ptr to MENUITEM structure (usID zero if not over an item)
// return HWND of application popup menu, or NULL if none
// - Owner of UCMenu control will get UCN_CMITEM ctrl messages (just like built-in menu)
// Apr 21 1995 (MAM): Fix: always register UCMenu window class in case DLL is freed
// and reloaded by the same process (otherwise class points to window
// proc in old freed DLL instance).
// Apr 21 1995 (MAM): Added UCMINRES.RES to build process to create minimal-resource .RES
// file. For use by apps that don't use the UCMenus built-in context
// menu or customization dialogs.
// Apr 24 1995 (MAM): Fix possible trap in UCMenuSetBmpBgColor() due to uninitialized ptr
// Apr 24 1995 (MAM): Changed all "(TYPE)0" null pointers to "NULL" or "NULLHANDLE" as appropriate
// Apr 24 1995 (MAM): Added UCMenuStrdup() to API set (useful during UCN_QRYBUBBLEHELP).
// Apr 24 1995 (MAM): Changed internal use of UCMenuFree() to MyFree() -- eliminate func call in non-debug mode
// Apr 25 1995 (MAM): Code cleanup, removed lots of unused vars, etc.
// Apr 26 1995 (MAM): Don't process MM_DELETEITEM for submenu item in main menu proc.
// Apr 27 1995 (MAM): Added UCMENU_ACTIVECHG message -- reqd for apps using UCN_BUBBLEHELP style
// mp1 = (SHORT1) TRUE -- app is being activated
// FALSE-- app is being deactivated
// (SHORT2) Reserved
// mp2 = Reserved
// Apr 27 1995 (MAM): Dismiss open submenus when app becomes inactive
// May 01 1995 (MAM): Fixed drawing of overall menu frame when !UCN_FRAMED
// May 01 1995 (MAM): Chg meaning of UCS_FORCESIZE (just sets size of bitmap, item still sizes to larger of bitmap or text)
// (e.g. text is NEVER clipped). Also FORCESIZE can now scale
// the bitmap up or down in size (instead of just down).
// May 02 1995 (MAM): Added UCMENU_QUERYRECT message to get position of a menu item in UCMenu window
// May 02 1995 (MAM): Added UCMENU_DISABLEUPDATE to improve performance when app inserts/deletes lots of items
// mp1 = (BOOL) TRUE -- do not update menu
// FALSE-- update when needed
// mp2 = reserved
// Application should always send UCMENUS_UPDATE after re-enabling update.
// Initial state is disabled=FALSE (e.g. update on every insert/delete, etc).
// May 08 1995 (MAM): Chngd UCMENU_QUERYSIZE to return real size for CMS_MATRIX style (instead of size based in num of row/cols requested)
// May 09 1995 (MAM): Added UCMenuItemDup() and UCMenuItemFree() functions to copy/free UCMITEM structures
// May 10 1995 (MAM): Added UCN_CHANGEDITEM msg when MM_SETITEM or MM_SETITEMHANDLE is received (notify of change to item, extent of change is unknown)
// May 15 1995 (MAM): Fixed memory leak by freeing pszParameters when item is deleted (MM_DELETEITEM processing)
// May 24 1995 (MAM): Use UCMString2Int() to better distinguish btw bitmap resource numbers and file names (previous code would take "123G.BMP" as resource ID 123).
// May 24 1995 (MAM): Store binary form of bitmap ID in upper word of ulFlags in UCMITEM structure
// May 24 1995 (MAM): UCMI_FROMBMPFILE in ulFlags is set if pszBmp[] is a filename (even if the file was not found and a default resource bitmap is being used instead)
// May 24 1995 (MAM): pszDefaultBitmap in UCMINFO can now be a resource ID (string form) or a file name
// May 25 1995 (MAM): Fix bug in algorithm for choosing best bitmap when .BMP file contains array of bitmaps
// June 03 1995 (MAM): Fix test of uninitialized variable in UCMenuNew().
// June 06 1995 (MAM): Enhanced UCMenuLoadBitmap() to load icons from non-BMP files using WinLoadFileIcon. Makes it easy to show WPS representation of any file.
// -- Commented out because of black-background problem (requires more code to solve).
// June 06 1995 (MAM): If toolbar is empty set size to size of a normal PM menu.
// June 13 1995 (MAM): Changed UCMENUS.RCH to UCMLOCAL.H (some build systems need .H extension for all header files)
// June 13 1995 (MAM): Fixed trap/hang if application had its own drag/drop implementation in addition to the UCMenu control
// (dragging over the UCMenu from a same-process, non-UCMenu window would trap/hang due to bad assumption in DM_DRAGOVER processing)
// July 20 1995 (MAM): Changed background color mapping of bitmaps:
// - Added new style "UCS_CHNGBMPBG_AUTO" to use lower-leftmost pixel of bitmap to determine bitmap background color (BgBmp of UCMINFO will be ignored)
// - Improved UCMenuSetBmpBgColor() to not assume 256 color bitmaps (less memory allocated and better performance for 2 or 16-color bitmaps)
// - Bitmap backgrounds are now mapped (only) when bitmaps are loaded (not at WM_DRAWITEM time)
// - All bitmaps are reloaded (and color mapped) when the menu background color is changed (fixes bug where multiple color changes would lose colors in the bitmaps)
// - Removed lCurBmpBgColor from UCMITEM structure (no longer needed since colors are mapped only when bitmaps are loaded)
// July 20 1995 (MAM): Removed use of BitBlt to shift image of items during hilight/unhilight (BltBit method leaves stray pixels in many cases when item is partially obscured by another window).
// Now just fully draw the item every time. Less efficient but more robust.
// July 21 1995 (MAM): Fixed spurious display of bubble help when pointer passes through toolbar (check for ptr in toolbar window during WM_TIMER (TIMER_BUBBLE) processing)
// July 21 1995 (MAM): Reduced timer for detecting ptr leaving toolbar to 1/2 second
// July 21 1995 (MAM): Fixed visual corruption when bubble is removed if underlaying window changed (remove WS_SAVEBITS style)
// July 21 1995 (MAM): Fixed visual corruption when bubble is quickly hidden/shown (get/dispatch all WM_PAINT messages between HIDE/SHOW so underlaying windows are sure to paint)
// July 21 1995 (MAM): Added several HWNDs to UCMDATA to elimiate many WinQueryWindow() calls.
// July 21 1995 (MAM): Added UCMUI #define to create smaller module with no user-customization or context menu functions.
// ----------------------------- Version 2.1 Build ----------------------------------------
// Aug 08 1995 (MAM): Activate frame on button 2 down (prevent context menu on inactive frame)
// Aug 10 1995 (MAM): Fix render of larger fonts by getting new PS in WM_DRAWITEM instead of using PS supplied by PM
// Aug 16 1995 (MAM): Removed MIS_TEXT bit flag from MIS_SPACER definition -- OS/2 2.1 does not send WM_MEASUREITEM messages if MIS_TEXT flag is set
// Aug 29 1995 (MAM): Fixed double-painting of toolbar when sized after creationg (changed WM_SIZE from Post to Send)
// Aug 29 1995 (MAM): Comment-out UCMENUS_DEBUG for memory allocate
// Aug 30 1995 (MAM): Fix memory leak from unclosed device context (WM_DESTROY processing)
// Sept 1 1995 (MAM): Fix memory leak from unfreed drag/drop transfer shared memory
// Sept 18 1995 (MAM): Fixed UCN_SIZE notification logic to only send size change notification when dimension of interest changes (e.g. vert dim of a HORZ menu)
// Sept 21 1995 (MAM): Fixed painting of disabled menu items (render our own half-tone).
// Sept 28 1995 (MAM): Added CMS_MATRIX_VERT and CMS_MATRIX_HORZ styles for scrollable matrix menus
// ----------------------------- Version 2.11 Build ----------------------------------------