Here's what i do, i don't know if it's correct though:
Mainform:
Code:
Stack<HWND> *ws;
case WM_SETFOCUS:
BringWindowToTop(ws->GetTop());
SetActiveWindow(ws->GetTop());
break;
case WM_CREATE: // Init event
//Create, and push HWND to stack
ws = new Stack<HWND>(hwnd);
Childform:
Code:
case WM_SETFOCUS:
BringWindowToTop(ws->GetTop());
SetFocus(ws->GetTop());
break;
case WM_CREATE: // Init event
ws->Push(tp[WND]);
case WM_DESTROY:
ws->Pop();
SetFocus(ws->GetTop());
The stack is a class i created on my own. The GetTop() function returns the handle of the last window pushed to the stack.
In this way, whatever window receives focus, it will call SetFocus() for the correct window.