PDA

View Full Version : Maintain Focus



Andrew Jameson
10-09-2003, 02:04 AM
I've seen this problem on quite a few games (normally shareware) but some commercial ... when launching my fullscreen application sometimes my application appears without focus and it takes a mouse click to get it back, meanwhile the user's confused by the lack of keyboard access. I've tried all the usual API calls ShowWindow, SetWindowPos, SetActive etc. without much conclusive success.
What seems to happen is that if the application is launched by double-clicking the desktop icon and is immediately followed by an accidental further mouse click then Windows sometimes engages drag-mode on the shortcut and prevents my form getting focus.

I'd be grateful is someone could share their knowledge on how an application should be launched so that it's 100% sure-fire guaranteed to have full attention !

Thanks Andrew

roffe
10-09-2003, 11:41 AM
You tried Set ForegroundWindow (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/SetForegroundWindow.asp) ?


[This message has been edited by roffe (edited 10-09-2003).]

Andrew Jameson
10-09-2003, 02:34 PM
Thanks ... yes tried that ... finally resolved it ... SetCapture was the solution. It wasn't so much the accidental click, it was caused by effectively holding the mouse button down as the application initialized that was preventing the focus being completed. SetCapture is very specific and only works for exactly this occasion where a mouse button is held down.

Andrew