Maintain Focus

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

You tried Set ForegroundWindow ?

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

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