Re: [AD] mouse focus @ create Window time bug

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


AJ wrote:
AJ wrote:

http://www.allegro.cc/forums/view_thread.php?_id=476898

this thread on a.cc seems to have found a fix for the mouse focus at createWindow time issue.

the problem is the mouse & keyb does not work if the window has not got the focus when the CreateWindow() is called.




/docs/src/win/wkeyb.c  line 553:
hr = IDirectInputDevice_SetCooperativeLevel(key_dinput_device, allegro_wnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);

passes the  allego_wnd  which gets set by  create_directx_window()

even the /examples/exmouse.c attempts to init_keyb before it creates the window. so the allegro_wnd is probably NULL when that
IDirectInputDevice_SetCooperativeLevel() occurs.

whether this has anything to do with this focus bug, i have no idea.



maybe we could add an ASSERT()


from MSDN:
HRESULT SetCooperativeLevel( HWND hwnd, DWORD dwFlags );

hwnd: Window handle to be associated with the device. This parameter must be a valid top-level window handle that belongs to the process. The window associated with the device must not be destroyed while it is still active in a Microsoft DirectInput device.








here is another function that appears to be VERY relevant in this problem:

from this document:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/enablewindow.asp






here are some notes from MSDN that may be relevant for this bug:

from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/createwindowex.asp

Windows 2000/XP: The WS_EX_NOACTIVATE value for dwExStyle prevents foreground activation by the system. To prevent queue activation when the user clicks on the window, you must process the WM_MOUSEACTIVATE message appropriately. To bring the window to the foreground or to activate it programmatically, use SetForegroundWindow or SetActiveWindow. Returning FALSE to WM_NCACTIVATE prevents the window from losing queue activation. However, the return value is ignored at activation time.













Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/