window doesn't gain focus after summon
Bug #364836 reported by
Eyal Wiener
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mighty Box |
Fix Committed
|
Critical
|
Unassigned |
Bug Description
When summoning the command window, sometimes the window appears, top most, but doesn't gain focus.
This is critical, cause this happens many times, and when the window ain't got no focus, it doesn't capture keystrokes.
You can invoke this behavior by working on some app, calling MB to appear, and then, while the command window is open, click outside of it, back on the app. and from this moment forward, mighty box doesn't get *keyboard focus* when called while using this app. as if it had a higher precedence over it
Related branches
tags: | added: gui |
Changed in mb: | |
importance: | Undecided → Critical |
status: | New → Confirmed |
description: | updated |
To post a comment you must log in.
I used Win32API to resolve this
[DllImport( "User32. dll")] ndow(IntPtr hWnd);
public static extern Int32 SetForegroundWi
[DllImport( "user32" )]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
IntPtr hWnd = new WindowInteropHe lper(MBMain. cmdWin) .Handle;
uint TOPMOST_FLAGS = SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS;
bool success = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, TOPMOST_FLAGS);
// Very very nasty hack: indow(hWnd) == 0) // on failure, try again Write(" #"); WriteLine( "@");
while (SetForegroundW
Console.
Console.