fixed handling of control focus

svn path=/trunk/; revision=7423
This commit is contained in:
Thomas Bluemel 2004-01-03 15:59:46 +00:00
parent 7fbcfcbc71
commit 33f1db80ee
4 changed files with 23 additions and 8 deletions

View file

@ -141,6 +141,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
pChildWnd->hWnd = hWnd;
pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, TREE_WINDOW);
pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW/*, pChildWnd->szPath*/);
SetFocus(pChildWnd->hTreeWnd);
break;
case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
@ -284,6 +285,9 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
}
}
break;
case NM_SETFOCUS:
pChildWnd->nFocusPanel = 1;
break;
default:
goto def;
}
@ -291,10 +295,17 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
{
if ((int)wParam == LIST_WINDOW)
{
if(ListWndNotifyProc(pChildWnd->hListWnd, wParam, lParam, &Result))
{
return Result;
}
switch (((LPNMHDR)lParam)->code) {
case NM_SETFOCUS:
pChildWnd->nFocusPanel = 0;
break;
default:
if(ListWndNotifyProc(pChildWnd->hListWnd, wParam, lParam, &Result))
{
return Result;
}
break;
}
}
}
break;

View file

@ -387,7 +387,7 @@ HWND CreateListView(HWND hwndParent, int id)
/* Get the dimensions of the parent window's client area, and create the list view control. */
GetClientRect(hwndParent, &rcClient);
hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"),
WS_VISIBLE | WS_CHILD | LVS_REPORT | LVS_EDITLABELS,
WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_REPORT | LVS_EDITLABELS,
0, 0, rcClient.right, rcClient.bottom,
hwndParent, (HMENU)id, hInst, NULL);
if (!hwndLV) return NULL;

View file

@ -185,7 +185,8 @@ int APIENTRY WinMain(HINSTANCE hInstance,
/* Main message loop */
while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) {
if (!TranslateAccelerator(msg.hwnd, hAccel, &msg) &&
!IsDialogMessage(hFrameWnd, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}

View file

@ -150,7 +150,10 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName)
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_LOCAL_MACHINE"), HKEY_LOCAL_MACHINE, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_USERS"), HKEY_USERS, 1)) return FALSE;
if (!AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_CONFIG"), HKEY_CURRENT_CONFIG, 1)) return FALSE;
/* expand and select host name */
TreeView_Expand(hwndTV, hRoot, TVE_EXPAND);
TreeView_Select(hwndTV, hRoot, TVGN_CARET);
return TRUE;
}
@ -262,7 +265,7 @@ HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id)
/* Get the dimensions of the parent window's client area, and create the tree view control. */
GetClientRect(hwndParent, &rcClient);
hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, _T("Tree View"),
WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
0, 0, rcClient.right, rcClient.bottom,
hwndParent, (HMENU)id, hInst, NULL);
/* Initialize the image list, and add items to the control. */