I have a ''main'' window with a treeview that holds items the user clicks on. When a double click is detected, a new window is opened up:
// WTL
ConversationWindow* newConvo = new ConversationWindow(e.contact);
newConvo->Create(::GetDesktopWindow(),
location,
newConvo->Title().c_str(),
WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SIZEBOX,
WS_EX_CLIENTEDGE);
SetForegroundWindow(newConvo->m_hWnd);
SetActiveWindow(newConvo->m_hWnd);
The problem is I cannot get it to actually keep the focus on the window. What happens (when I use Spy++) is the window gets the focus and then the main window steals the focus back somehow. It seems like the Treeview needs the focus back to finish updating itself after it runs the handler. Here is my treeview WM_NOTIFY handler:
LRESULT ContactListWindow::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&)
{
NMHDR* mhdr = reinterpret_cast<NMHDR*>(lParam);
if(mhdr->code == NM_DBLCLK)
{
Node* selectedNode = reinterpret_cast<Node*>(m_treeView.GetSelectedItem().GetData());
if(selectedNode != 0)
selectedNode->OnDoubleClick();
}
return CFrameWindowImpl<ContactListWindow>::DefWindowProc(uMsg, wParam, lParam);
}
This
URL seems to be what my problem is but I tried implementing it by hooking the TVN_SELCHANGING message to no avail.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis