Sorry for delayed reply
There are only few situations where you should need to manage the focus explicitly.
I don't want to - only my component displays a few windows: main with thumbnails, additional with clicked picture, windows of threads - and if any of this window doesn't have 'core_api::get_main_window()' as parent, after closing my component main window focus doesn't return to Foobar main window. I made some errors, but I don't know where.
As for creating an invisible window, WTL may be trying to help you by providing some default behaviour and window styles there. I remember I had a similar problem once. It is too far ago unfortunately, so I don't remember the details. It might help, if you posted the code that defines and creates your window.
I created a better version of my plugin - showing downloaded thumbnails, I don't need to hide window - so this is not a big problem now for me.
Window class:
typedef CWinTraits<WS_TILEDWINDOW, WS_EX_TOOLWINDOW>//I've tested other combinations, of course
CovWinTraits;
class CovWin : public CFrameWindowImpl<CovWin,CWindow,CovWinTraits>//CFrameWindowImpl, because I wanted a CreateSimpleStatusBar
//Tested with CWindowImpl too
then I have a global object
static CovWin g_dlg; //I know - this could be done better, but I made this for quick experiments
and in function of context menu:
try{//(...)
if ( !g_dlg.IsWindow() ){
RECT rc = {100, 100, 500, 700};//Later cfg_popup_window_placement
g_dlg.Create(core_api::get_main_window(),rc);//this window is visible
}
g_dlg.ShowWindow(SW_HIDE);//A window will disappear, after blinking in Create();
//(...)