Release 0.5
Sun Jan 2 12:38:53 1994 David Metcalfe <david@prism.demon.co.uk>
* [windows/class.c]
Implemented GetClassName and GetClassInfo.
* [windows/caret.c]
Various improvements to text caret code.
Fri Dec 31 15:22:22 1993 John Brezak <brezak@apollo.hp.com>
* [misc/comm.c]
Patches to work with NetBSD.
Thu Dec 30 12:11:55 1993 John Richardson <jrichard@cs.uml.edu>
* [objects/bitblt.c] Added StretchBlt().
Tue Jan 4 05:22:07 1994 julliard@di.epfl.ch (Alexandre Julliard)
* [misc/user.c]
Added creation of system message queue.
* [objects/bitmap.c] [objects/dcvalues.c] [windows/dc.c]
Added DC size fields into DC structure.
* [objects/clipping.c]
Bug fix in CLIPPING_IntersectRect().
* [windows/class.c]
Allocate a DCE instead of a DC for CS_CLASSDC classes.
* [windows/clipping.c]
Fixed GetUpdateRect() and GetUpdateRgn() to clip to the client area.
* [windows/dce.c]
Implemented GetDCEx() and GetWindowDC().
* [windows/defwnd.c]
Implemented WM_WINDOWPOSCHANGED handling.
* [windows/event.c]
Preliminary support for Xlib event handling instead of Xt callbacks.
Changed MSG_AddMsg() calls to hardware_event() or PostMessage().
* [windows/message.c]
Preliminary support for multiple message queues.
Implemented hardware_event() to store messages into the system queue.
Implemented Get/SetTaskQueue().
Better WM_PAINT and WM_TIMER handling.
Changes to use Xlib instead of Xt for events.
* [windows/painting.c]
Use GetDCEx() to retrieve the DC, to get a correct visible region.
* [windows/timer.c]
Moved the timer procedure callback into DispatchMessage().
Changed implementation to get rid of Xt timeouts. Timer checking
is now done inside GetMessage().
* [windows/win.c]
Allocate a DCE instead of a DC for CS_OWNDC windows.
Replaced Xt calls with Xlib calls.
Moved window positioning functions into windows/winpos.c
* [windows/winpos.c] (New file)
Rewritten most of the window positioning functions.
Implemented SetWindowPos() and MapWindowPoints().
Jan 3, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [if1632/user.spec]
Bad arguments description for function SetDlgItemText.
* [objects/text.c]
Function DrawText now handle DT_CALCRECT request.
* [misc/message.c]
Message boxes now use DrawText with DT_CALCRECT.
* [windows/graphics.c]
Bug fix in function FrameRect, (it was using PEN instead of BRUSH).
* [windows/win.c]
Bug fix for flags in function ShowWindow.
More accurate WM_SIZE generated by function ShowWindow.
* [controls/listbox.c]
More code for LBS_MULTIPLESEL.
More code for LBS_MULTICOLUMN.
* [include/windows.h]
Bad define for MF_SEPARATOR.
* [controls/menu.c]
New functions: PopMenuWndProc() with 'glues',
CreatePopupMenu(), AppendMenu(), InsertMenu(), RemoveMenu(),
DeleteMenu(), ModifyMenu(), TrackPopupMenu().
Code in stubs: CreateMenu(), DestroyMenu().
Sat Jan 1 10:22:43 1994 Bob Amstadt (bob@pooh)
* loader/wine.c: Added support for relocation types 5 and 6.
Mon Dec 27 11:06:03 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [misc/comm.c]
new functions: BuildCommDCB(), OpenComm(), CloseComm(),
SetCommBreak(), ClearCommBreak(), EscapeCommFunction(), FlushComm(),
GetCommError(), SetCommEventMask(), GetCommEventMask(),
SetCommState(), GetCommState(), TransmitCommChar(), ReadComm(),
WriteComm().
Wed Dec 22 13:00:15 1993 David Metcalfe <david@prism.demon.co.uk>
* [windows/caret.c]
Implemented text caret functions.
Tue Dec 21 06:13:58 1993 julliard@di.epfl.ch (Alexandre Julliard)
* [loader/wine.c]
Bug fix in LoadImage().
* [objects/bitblt.c] [objects/clipping.c] [objects/text.c]
[windows/dc.c] [windows/dce.c] [windows/graphics.c]
Modified graphics calls to take into account the DC origin.
* [windows/defwnd.c]
Added preliminary WM_NCCALCSIZE handling.
* [windows/event.c]
Send WM_NCCALCSIZE message on resize event.
* [windows/win.c]
Send WM_NCCALCSIZE message in CreateWindow().
Realize widgets at creation time (should prevent problems with
unrealized widgets).
Dec 19, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [controls/static.c]
Send mouse & keyboard message received to its parent.
* [controls/scroll.c]
Send keyboard message received to its parent.
* [controls/listbox.c]
Add Navigation keys .
ListBox now use VSCROLL & HSCROLL instead of children.
Alpha version of LBS_MULTIPLESEL.
Alpha version of LBS_MULTICOLUMN.
* [controls/combo.c]
Add Navigation keys on closed ComboBox.
Remove useless 'COMBOBOX_CreateComboBox' function.
Mon Dec 19 20:39:34 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [loader/wine.
LoadImage() modified to use FindFile().
* [misc/file.c]
SetErrorMode added
* [misc/dos_fs.c]
bug fixes.
Dec 13, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [memory/global.c]
bug fix in GlobalGetFreeSegment : good ptr in 'g_prev'.
* [sysres.dll]
preliminary version of a 'glass of wine' bitmap
* [windows/event.c]
New function 'GetCapture'.
* [controls/scroll.c]
Remove useless 'SCROLLBAR_CreateScrollBar' function.
* [controls/listbox.c]
Remove useless 'LISTBOX_CreateListBox' function.
Mon Dec 13 13:51:00 1993 David Metcalfe <david@prism.demon.co.uk>
* [objects/font.c]
Corrected bugs in GetCharWidth().
* [windows/event.c]
Modified EVENT_key to send Windows virtual key codes for
WM_KEYDOWN and WM_KEYUP messages, and a WM_CHAR message
for printable characters.
Wed Dec 08 19:20:00 1993 Karl Guenter Wuensch (hn324wu@unidui.uni-duisburg.de)
* [windows/graphics.c]
Added Polyline and Polygon
Mon Dec 13 14:51:54 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [controls/listbox.c]
ListBoxDirectory() modified to use dos_fs.c's functions to
access files&|drives.
Sat Dec 04 17:04:23 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [misc/dos_fs.c]
Added FindFile() to search a file in a dos/unix style path.
* [misc/file.c]
New Win31 functions: OpenFile, _lcreate, _llseek, GetTempDrive,
GetTempFileName, GetWindowsDirectory, GetSystemDirectory,
GetDriveType.
* [misc/int21.c]
Modified.
Wed Dec 1 16:20:45 1993 Miguel de Icaza (miguel@roxanne.nuclecu.unam.mx)
* [misc/profile.c]
The Profile functions now return the correct values. They now
implement all the features described in the SDK.
Tue Nov 30 13:55:27 1993 Bob Amstadt (bob at amscons)
* [loader/selector.c]
Rewrote selector aliasing routines to use System V IPC
routine to alias memory segments.
Nov 28, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [controls/listbox.c]
More consistency in functions using wIndexes
* [controls/scroll.c]
New function : ShowScrollBar().
* [loader/cursor.c] ... New file
Move cursor functions from [loader/resource.c].
New function : ClipCursor().
New function : GetClipCursor().
New function : CreateCursor().
SetCursor() now working using gloabal variable 'winHasCursor'.
*[object/palette.c]
New stub only : SelectPalette().
New stub only : RealizePalette().
*[win/event.c]
New function : EVENT_enter_notify(),
update 'winHasCursor' and send WM_SETCURSOR.
*[win/defwnd.c]
Add processing of WM_SETCURSOR message.
*[win/win.c]
New members in WND structure : hCursor, hWndVScroll & hWndHScroll.
CreateWindowEx() now create children for WM_HSCROLL & WM_VSCROLL.
New function ClientToScreen().
New function ScreenToClient().
Mon Nov 25 18:25:40 1993 Erik Bos (erik@trashcan.hacktic.nl)
* [files.h / regfunc.h / misc/dos.c]
Removed.
* [misc/dos_fs.c]
Added support for loading dosdrive cfg from wine.ini.
* [misc/int21.c]
Modified.
Wed Nov 24 11:37:33 1993 julliard@disuns2.epfl.ch (Alexandre Julliard)
* [include/atom.h] [memory/atom.c]
Implemented atoms.
* [windows/class.c]
Modified RegisterClass() to use atoms.
Implemented CS_GLOBALCLASS style.
* [windows/message.c]
Implemented RegisterWindowMessage().
* [loader/resource.c]
Bug fix in LoadResource().
* [windows/dialog.c]
Modified CreateDialogParam() to use Find/LoadResource().
diff --git a/controls/menu.c b/controls/menu.c
index 2d22115..c1cd758 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -1,6 +1,8 @@
static char RCSId[] = "$Id$";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
+#define DEBUG_MENU
+
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/SmeBSB.h>
@@ -22,7 +24,306 @@
static int menuId = 0;
static Pixmap checkBitmap = XtUnspecifiedPixmap;
static Pixmap nocheckBitmap = XtUnspecifiedPixmap;
-
+
+LPPOPUPMENU PopupMenuGetStorageHeader(HWND hwnd);
+LPPOPUPMENU PopupMenuGetWindowAndStorage(HWND hwnd, WND **wndPtr);
+void StdDrawPopupMenu(HWND hwnd);
+LPMENUITEM PopupMenuFindItem(HWND hwnd, int x, int y, WORD *lpRet);
+LPMENUITEM GetMenuItemPtr(LPPOPUPMENU menu, WORD nPos);
+
+/***********************************************************************
+ * PopupMenuWndProc
+ */
+LONG PopupMenuWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
+{
+ CREATESTRUCT *createStruct;
+ WORD wRet;
+ short x, y;
+ WND *wndPtr;
+ LPPOPUPMENU lppop;
+ LPMENUITEM lpitem, lpitem2;
+ HMENU hSubMenu;
+ RECT rect;
+ HDC hDC;
+ switch(message)
+ {
+ case WM_CREATE:
+#ifdef DEBUG_MENU
+ printf("PopupMenu WM_CREATE lParam=%08X !\n", lParam);
+#endif
+ createStruct = (CREATESTRUCT *)lParam;
+ lppop = (LPPOPUPMENU)createStruct->lpCreateParams;
+ if (lppop == 0) break;
+ wndPtr = WIN_FindWndPtr(hwnd);
+ *((LPPOPUPMENU *)&wndPtr->wExtra[1]) = lppop;
+#ifdef DEBUG_MENU
+ printf("PopupMenu WM_CREATE lppop=%08X !\n", lppop);
+#endif
+ return 0;
+ case WM_DESTROY:
+ lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
+#ifdef DEBUG_MENU
+ printf("PopupMenu WM_DESTROY %lX !\n", lppop);
+#endif
+ return 0;
+
+ case WM_LBUTTONDOWN:
+ lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
+ SetCapture(hwnd);
+ lpitem = PopupMenuFindItem(hwnd, LOWORD(lParam), HIWORD(lParam), &wRet);
+ printf("PopupMenu WM_LBUTTONDOWN wRet=%d lpitem=%08X !\n", wRet, lpitem);
+ if (lpitem != NULL) {
+ lppop->FocusedItem = wRet;
+ if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
+ ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
+ hDC = GetDC(hwnd);
+ InvertRect(hDC, &lpitem->rect);
+ ReleaseDC(hwnd, hDC);
+ }
+ }
+ break;
+ case WM_LBUTTONUP:
+ lppop = PopupMenuGetStorageHeader(hwnd);
+ ReleaseCapture();
+ lpitem = PopupMenuFindItem(hwnd, LOWORD(lParam), HIWORD(lParam), &wRet);
+ printf("PopupMenu WM_LBUTTONUP wRet=%d lpitem=%08X !\n", wRet, lpitem);
+ if (lpitem != NULL) {
+ if (lppop->FocusedItem != (WORD)-1) {
+ lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem);
+ if (((lpitem2->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
+ ((lpitem2->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
+ hDC = GetDC(hwnd);
+ InvertRect(hDC, &lpitem2->rect);
+ ReleaseDC(hwnd, hDC);
+ }
+ }
+ if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) {
+ hSubMenu = (HMENU)lpitem->item_id;
+ printf("ShowSubmenu hSubMenu=%04X !\n", hSubMenu);
+ GetClientRect(hwnd, &rect);
+ x = rect.right;
+ GetWindowRect(hwnd, &rect);
+ x += rect.left;
+ TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON,
+ x, rect.top + HIWORD(lParam),
+ 0, lppop->ownerWnd, (LPRECT)NULL);
+ break;
+ }
+ if (((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
+ ((lpitem->item_flags & MF_POPUP) != MF_POPUP)) {
+ SendMessage(lppop->ownerWnd, WM_COMMAND, lpitem->item_id, 0L);
+ printf("PopupMenu // SendMessage WM_COMMAND wParam=%d !\n",
+ lpitem->item_id);
+ ShowWindow(lppop->hWnd, SW_HIDE);
+ break;
+ }
+ }
+ break;
+ case WM_MOUSEMOVE:
+ if ((wParam & MK_LBUTTON) != 0) {
+ lppop = PopupMenuGetStorageHeader(hwnd);
+ lpitem = PopupMenuFindItem(hwnd, LOWORD(lParam), HIWORD(lParam), &wRet);
+ if ((lpitem != NULL) && (lppop->FocusedItem != wRet)) {
+ lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem);
+ hDC = GetDC(hwnd);
+ if (((lpitem2->item_flags & MF_POPUP) == MF_POPUP) ||
+ ((lpitem2->item_flags & MF_STRING) == MF_STRING)) {
+ InvertRect(hDC, &lpitem2->rect);
+ }
+ lppop->FocusedItem = wRet;
+ printf("PopupMenu WM_MOUSEMOVE wRet=%d lpitem=%08X !\n", wRet, lpitem);
+ InvertRect(hDC, &lpitem->rect);
+ ReleaseDC(hwnd, hDC);
+ }
+ }
+ break;
+
+ case WM_KEYDOWN:
+ case WM_KEYUP:
+ case WM_CHAR:
+ lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
+ return(SendMessage(wndPtr->hwndParent, message, wParam, lParam));
+
+ case WM_PAINT:
+ printf("PopupMenu WM_PAINT !\n");
+ StdDrawPopupMenu(hwnd);
+ break;
+ default:
+ return DefWindowProc( hwnd, message, wParam, lParam );
+ }
+return(0);
+}
+
+
+
+LPPOPUPMENU PopupMenuGetWindowAndStorage(HWND hwnd, WND **wndPtr)
+{
+ WND *Ptr;
+ LPPOPUPMENU lppop;
+ *(wndPtr) = Ptr = WIN_FindWndPtr(hwnd);
+ if (Ptr == 0) {
+ printf("Bad Window handle on PopupMenu !\n");
+ return 0;
+ }
+ lppop = *((LPPOPUPMENU *)&Ptr->wExtra[1]);
+ return lppop;
+}
+
+
+LPPOPUPMENU PopupMenuGetStorageHeader(HWND hwnd)
+{
+ WND *Ptr;
+ LPPOPUPMENU lppop;
+ Ptr = WIN_FindWndPtr(hwnd);
+ if (Ptr == 0) {
+ printf("Bad Window handle on PopupMenu !\n");
+ return 0;
+ }
+ lppop = *((LPPOPUPMENU *)&Ptr->wExtra[1]);
+ return lppop;
+}
+
+
+void StdDrawPopupMenu(HWND hwnd)
+{
+ WND *wndPtr;
+ LPPOPUPMENU lppop;
+ LPMENUITEM lpitem;
+ PAINTSTRUCT ps;
+ HBRUSH hBrush;
+ HPEN hOldPen;
+ HWND hWndParent;
+ HDC hDC, hMemDC;
+ RECT rect, rect2, rect3;
+ HBITMAP hBitMap;
+ BITMAP bm;
+ UINT i;
+ hDC = BeginPaint( hwnd, &ps );
+ if (!IsWindowVisible(hwnd)) {
+ EndPaint( hwnd, &ps );
+ return;
+ }
+ lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
+ if (lppop == NULL) goto EndOfPaint;
+ hBrush = SendMessage(lppop->ownerWnd, WM_CTLCOLOR, (WORD)hDC,
+ MAKELONG(hwnd, CTLCOLOR_LISTBOX));
+ if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH);
+ GetClientRect(hwnd, &rect);
+ GetClientRect(hwnd, &rect2);
+ FillRect(hDC, &rect, hBrush);
+ if (lppop->nItems == 0) goto EndOfPaint;
+ lpitem = lppop->firstItem->next;
+ if (lpitem == NULL) goto EndOfPaint;
+ for(i = 0; i < lppop->nItems; i++) {
+ if ((lpitem->item_flags & MF_SEPARATOR) == MF_SEPARATOR) {
+ rect2.bottom = rect2.top + 3;
+ CopyRect(&lpitem->rect, &rect2);
+ hOldPen = SelectObject(hDC, GetStockObject(BLACK_PEN));
+ MoveTo(hDC, rect2.left, rect2.top + 1);
+ LineTo(hDC, rect2.right, rect2.top + 1);
+ SelectObject(hDC, hOldPen);
+ rect2.top += 3;
+ }
+ if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) {
+ hBitMap = (HBITMAP)LOWORD(lpitem->item_text);
+ rect2.bottom = rect2.top + bm.bmHeight;
+ CopyRect(&lpitem->rect, &rect2);
+ hMemDC = CreateCompatibleDC(hDC);
+ SelectObject(hMemDC, hBitMap);
+ GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
+ BitBlt(hDC, rect2.left, rect2.top,
+ bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
+ DeleteDC(hMemDC);
+ rect2.top += bm.bmHeight;
+ }
+ if (((lpitem->item_flags & MF_BITMAP) != MF_BITMAP) &&
+ ((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
+ ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
+ rect2.bottom = rect2.top + 15;
+ CopyRect(&lpitem->rect, &rect2);
+ TextOut(hDC, rect2.left + 5, rect2.top + 2,
+ (char *)lpitem->item_text, strlen((char *)lpitem->item_text));
+ rect2.top += 15;
+ }
+ if ((lpitem->item_flags & MF_CHECKED) == MF_CHECKED) {
+ CopyRect(&rect3, &rect2);
+ rect3.left = rect3.right - rect3.bottom + rect3.top;
+ InvertRect(hDC, &rect3);
+ }
+ if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) {
+ CopyRect(&rect3, &rect2);
+ rect3.left = rect3.right - rect3.bottom + rect3.top;
+ FillRect(hDC, &rect3, GetStockObject(BLACK_BRUSH));
+ }
+ if (lpitem->next == NULL) goto EndOfPaint;
+ lpitem = (LPMENUITEM)lpitem->next;
+ }
+EndOfPaint:
+ EndPaint( hwnd, &ps );
+}
+
+
+
+LPMENUITEM PopupMenuFindItem(HWND hwnd, int x, int y, WORD *lpRet)
+{
+ WND *wndPtr;
+ LPPOPUPMENU lppop;
+ LPMENUITEM lpitem;
+ RECT rect, rect2;
+ HBITMAP hBitMap;
+ BITMAP bm;
+ UINT i;
+ lppop = PopupMenuGetWindowAndStorage(hwnd, &wndPtr);
+ if (lppop == NULL) return NULL;
+ GetClientRect(hwnd, &rect);
+ if (lppop->nItems == 0) return NULL;
+ lpitem = lppop->firstItem->next;
+ if (lpitem == NULL) return NULL;
+ for(i = 0; i < lppop->nItems; i++) {
+ if (y < rect2.top) return NULL;
+ if ((lpitem->item_flags & MF_SEPARATOR) == MF_SEPARATOR) {
+ rect2.bottom = rect2.top + 3;
+ rect2.top += 3;
+ }
+ if ((lpitem->item_flags & MF_BITMAP) == MF_BITMAP) {
+ hBitMap = (HBITMAP)LOWORD(lpitem->item_text);
+ GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
+ rect2.bottom = rect2.top + bm.bmHeight;
+ rect2.top += bm.bmHeight;
+ }
+ if (((lpitem->item_flags & MF_BITMAP) != MF_BITMAP) &&
+ ((lpitem->item_flags & MF_SEPARATOR) != MF_SEPARATOR) &&
+ ((lpitem->item_flags & MF_MENUBREAK) != MF_MENUBREAK)) {
+ rect2.bottom = rect2.top + 15;
+ rect2.top += 15;
+ }
+ if (y < rect2.bottom) {
+ if (lpRet != NULL) *lpRet = i;
+ return lpitem;
+ }
+ if (lpitem->next == NULL) return NULL;
+ lpitem = (LPMENUITEM)lpitem->next;
+ }
+ return NULL;
+}
+
+
+
+LPMENUITEM GetMenuItemPtr(LPPOPUPMENU menu, WORD nPos)
+{
+ LPMENUITEM lpitem;
+ int i;
+ if (menu == NULL) return NULL;
+ lpitem = menu->firstItem;
+ for (i = 0; i < menu->nItems; i++) {
+ if (lpitem->next == NULL) return NULL;
+ lpitem = (LPMENUITEM)lpitem->next;
+ if (i == nPos) return(lpitem);
+ }
+ return NULL;
+}
+
+
/**********************************************************************
* MENU_CheckWidget
*/
@@ -565,3 +866,316 @@
return GlobalHandleFromPointer(menu->firstItem);
}
+
+
+/**********************************************************************
+ * CheckMenuItem [USER.154]
+ */
+BOOL CheckMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags)
+{
+}
+
+
+/**********************************************************************
+ * EnableMenuItem [USER.155]
+ */
+BOOL EnableMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags)
+{
+}
+
+
+/**********************************************************************
+ * InsertMenu [USER.410]
+ */
+BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewItem)
+{
+ WND *wndPtr;
+ LPPOPUPMENU menu;
+ HANDLE hNewItem;
+ LPMENUITEM lpitem, lpitem2;
+ int i;
+#ifdef DEBUG_MENU
+ printf("InsertMenu (%04X, %04X, %04X, %04X, %08X) !\n",
+ hMenu, nPos, wFlags, wItemID, lpNewItem);
+#endif
+ menu = (LPPOPUPMENU) GlobalLock(hMenu);
+ if (menu == NULL) return FALSE;
+ lpitem = menu->firstItem;
+ for (i = 0; i < menu->nItems; i++) {
+ if (lpitem->next == NULL) break;
+ lpitem = (LPMENUITEM)lpitem->next;
+ printf("InsertMenu // during loop items !\n");
+ }
+ printf("InsertMenu // after loop items !\n");
+ hNewItem = GlobalAlloc(GMEM_MOVEABLE, sizeof(MENUITEM));
+ if (hNewItem == 0) return FALSE;
+ lpitem2 = (LPMENUITEM)GlobalLock(hNewItem);
+ if (lpitem2 == 0) {
+ GlobalFree(hNewItem);
+ return FALSE;
+ }
+ lpitem2->item_flags = wFlags;
+ lpitem2->item_id = wItemID;
+ if ((wFlags & MF_STRING) == MF_STRING) {
+ lpitem2->item_text = lpNewItem;
+ }
+ else
+ lpitem2->item_text = lpNewItem;
+ lpitem2->prev = lpitem;
+ if (lpitem->next != NULL)
+ lpitem2->next = lpitem->next;
+ else
+ lpitem2->next = NULL;
+ lpitem->next = lpitem2;
+ lpitem2->child = NULL;
+ lpitem2->parent = NULL;
+ lpitem2->w = NULL;
+ lpitem2->menu_w = NULL;
+ menu->nItems++;
+ return TRUE;
+}
+
+
+/**********************************************************************
+ * AppendMenu [USER.411]
+ */
+BOOL AppendMenu(HMENU hMenu, WORD wFlags, WORD wItemID, LPSTR lpNewItem)
+{
+ WND *wndPtr;
+ LPPOPUPMENU menu;
+ HANDLE hNewItem;
+ LPMENUITEM lpitem, lpitem2;
+#ifdef DEBUG_MENU
+ printf("AppendMenu (%04X, %04X, %04X, %08X) !\n",
+ hMenu, wFlags, wItemID, lpNewItem);
+#endif
+ menu = (LPPOPUPMENU) GlobalLock(hMenu);
+ if (menu == NULL) return FALSE;
+ lpitem = menu->firstItem;
+ while (lpitem->next != NULL) {
+ lpitem = (LPMENUITEM)lpitem->next;
+ printf("AppendMenu // during loop items !\n");
+ }
+ printf("AppendMenu // after loop items !\n");
+ hNewItem = GlobalAlloc(GMEM_MOVEABLE, sizeof(MENUITEM));
+ if (hNewItem == 0) return FALSE;
+ lpitem2 = (LPMENUITEM)GlobalLock(hNewItem);
+ if (lpitem2 == 0) {
+ GlobalFree(hNewItem);
+ return FALSE;
+ }
+ lpitem2->item_flags = wFlags;
+ lpitem2->item_id = wItemID;
+ if ((wFlags & MF_STRING) == MF_STRING) {
+ lpitem2->item_text = lpNewItem;
+ }
+ else
+ lpitem2->item_text = lpNewItem;
+ lpitem->next = lpitem2;
+ lpitem2->prev = lpitem;
+ lpitem2->next = NULL;
+ lpitem2->child = NULL;
+ lpitem2->parent = NULL;
+ lpitem2->w = NULL;
+ lpitem2->menu_w = NULL;
+ menu->nItems++;
+ return TRUE;
+}
+
+
+/**********************************************************************
+ * RemoveMenu [USER.412]
+ */
+BOOL RemoveMenu(HMENU hMenu, WORD nPos, WORD wFlags)
+{
+ WND *wndPtr;
+ LPPOPUPMENU menu;
+ LPMENUITEM lpitem;
+ int i;
+#ifdef DEBUG_MENU
+ printf("RemoveMenu (%04X, %04X, %04X) !\n", hMenu, nPos, wFlags);
+#endif
+ menu = (LPPOPUPMENU) GlobalLock(hMenu);
+ if (menu == NULL) return FALSE;
+ lpitem = menu->firstItem;
+ for (i = 0; i < menu->nItems; i++) {
+ if (lpitem->next == NULL) break;
+ lpitem = (LPMENUITEM)lpitem->next;
+ if (i == nPos) {
+ lpitem->prev->next = lpitem->next;
+ lpitem->next->prev = lpitem->prev;
+ GlobalFree(HIWORD(lpitem));
+ return(TRUE);
+ }
+ printf("RemoveMenu // during loop items !\n");
+ }
+ printf("RemoveMenu // after loop items !\n");
+ return FALSE;
+}
+
+
+/**********************************************************************
+ * DeleteMenu [USER.413]
+ */
+BOOL DeleteMenu(HMENU hMenu, WORD nPos, WORD wFlags)
+{
+#ifdef DEBUG_MENU
+ printf("DeleteMenu (%04X, %04X, %04X) !\n", hMenu, nPos, wFlags);
+#endif
+ return TRUE;
+}
+
+
+/**********************************************************************
+ * ModifyMenu [USER.414]
+ */
+BOOL ModifyMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewItem)
+{
+#ifdef DEBUG_MENU
+ printf("ModifyMenu (%04X, %04X, %04X, %04X, %08X) !\n",
+ hMenu, nPos, wFlags, wItemID, lpNewItem);
+#endif
+ return TRUE;
+}
+
+
+/**********************************************************************
+ * CreatePopupMenu [USER.415]
+ */
+HMENU CreatePopupMenu()
+{
+ HANDLE hItem;
+ HMENU hMenu;
+ LPPOPUPMENU menu;
+#ifdef DEBUG_MENU
+ printf("CreatePopupMenu !\n");
+#endif
+ hMenu = GlobalAlloc(GMEM_MOVEABLE, sizeof(POPUPMENU));
+ menu = (LPPOPUPMENU) GlobalLock(hMenu);
+ if (menu == NULL) {
+ GlobalFree(hMenu);
+ return 0;
+ }
+ hItem = GlobalAlloc(GMEM_MOVEABLE, sizeof(MENUITEM));
+ if (hItem == 0) {
+ GlobalFree(hMenu);
+ return 0;
+ }
+ menu->nItems = 0;
+ menu->firstItem = (LPMENUITEM)GlobalLock(hItem);
+ menu->ownerWnd = 0;
+ menu->hWnd = 0;
+
+ menu->firstItem->next = NULL;
+ menu->firstItem->prev = NULL;
+ menu->firstItem->child = NULL;
+ menu->firstItem->parent = NULL;
+ menu->firstItem->item_flags = 0;
+ menu->firstItem->item_id = 0;
+ menu->firstItem->item_text = NULL;
+ menu->firstItem->w = NULL;
+ menu->firstItem->menu_w = NULL;
+ return hMenu;
+}
+
+
+/**********************************************************************
+ * TrackPopupMenu [USER.414]
+ */
+BOOL TrackPopupMenu(HMENU hMenu, WORD wFlags, short x, short y,
+ short nReserved, HWND hWnd, LPRECT lpRect)
+{
+ WND *wndPtr;
+ LPPOPUPMENU menu;
+#ifdef DEBUG_MENU
+ printf("TrackPopupMenu (%04X, %04X, %d, %d, %04X, %04X, %08X) !\n",
+ hMenu, wFlags, x, y, nReserved, hWnd, lpRect);
+#endif
+ menu = (LPPOPUPMENU) GlobalLock(hMenu);
+ if (menu == NULL) return FALSE;
+ wndPtr = WIN_FindWndPtr(hWnd);
+ menu->ownerWnd = hWnd;
+ if (menu->hWnd == NULL) {
+ menu->hWnd = CreateWindow("POPUPMENU", "", WS_CHILD | WS_VISIBLE,
+ x, y, 100, 150, hWnd, 0, wndPtr->hInstance, (LPSTR)menu);
+ }
+ else
+ ShowWindow(menu->hWnd, SW_SHOW);
+ return TRUE;
+}
+
+
+/**********************************************************************
+ * CreateMenu [USER.151]
+ */
+HMENU CreateMenu()
+{
+ HANDLE hItem;
+ HMENU hMenu;
+ LPMENUBAR menu;
+#ifdef DEBUG_MENU
+ printf("CreateMenu !\n");
+#endif
+ hMenu = GlobalAlloc(GMEM_MOVEABLE, sizeof(MENUBAR));
+ menu = (LPMENUBAR) GlobalLock(hMenu);
+ if (menu == NULL) {
+ GlobalFree(hMenu);
+ return 0;
+ }
+ hItem = GlobalAlloc(GMEM_MOVEABLE, sizeof(MENUITEM));
+ if (hItem == 0) {
+ GlobalFree(hMenu);
+ return 0;
+ }
+ menu->menuDescription = 0;
+ menu->nItems = 0;
+ menu->parentWidget = NULL;
+ menu->firstItem = (LPMENUITEM) GlobalLock(hItem);
+ menu->ownerWnd = 0;
+ menu->menuBarWidget = NULL;
+
+ menu->firstItem->next = NULL;
+ menu->firstItem->prev = NULL;
+ menu->firstItem->child = NULL;
+ menu->firstItem->parent = NULL;
+ menu->firstItem->item_flags = 0;
+ menu->firstItem->item_id = 0;
+ menu->firstItem->item_text = NULL;
+ menu->firstItem->w = NULL;
+ menu->firstItem->menu_w = NULL;
+ return hMenu;
+}
+
+
+/**********************************************************************
+ * DestroyMenu [USER.152]
+ */
+BOOL DestroyMenu(HMENU hMenu)
+{
+ LPPOPUPMENU lppop;
+ LPMENUITEM lpitem, lpitem2;
+#ifdef DEBUG_MENU
+ printf("DestroyMenu (%04X) !\n", hMenu);
+#endif
+ if (hMenu == 0) return FALSE;
+ lppop = (LPPOPUPMENU) GlobalLock(hMenu);
+ if (lppop == NULL) return FALSE;
+ if (lppop->hWnd) DestroyWindow (lppop->hWnd);
+ lpitem = lppop->firstItem;
+ while (lpitem->next != NULL) {
+#ifdef DEBUG_MENU
+ printf("DestroyMenu (%04X) // during loop items !\n", hMenu);
+#endif
+ if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) {
+ DestroyMenu((HMENU)lpitem->item_id);
+ }
+ lpitem = (LPMENUITEM)lpitem->next;
+ }
+ GlobalFree(hMenu);
+#ifdef DEBUG_MENU
+ printf("DestroyMenu (%04X) // End !\n", hMenu);
+#endif
+ return TRUE;
+}
+
+