2003-08-07 05:10:13 +02:00
|
|
|
/*
|
|
|
|
* Regedit child window
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-08-07 05:10:13 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
2004-05-04 04:55:28 +02:00
|
|
|
#include "wine/debug.h"
|
2018-02-07 00:20:07 +01:00
|
|
|
#include "wine/heap.h"
|
|
|
|
|
2004-05-04 04:55:28 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(regedit);
|
2007-02-18 17:14:39 +01:00
|
|
|
|
2003-12-12 05:08:59 +01:00
|
|
|
ChildWnd* g_pChildWnd;
|
2007-02-18 17:14:39 +01:00
|
|
|
static int last_split;
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2022-04-14 15:01:32 +02:00
|
|
|
static const WCHAR wszLastKey[] = L"LastKey";
|
|
|
|
static const WCHAR wszKeyName[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit";
|
2009-07-02 18:29:44 +02:00
|
|
|
|
2003-08-07 05:10:13 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Local module support methods
|
|
|
|
*/
|
|
|
|
|
2009-01-26 12:53:12 +01:00
|
|
|
static LPCWSTR GetRootKeyName(HKEY hRootKey)
|
2008-08-10 13:52:44 +02:00
|
|
|
{
|
|
|
|
if(hRootKey == HKEY_CLASSES_ROOT)
|
|
|
|
return reg_class_namesW[INDEX_HKEY_CLASSES_ROOT];
|
|
|
|
if(hRootKey == HKEY_CURRENT_USER)
|
|
|
|
return reg_class_namesW[INDEX_HKEY_CURRENT_USER];
|
|
|
|
if(hRootKey == HKEY_LOCAL_MACHINE)
|
|
|
|
return reg_class_namesW[INDEX_HKEY_LOCAL_MACHINE];
|
|
|
|
if(hRootKey == HKEY_USERS)
|
|
|
|
return reg_class_namesW[INDEX_HKEY_USERS];
|
|
|
|
if(hRootKey == HKEY_CURRENT_CONFIG)
|
|
|
|
return reg_class_namesW[INDEX_HKEY_CURRENT_CONFIG];
|
|
|
|
if(hRootKey == HKEY_DYN_DATA)
|
|
|
|
return reg_class_namesW[INDEX_HKEY_DYN_DATA];
|
|
|
|
else
|
2022-04-14 15:01:32 +02:00
|
|
|
return L"Unknown HKEY. Please report.";
|
2008-08-10 13:52:44 +02:00
|
|
|
}
|
|
|
|
|
2003-08-07 05:10:13 +02:00
|
|
|
static void draw_splitbar(HWND hWnd, int x)
|
|
|
|
{
|
2003-12-08 23:48:07 +01:00
|
|
|
RECT rt;
|
|
|
|
HDC hdc = GetDC(hWnd);
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2003-12-08 23:48:07 +01:00
|
|
|
GetClientRect(hWnd, &rt);
|
|
|
|
rt.left = x - SPLIT_WIDTH/2;
|
|
|
|
rt.right = x + SPLIT_WIDTH/2+1;
|
|
|
|
InvertRect(hdc, &rt);
|
|
|
|
ReleaseDC(hWnd, hdc);
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|
|
|
|
|
2007-02-08 00:08:44 +01:00
|
|
|
static void ResizeWnd(int cx, int cy)
|
2003-08-07 05:10:13 +02:00
|
|
|
{
|
2003-12-08 23:48:07 +01:00
|
|
|
HDWP hdwp = BeginDeferWindowPos(2);
|
|
|
|
RECT rt = {0, 0, cx, cy};
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2007-02-08 00:08:44 +01:00
|
|
|
cx = g_pChildWnd->nSplitPos + SPLIT_WIDTH/2;
|
|
|
|
DeferWindowPos(hdwp, g_pChildWnd->hTreeWnd, 0, rt.left, rt.top, g_pChildWnd->nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
|
|
|
DeferWindowPos(hdwp, g_pChildWnd->hListWnd, 0, rt.left+cx , rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
2003-12-08 23:48:07 +01:00
|
|
|
EndDeferWindowPos(hdwp);
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void OnPaint(HWND hWnd)
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
RECT rt;
|
|
|
|
|
|
|
|
GetClientRect(hWnd, &rt);
|
2010-05-01 16:36:49 +02:00
|
|
|
BeginPaint(hWnd, &ps);
|
2003-12-05 01:09:54 +01:00
|
|
|
FillRect(ps.hdc, &rt, GetSysColorBrush(COLOR_BTNFACE));
|
2003-08-07 05:10:13 +02:00
|
|
|
EndPaint(hWnd, &ps);
|
|
|
|
}
|
|
|
|
|
2008-08-31 00:57:41 +02:00
|
|
|
static LPWSTR CombinePaths(LPCWSTR pPaths[], int nPaths) {
|
2008-08-10 13:52:44 +02:00
|
|
|
int i, len, pos;
|
|
|
|
LPWSTR combined;
|
|
|
|
for (i=0, len=0; i<nPaths; i++) {
|
|
|
|
if (pPaths[i] && *pPaths[i]) {
|
|
|
|
len += lstrlenW(pPaths[i])+1;
|
|
|
|
}
|
|
|
|
}
|
2017-07-27 14:25:17 +02:00
|
|
|
combined = heap_xalloc(len * sizeof(WCHAR));
|
2008-08-10 13:52:44 +02:00
|
|
|
*combined = '\0';
|
|
|
|
for (i=0, pos=0; i<nPaths; i++) {
|
|
|
|
if (pPaths[i] && *pPaths[i]) {
|
|
|
|
int llen = lstrlenW(pPaths[i]);
|
|
|
|
if (!*combined)
|
|
|
|
lstrcpyW(combined, pPaths[i]);
|
|
|
|
else {
|
2008-09-02 18:41:42 +02:00
|
|
|
combined[pos++] = '\\';
|
2008-08-10 13:52:44 +02:00
|
|
|
lstrcpyW(combined+pos, pPaths[i]);
|
|
|
|
}
|
|
|
|
pos += llen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return combined;
|
|
|
|
}
|
|
|
|
|
2008-08-31 00:57:41 +02:00
|
|
|
static LPWSTR GetPathRoot(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
|
2008-08-10 13:52:44 +02:00
|
|
|
LPCWSTR parts[2] = {0,0};
|
|
|
|
WCHAR text[260];
|
|
|
|
HKEY hRootKey = NULL;
|
|
|
|
if (!hItem)
|
2011-04-16 10:07:08 +02:00
|
|
|
hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CARET, 0);
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(GetItemPath(hwndTV, hItem, &hRootKey));
|
2008-08-10 13:52:44 +02:00
|
|
|
if (!bFull && !hRootKey)
|
|
|
|
return NULL;
|
|
|
|
if (hRootKey)
|
2008-09-02 18:43:57 +02:00
|
|
|
parts[1] = GetRootKeyName(hRootKey);
|
2008-08-10 13:52:44 +02:00
|
|
|
if (bFull) {
|
2018-05-21 15:34:56 +02:00
|
|
|
DWORD dwSize = ARRAY_SIZE(text);
|
2008-08-10 13:52:44 +02:00
|
|
|
GetComputerNameW(text, &dwSize);
|
|
|
|
parts[0] = text;
|
|
|
|
}
|
2008-08-31 00:57:41 +02:00
|
|
|
return CombinePaths(parts, 2);
|
2006-06-29 03:06:39 +02:00
|
|
|
}
|
|
|
|
|
2008-08-31 00:57:41 +02:00
|
|
|
LPWSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
|
2008-08-10 13:52:44 +02:00
|
|
|
LPWSTR parts[2];
|
|
|
|
LPWSTR ret;
|
|
|
|
HKEY hRootKey = NULL;
|
|
|
|
|
2008-08-31 00:57:41 +02:00
|
|
|
parts[0] = GetPathRoot(hwndTV, hItem, bFull);
|
|
|
|
parts[1] = GetItemPath(hwndTV, hItem, &hRootKey);
|
|
|
|
ret = CombinePaths((LPCWSTR *)parts, 2);
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(parts[0]);
|
|
|
|
heap_free(parts[1]);
|
2008-08-10 13:52:44 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-09-26 11:57:56 +02:00
|
|
|
static void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BOOL bRefreshLV)
|
|
|
|
{
|
|
|
|
if (bRefreshLV) {
|
2008-08-27 20:40:31 +02:00
|
|
|
LPWSTR keyPath;
|
2005-09-26 11:57:56 +02:00
|
|
|
HKEY hRootKey = NULL;
|
2017-01-28 14:37:52 +01:00
|
|
|
HTREEITEM rootitem;
|
|
|
|
|
|
|
|
rootitem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_ROOT, 0);
|
|
|
|
if (rootitem == hItem)
|
|
|
|
{
|
|
|
|
SendMessageW(hwndLV, LVM_DELETEALLITEMS, 0, 0);
|
2017-05-31 15:06:55 +02:00
|
|
|
UpdateStatusBar();
|
2017-01-28 14:37:52 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-31 00:57:41 +02:00
|
|
|
keyPath = GetItemPath(hwndTV, hItem, &hRootKey);
|
2005-09-26 11:57:56 +02:00
|
|
|
RefreshListView(hwndLV, hRootKey, keyPath, NULL);
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(keyPath);
|
2005-03-21 12:23:40 +01:00
|
|
|
}
|
2005-09-26 11:57:56 +02:00
|
|
|
UpdateStatusBar();
|
2005-03-21 12:23:40 +01:00
|
|
|
}
|
|
|
|
|
2007-02-18 17:14:39 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* finish_splitbar [internal]
|
|
|
|
*
|
|
|
|
* make the splitbar invisible and resize the windows
|
|
|
|
* (helper for ChildWndProc)
|
|
|
|
*/
|
|
|
|
static void finish_splitbar(HWND hWnd, int x)
|
|
|
|
{
|
|
|
|
RECT rt;
|
|
|
|
|
|
|
|
draw_splitbar(hWnd, last_split);
|
|
|
|
last_split = -1;
|
|
|
|
GetClientRect(hWnd, &rt);
|
|
|
|
g_pChildWnd->nSplitPos = x;
|
|
|
|
ResizeWnd(rt.right, rt.bottom);
|
|
|
|
ReleaseCapture();
|
|
|
|
}
|
|
|
|
|
2003-08-07 05:10:13 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
|
|
|
|
*
|
|
|
|
* PURPOSE: Processes WM_COMMAND messages for the main frame window.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2003-12-08 23:48:07 +01:00
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
/* Parse the menu selections: */
|
2003-08-07 05:10:13 +02:00
|
|
|
case ID_REGISTRY_EXIT:
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
break;
|
|
|
|
case ID_VIEW_REFRESH:
|
2005-01-10 17:03:22 +01:00
|
|
|
WINE_TRACE("Is this ever called or is it just dead code?\n");
|
2003-08-07 05:10:13 +02:00
|
|
|
/* TODO */
|
|
|
|
break;
|
2004-05-04 04:55:28 +02:00
|
|
|
case ID_SWITCH_PANELS:
|
2007-02-08 00:14:15 +01:00
|
|
|
g_pChildWnd->nFocusPanel = !g_pChildWnd->nFocusPanel;
|
|
|
|
SetFocus(g_pChildWnd->nFocusPanel? g_pChildWnd->hListWnd: g_pChildWnd->hTreeWnd);
|
2004-05-04 04:55:28 +02:00
|
|
|
break;
|
2003-08-07 05:10:13 +02:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-12-08 23:48:07 +01:00
|
|
|
return TRUE;
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|
|
|
|
|
2009-07-02 18:29:44 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* get_last_key [internal]
|
|
|
|
*
|
|
|
|
* open last key
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void get_last_key(HWND hwndTV)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
WCHAR wszVal[KEY_MAX_LEN];
|
|
|
|
DWORD dwSize = sizeof(wszVal);
|
|
|
|
|
|
|
|
if (RegCreateKeyExW(HKEY_CURRENT_USER, wszKeyName, 0, NULL, 0, KEY_READ, NULL, &hkey, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
2018-08-21 00:49:20 +02:00
|
|
|
HTREEITEM selection = NULL;
|
2009-07-02 18:29:44 +02:00
|
|
|
if (RegQueryValueExW(hkey, wszLastKey, NULL, NULL, (LPBYTE)wszVal, &dwSize) == ERROR_SUCCESS)
|
2015-06-13 18:26:22 +02:00
|
|
|
{
|
2019-04-01 11:47:50 +02:00
|
|
|
if (lstrcmpW(wszVal, g_pChildWnd->szPath))
|
2015-06-13 18:26:22 +02:00
|
|
|
selection = FindPathInTree(hwndTV, wszVal);
|
|
|
|
}
|
2009-07-02 18:29:44 +02:00
|
|
|
|
2018-08-21 00:49:20 +02:00
|
|
|
if(!selection)
|
|
|
|
{
|
|
|
|
selection = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
|
|
|
|
SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)selection );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)selection);
|
|
|
|
|
2009-07-02 18:29:44 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* set_last_key [internal]
|
|
|
|
*
|
|
|
|
* save last key
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void set_last_key(HWND hwndTV)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
if (RegCreateKeyExW(HKEY_CURRENT_USER, wszKeyName, 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
2011-04-16 10:07:08 +02:00
|
|
|
HTREEITEM selection = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_CARET, 0);
|
2015-06-13 18:26:22 +02:00
|
|
|
HTREEITEM root = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
|
|
|
|
WCHAR *value;
|
2011-04-16 10:07:08 +02:00
|
|
|
|
2015-06-13 18:26:22 +02:00
|
|
|
if (selection == root)
|
|
|
|
value = g_pChildWnd->szPath;
|
|
|
|
else
|
|
|
|
value = GetItemFullPath(g_pChildWnd->hTreeWnd, selection, FALSE);
|
|
|
|
RegSetValueExW(hkey, wszLastKey, 0, REG_SZ, (LPBYTE)value, (lstrlenW(value) + 1) * sizeof(WCHAR));
|
|
|
|
if (selection != root)
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(value);
|
2009-07-02 18:29:44 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-12 13:09:38 +02:00
|
|
|
static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (((NMHDR *)lParam)->code)
|
|
|
|
{
|
|
|
|
case NM_SETFOCUS:
|
|
|
|
g_pChildWnd->nFocusPanel = 0;
|
|
|
|
break;
|
|
|
|
case TVN_BEGINLABELEDITW:
|
|
|
|
{
|
|
|
|
HKEY hRootKey;
|
|
|
|
WCHAR *path;
|
|
|
|
|
|
|
|
if (!GetWindowLongPtrW(g_pChildWnd->hTreeWnd, GWLP_USERDATA))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
|
|
|
|
if (!path || !*path)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
case TVN_ENDLABELEDITW:
|
|
|
|
{
|
|
|
|
HKEY hRootKey;
|
|
|
|
NMTVDISPINFOW *dispInfo = (NMTVDISPINFOW *)lParam;
|
|
|
|
WCHAR *path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
|
|
|
|
BOOL res = RenameKey(hWnd, hRootKey, path, dispInfo->item.pszText);
|
|
|
|
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(path);
|
2017-07-12 13:09:38 +02:00
|
|
|
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
TVITEMW item;
|
|
|
|
|
|
|
|
item.mask = TVIF_HANDLE | TVIF_TEXT;
|
|
|
|
item.hItem = dispInfo->item.hItem;
|
|
|
|
item.pszText = dispInfo->item.pszText;
|
|
|
|
SendMessageW(g_pChildWnd->hTreeWnd, TVM_SETITEMW, 0, (LPARAM)&item);
|
|
|
|
|
|
|
|
path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
|
|
|
|
update_listview_path(path);
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(path);
|
2017-07-13 15:22:01 +02:00
|
|
|
|
|
|
|
UpdateStatusBar();
|
2017-07-12 13:09:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowLongPtrW(g_pChildWnd->hTreeWnd, GWLP_USERDATA, 0);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
case TVN_ITEMEXPANDINGW:
|
|
|
|
return !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEWW *)lParam);
|
|
|
|
case TVN_SELCHANGEDW:
|
|
|
|
OnTreeSelectionChanged(g_pChildWnd->hTreeWnd, g_pChildWnd->hListWnd,
|
|
|
|
((NMTREEVIEWW *)lParam)->itemNew.hItem, TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-07-12 13:09:49 +02:00
|
|
|
static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (((NMHDR *)lParam)->code)
|
|
|
|
{
|
|
|
|
case NM_DBLCLK:
|
|
|
|
{
|
|
|
|
NMITEMACTIVATE *nmitem = (NMITEMACTIVATE *)lParam;
|
|
|
|
|
2017-07-13 23:27:11 +02:00
|
|
|
if (nmitem->iItem != -1)
|
2017-07-12 13:09:49 +02:00
|
|
|
{
|
|
|
|
LVITEMW item;
|
|
|
|
|
|
|
|
item.state = 0;
|
|
|
|
item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
|
|
|
|
SendMessageW(g_pChildWnd->hListWnd, LVM_SETITEMSTATE, (UINT)-1, (LPARAM)&item);
|
|
|
|
|
|
|
|
item.state = LVIS_FOCUSED | LVIS_SELECTED;
|
|
|
|
item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
|
2017-07-13 23:27:11 +02:00
|
|
|
SendMessageW(g_pChildWnd->hListWnd, LVM_SETITEMSTATE, nmitem->iItem, (LPARAM)&item);
|
2017-07-12 13:09:49 +02:00
|
|
|
|
|
|
|
SendMessageW(hFrameWnd, WM_COMMAND, ID_EDIT_MODIFY, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NM_RETURN:
|
|
|
|
{
|
|
|
|
int cnt = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1,
|
|
|
|
MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0));
|
|
|
|
if (cnt != -1)
|
|
|
|
SendMessageW(hFrameWnd, WM_COMMAND, ID_EDIT_MODIFY, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NM_SETFOCUS:
|
|
|
|
g_pChildWnd->nFocusPanel = 1;
|
|
|
|
break;
|
|
|
|
case LVN_BEGINLABELEDITW:
|
|
|
|
if (!((NMLVDISPINFOW *)lParam)->item.iItem)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
case LVN_COLUMNCLICK:
|
|
|
|
if (g_columnToSort == ((NMLISTVIEW *)lParam)->iSubItem)
|
|
|
|
g_invertSort = !g_invertSort;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_columnToSort = ((NMLISTVIEW *)lParam)->iSubItem;
|
|
|
|
g_invertSort = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
SendMessageW(g_pChildWnd->hListWnd, LVM_SORTITEMS,
|
|
|
|
(WPARAM)g_pChildWnd->hListWnd, (LPARAM)CompareFunc);
|
|
|
|
break;
|
|
|
|
case LVN_DELETEITEM:
|
|
|
|
{
|
|
|
|
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
|
|
|
|
LINE_INFO *info = (LINE_INFO *)nmlv->lParam;
|
|
|
|
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(info->name);
|
2017-07-28 15:22:27 +02:00
|
|
|
heap_free(info->val);
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(info);
|
2017-07-12 13:09:49 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LVN_ENDLABELEDITW:
|
|
|
|
{
|
|
|
|
NMLVDISPINFOW *dispInfo = (NMLVDISPINFOW *)lParam;
|
|
|
|
WCHAR *oldName = GetItemText(g_pChildWnd->hListWnd, dispInfo->item.iItem);
|
|
|
|
LONG ret;
|
|
|
|
|
|
|
|
if (!oldName) return -1; /* cannot rename a default value */
|
|
|
|
ret = RenameValue(g_pChildWnd->hListWnd, g_currentRootKey, g_currentPath,
|
|
|
|
oldName, dispInfo->item.pszText);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
dispInfo->item.iSubItem = 0;
|
|
|
|
SendMessageW(g_pChildWnd->hListWnd, LVM_SETITEMTEXTW,
|
|
|
|
dispInfo->item.iItem, (LPARAM)&dispInfo->item);
|
|
|
|
}
|
|
|
|
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(oldName);
|
2017-07-12 13:09:49 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
case LVN_GETDISPINFOW:
|
|
|
|
OnGetDispInfo((NMLVDISPINFOW *)lParam);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-17 11:15:25 +02:00
|
|
|
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
|
|
|
|
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
|
|
|
|
|
2003-08-07 05:10:13 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: ChildWndProc(HWND, unsigned, WORD, LONG)
|
|
|
|
*
|
|
|
|
* PURPOSE: Processes messages for the child windows.
|
|
|
|
*
|
|
|
|
* WM_COMMAND - process the application menu
|
|
|
|
* WM_PAINT - Paint the main window
|
|
|
|
* WM_DESTROY - post a quit message and return
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (message) {
|
|
|
|
case WM_CREATE:
|
2017-07-27 14:25:17 +02:00
|
|
|
g_pChildWnd = heap_xalloc(sizeof(ChildWnd));
|
2007-02-08 00:14:15 +01:00
|
|
|
if (!g_pChildWnd) return 0;
|
2008-08-25 23:00:35 +02:00
|
|
|
LoadStringW(hInst, IDS_REGISTRY_ROOT_NAME, g_pChildWnd->szPath, MAX_PATH);
|
2007-02-08 00:14:15 +01:00
|
|
|
g_pChildWnd->nSplitPos = 250;
|
|
|
|
g_pChildWnd->hWnd = hWnd;
|
|
|
|
g_pChildWnd->hTreeWnd = CreateTreeView(hWnd, g_pChildWnd->szPath, TREE_WINDOW);
|
|
|
|
g_pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW/*, g_pChildWnd->szPath*/);
|
|
|
|
g_pChildWnd->nFocusPanel = 1;
|
|
|
|
SetFocus(g_pChildWnd->hTreeWnd);
|
2009-07-02 18:29:44 +02:00
|
|
|
get_last_key(g_pChildWnd->hTreeWnd);
|
2003-08-07 05:10:13 +02:00
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
|
|
|
|
goto def;
|
|
|
|
}
|
2003-12-08 23:48:07 +01:00
|
|
|
break;
|
2003-08-07 05:10:13 +02:00
|
|
|
case WM_PAINT:
|
|
|
|
OnPaint(hWnd);
|
|
|
|
return 0;
|
2003-12-08 23:48:07 +01:00
|
|
|
case WM_SETCURSOR:
|
|
|
|
if (LOWORD(lParam) == HTCLIENT) {
|
|
|
|
POINT pt;
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
ScreenToClient(hWnd, &pt);
|
2007-02-08 00:14:15 +01:00
|
|
|
if (pt.x>=g_pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<g_pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
2011-04-16 10:07:08 +02:00
|
|
|
SetCursor(LoadCursorW(0, (LPCWSTR)IDC_SIZEWE));
|
2003-12-08 23:48:07 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto def;
|
2003-08-07 05:10:13 +02:00
|
|
|
case WM_DESTROY:
|
2009-07-02 18:29:44 +02:00
|
|
|
set_last_key(g_pChildWnd->hTreeWnd);
|
2017-07-27 14:25:17 +02:00
|
|
|
heap_free(g_pChildWnd);
|
2007-02-08 00:14:15 +01:00
|
|
|
g_pChildWnd = NULL;
|
2003-08-07 05:10:13 +02:00
|
|
|
PostQuitMessage(0);
|
|
|
|
break;
|
2003-12-08 23:48:07 +01:00
|
|
|
case WM_LBUTTONDOWN: {
|
|
|
|
RECT rt;
|
2006-10-25 17:42:57 +02:00
|
|
|
int x = (short)LOWORD(lParam);
|
2003-12-08 23:48:07 +01:00
|
|
|
GetClientRect(hWnd, &rt);
|
2007-02-08 00:14:15 +01:00
|
|
|
if (x>=g_pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<g_pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
|
|
|
last_split = g_pChildWnd->nSplitPos;
|
2003-12-08 23:48:07 +01:00
|
|
|
draw_splitbar(hWnd, last_split);
|
|
|
|
SetCapture(hWnd);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2007-02-18 17:14:39 +01:00
|
|
|
/* WM_RBUTTONDOWN sets the splitbar the same way as WM_LBUTTONUP */
|
2003-12-08 23:48:07 +01:00
|
|
|
case WM_LBUTTONUP:
|
2007-02-18 17:14:39 +01:00
|
|
|
case WM_RBUTTONDOWN:
|
2003-12-08 23:48:07 +01:00
|
|
|
if (GetCapture() == hWnd) {
|
2007-02-18 17:14:39 +01:00
|
|
|
finish_splitbar(hWnd, LOWORD(lParam));
|
2003-12-08 23:48:07 +01:00
|
|
|
}
|
|
|
|
break;
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2003-12-08 23:48:07 +01:00
|
|
|
case WM_CAPTURECHANGED:
|
|
|
|
if (GetCapture()==hWnd && last_split>=0)
|
|
|
|
draw_splitbar(hWnd, last_split);
|
|
|
|
break;
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2017-07-12 13:09:49 +02:00
|
|
|
case WM_CONTEXTMENU:
|
|
|
|
{
|
2017-04-17 11:15:36 +02:00
|
|
|
POINT pt = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
|
2017-07-12 13:09:49 +02:00
|
|
|
short int menu_id = -1;
|
|
|
|
|
|
|
|
if ((HWND)wParam == g_pChildWnd->hTreeWnd)
|
|
|
|
{
|
|
|
|
TVHITTESTINFO ht;
|
|
|
|
|
|
|
|
ht.pt = pt;
|
|
|
|
ScreenToClient(g_pChildWnd->hTreeWnd, &ht.pt);
|
|
|
|
|
|
|
|
if (SendMessageW(g_pChildWnd->hTreeWnd, TVM_HITTEST, 0, (LPARAM)&ht))
|
|
|
|
{
|
|
|
|
HTREEITEM root;
|
|
|
|
|
|
|
|
SendMessageW(g_pChildWnd->hTreeWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)ht.hItem);
|
|
|
|
root = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
|
|
|
|
menu_id = (ht.hItem == root) ? PM_COMPUTER : PM_TREEVIEW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int sel = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1,
|
|
|
|
MAKELPARAM(LVNI_SELECTED, 0));
|
|
|
|
menu_id = (sel == -1) ? PM_NEW_VALUE : PM_MODIFY_VALUE;
|
2017-04-17 11:15:46 +02:00
|
|
|
}
|
2017-07-12 13:09:49 +02:00
|
|
|
|
|
|
|
TrackPopupMenu(GetSubMenu(hPopupMenus, menu_id), TPM_RIGHTBUTTON,
|
|
|
|
pt.x, pt.y, 0, hFrameWnd, NULL);
|
2017-05-01 11:30:21 +02:00
|
|
|
break;
|
2017-04-17 11:15:25 +02:00
|
|
|
}
|
|
|
|
|
2003-08-07 05:10:13 +02:00
|
|
|
case WM_KEYDOWN:
|
2003-12-08 23:48:07 +01:00
|
|
|
if (wParam == VK_ESCAPE)
|
|
|
|
if (GetCapture() == hWnd) {
|
|
|
|
RECT rt;
|
|
|
|
draw_splitbar(hWnd, last_split);
|
|
|
|
GetClientRect(hWnd, &rt);
|
2007-02-08 00:08:44 +01:00
|
|
|
ResizeWnd(rt.right, rt.bottom);
|
2003-12-08 23:48:07 +01:00
|
|
|
last_split = -1;
|
|
|
|
ReleaseCapture();
|
2011-04-16 10:07:08 +02:00
|
|
|
SetCursor(LoadCursorW(0, (LPCWSTR)IDC_ARROW));
|
2003-12-08 23:48:07 +01:00
|
|
|
}
|
|
|
|
break;
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2003-12-08 23:48:07 +01:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
if (GetCapture() == hWnd) {
|
|
|
|
RECT rt;
|
|
|
|
int x = LOWORD(lParam);
|
|
|
|
HDC hdc = GetDC(hWnd);
|
|
|
|
GetClientRect(hWnd, &rt);
|
|
|
|
rt.left = last_split-SPLIT_WIDTH/2;
|
|
|
|
rt.right = last_split+SPLIT_WIDTH/2+1;
|
|
|
|
InvertRect(hdc, &rt);
|
|
|
|
last_split = x;
|
|
|
|
rt.left = x-SPLIT_WIDTH/2;
|
|
|
|
rt.right = x+SPLIT_WIDTH/2+1;
|
|
|
|
InvertRect(hdc, &rt);
|
|
|
|
ReleaseDC(hWnd, hdc);
|
|
|
|
}
|
|
|
|
break;
|
2003-08-07 05:10:13 +02:00
|
|
|
|
2003-12-08 23:48:07 +01:00
|
|
|
case WM_SETFOCUS:
|
2007-02-08 00:14:15 +01:00
|
|
|
if (g_pChildWnd != NULL) {
|
|
|
|
SetFocus(g_pChildWnd->nFocusPanel? g_pChildWnd->hListWnd: g_pChildWnd->hTreeWnd);
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|
2003-12-08 23:48:07 +01:00
|
|
|
break;
|
2003-08-07 05:10:13 +02:00
|
|
|
|
|
|
|
case WM_TIMER:
|
|
|
|
break;
|
|
|
|
|
2003-12-08 23:48:07 +01:00
|
|
|
case WM_NOTIFY:
|
2017-07-12 13:09:38 +02:00
|
|
|
if (wParam == TREE_WINDOW && g_pChildWnd)
|
|
|
|
return treeview_notify(hWnd, message, wParam, lParam);
|
|
|
|
else if (wParam == LIST_WINDOW && g_pChildWnd)
|
2017-07-12 13:09:49 +02:00
|
|
|
return listview_notify(hWnd, message, wParam, lParam);
|
2003-08-07 05:10:13 +02:00
|
|
|
break;
|
|
|
|
|
2003-12-08 23:48:07 +01:00
|
|
|
case WM_SIZE:
|
2007-02-08 00:14:15 +01:00
|
|
|
if (wParam != SIZE_MINIMIZED && g_pChildWnd != NULL) {
|
2007-02-08 00:08:44 +01:00
|
|
|
ResizeWnd(LOWORD(lParam), HIWORD(lParam));
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|
|
|
|
/* fall through */
|
2003-12-08 23:48:07 +01:00
|
|
|
default: def:
|
2011-04-16 10:06:48 +02:00
|
|
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
2003-12-08 23:48:07 +01:00
|
|
|
}
|
|
|
|
return 0;
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|