How to change focus from TreeView to ListView using tab in MFC?
-
Hello, I am currently working on an MFC project. The project have a treeview and listview similar to the layout of windows registry editor. I was just wondering if any of you guys know how to change the focus wherein if the user click one item in the treeview and then presses the tab key the focus would be changed to the corresponding item in the listview? Please help.
-
Hello, I am currently working on an MFC project. The project have a treeview and listview similar to the layout of windows registry editor. I was just wondering if any of you guys know how to change the focus wherein if the user click one item in the treeview and then presses the tab key the focus would be changed to the corresponding item in the listview? Please help.
Try it :) :
/*virtual*/ BOOL CLeft(Right)View::PreTranslateMessage(MSG* pMsg)
{
if (WM_KEYDOWN == pMsg->message) {
if (VK_TAB == pMsg->wParam) {
CWnd* pcWnd = YourFunctionToGetRight(Left)View();
if (pcWnd) {
pcWnd->SetFocus(); // :)
}
return TRUE;
}
}
return CBaseOfLeft(Right)View::PreTranslateMessage(MSG* pMsg);
}virtual void BeHappy() = 0;
-
Try it :) :
/*virtual*/ BOOL CLeft(Right)View::PreTranslateMessage(MSG* pMsg)
{
if (WM_KEYDOWN == pMsg->message) {
if (VK_TAB == pMsg->wParam) {
CWnd* pcWnd = YourFunctionToGetRight(Left)View();
if (pcWnd) {
pcWnd->SetFocus(); // :)
}
return TRUE;
}
}
return CBaseOfLeft(Right)View::PreTranslateMessage(MSG* pMsg);
}virtual void BeHappy() = 0;
-
I have tried the code above but it slows down the application to the point it no longer populates the treeview, is there any other alternative?
Of course, try to implement the reactions on WM_KEYDOWN for the both views :)
virtual void BeHappy() = 0;
-
Of course, try to implement the reactions on WM_KEYDOWN for the both views :)
virtual void BeHappy() = 0;