[quote=427918:@Isaac Raway]So, poking around the Wine source code I think it might be possible to simulate what CreatePopupMenu and TrackPopupMenu do to accomplish showing a window above a modal.
This should at least give you an idea of the flags involved.
First, creating the HWND that is used (these flags should be settable on an existing window with SetWindowLong):
menu->hWnd = CreateWindowExW( ex_style, (LPCWSTR)POPUPMENU_CLASS_ATOM, NULL,
WS_POPUP, 0, 0, 0, 0,
hwndOwner, 0, (HINSTANCE)GetWindowLongPtrW(hwndOwner, GWLP_HINSTANCE),
(LPVOID)hmenu );
The styles referenced by the POPUPMENU_CLASS_ATOM (which are CS_DROPSHADOW | CS_SAVEBITS | CS_DBLCLKS) do not seem to be relevant, though CS_SAVEBITS does have a small optimization when hiding small windows. Hopefully we don’t need those class styles since I am not aware of a way to make a Xojo window with a custom class.
So, then the window is actually shown:
SetWindowPos( menu->hWnd, HWND_TOPMOST, x, y, menu->Width, menu->Height,
SWP_SHOWWINDOW | SWP_NOACTIVATE );
UpdateWindow( menu->hWnd );
This seems to be mainly a simple combination of HWND_TOPMOST and the SetWindowPos flags SWP_SHOWWINDOW and SWP_NOACTIVATE. SetWindowPos should be able to do this for you pretty much as shown in the actual Wine code.
Source, MENU_InitPopup and MENU_ShowPopup. Hopefully that’s enough to go on, I wish I could get this together into a working example but other duties call.[/quote]
I tried to replicate the above, and wrote this:
const GWL_STYLE = -16
const WS_POPUP = &h80000000
const HWND_TOPMOST = -1
const SWP_SHOWWINDOW = &h0040
const SWP_NOACTIVATE = &h0010
declare function SetWindowPos lib "User32" (hWnd as integer, hWndInstertAfter as integer, x as integer, y as integer, cx as integer, cy as integer, flags as integer) as boolean
declare function SetWindowLongW lib "User32" (hWnd as integer, nIndex as integer, dwNewLong as integer) as integer
declare function UpdateWindow lib "User32" (hWnd as integer) as boolean
call SetWindowLongW(w.handle, GWL_STYLE, WS_POPUP)
call SetWindowPos(w.handle, HWND_TOPMOST, w.left, w.top, w.width, w.height, SWP_NOACTIVATE or SWP_SHOWWINDOW)
call UpdateWindow(w.handle)
but seems to do nothing. Worse, the SWP_NOACTIVATE
completely prevent the window to get keyboard focus. Removing it, the above code behave like if it’s not called, that is, the window is set to front, the keyboard input is active, only the mouse is not captured.