if (!visible) {
if (visible) { int flags = OS.TPM_LEFTBUTTON; if (OS.GetKeyState (OS.VK_LBUTTON) >= 0) flags |= OS.TPM_RIGHTBUTTON; if ((style & SWT.RIGHT_TO_LEFT) != 0) flags |= OS.TPM_RIGHTALIGN; if ((parent.style & SWT.MIRRORED) != 0) { flags &= ~OS.TPM_RIGHTALIGN; if ((style & SWT.LEFT_TO_RIGHT) != 0) flags |= OS.TPM_RIGHTALIGN; } int nX = x, nY = y; if (!hasLocation) { int pos = OS.GetMessagePos (); nX = (short) (pos & 0xFFFF); nY = (short) (pos >> 16); }  boolean success = OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null); if (!success && GetMenuItemCount (handle) == 0) { OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0); } } else {
void _setVisible (boolean visible) {	if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;	int hwndParent = parent.handle;	if (!visible) {		OS.SendMessage (hwndParent, OS.WM_CANCELMODE, 0, 0);		return;	}	int flags = OS.TPM_LEFTBUTTON;	if (OS.GetKeyState (OS.VK_LBUTTON) >= 0) flags |= OS.TPM_RIGHTBUTTON;	if ((style & SWT.RIGHT_TO_LEFT) != 0) flags |= OS.TPM_RIGHTALIGN;	if ((parent.style & SWT.MIRRORED) != 0) {		flags &= ~OS.TPM_RIGHTALIGN;		if ((style & SWT.LEFT_TO_RIGHT) != 0) flags |= OS.TPM_RIGHTALIGN;	}	int nX = x, nY = y;	if (!hasLocation) {		int pos = OS.GetMessagePos ();		nX = (short) (pos & 0xFFFF);		nY = (short) (pos >> 16);	}	/*	* Feature in Windows.  It is legal use TrackPopupMenu ()	* to display an empty menu as long as menu items are added	* inside of WM_INITPOPUPMENU.  If no items are added, then	* TrackPopupMenu () fails and does not send an indication	* that the menu has been closed.  This is not strictly a	* bug but leads to unwanted behavior when application code	* assumes that every WM_INITPOPUPMENU will eventually result	* in a WM_MENUSELECT, wParam=0xFFFF0000, lParam=0 to indicate	* that the menu has been closed.  The fix is to detect the	* case when TrackPopupMenu fails and the number of items in	* the menu is zero and issue a fake WM_MENUSELECT.	*/	boolean success = OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null);	if (!success && GetMenuItemCount (handle) == 0) {		OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0);	}}