mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 05:30:50 +00:00
- Added Find functions
- Some refactoring that made Find functions possible - GetItemPath returns a heap-allocated string - subtree update put into a separate function UpdateExpandingTree - error() utility function made public - Find functions are grayed/ungrayed based on context (which fixes invalid 'grayed' flag in some localizations). - InvalidateRect to fix display glitches coming from using WM_SETREDRAW. - English and Polish resource updates (Find dialog box and Find menu options, string not found message).
This commit is contained in:
parent
0c6d54631f
commit
e4e75a2a06
|
@ -60,8 +60,8 @@ BEGIN
|
|||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Copy Key Name", ID_EDIT_COPYKEYNAME
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Find\tCtrl+F", ID_EDIT_FIND, GRAYED
|
||||
MENUITEM "Find Ne&xt\tF3", ID_EDIT_FINDNEXT, GRAYED
|
||||
MENUITEM "&Find\tCtrl+F", ID_EDIT_FIND
|
||||
MENUITEM "Find Ne&xt\tF3", ID_EDIT_FINDNEXT
|
||||
END
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
|
@ -207,6 +207,22 @@ BEGIN
|
|||
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_FIND DIALOG DISCARDABLE 22, 17, 210, 85
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Find"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "Find:",IDC_STATIC,5,7,119,8
|
||||
EDITTEXT IDC_VALUE_NAME,40,5,125,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL
|
||||
LTEXT "Find in:",IDC_STATIC,5, 22, 119, 8
|
||||
CHECKBOX "Keys", IDC_FIND_KEYS, 5, 34, 90, 10, WS_TABSTOP | WS_GROUP | BS_AUTOCHECKBOX
|
||||
CHECKBOX "Value names", IDC_FIND_VALUES, 5, 46, 90, 10, WS_TABSTOP | BS_AUTOCHECKBOX
|
||||
CHECKBOX "Value content", IDC_FIND_CONTENT, 5, 58, 90, 10, WS_TABSTOP | BS_AUTOCHECKBOX
|
||||
CHECKBOX "Whole string only", IDC_FIND_WHOLE, 5, 70, 90, 10, WS_TABSTOP | BS_AUTOCHECKBOX
|
||||
DEFPUSHBUTTON "Find",IDOK,175,5,30,11,WS_GROUP
|
||||
PUSHBUTTON "Close",IDCANCEL,175,22,30,11, WS_GROUP
|
||||
END
|
||||
|
||||
IDD_ADDFAVORITE DIALOG DISCARDABLE 22, 17, 210, 55
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Add Favorite"
|
||||
|
@ -344,6 +360,7 @@ BEGIN
|
|||
IDS_DELETE_BOX_TEXT "Are you sure you want to delete value '%s'?"
|
||||
IDS_NEWKEY "New Key #%d"
|
||||
IDS_NEWVALUE "New Value #%d"
|
||||
IDS_NOTFOUND "Search string '%s' not found"
|
||||
END
|
||||
|
||||
/*****************************************************************/
|
||||
|
|
|
@ -68,8 +68,8 @@ BEGIN
|
|||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Kopiuj nazwê klucza", ID_EDIT_COPYKEYNAME
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&ZnajdŸ...\tCtrl+F", ID_EDIT_FIND, GRAYED
|
||||
MENUITEM "Zn&ajdŸ nastêpny\tF3", ID_EDIT_FINDNEXT, GRAYED
|
||||
MENUITEM "&ZnajdŸ...\tCtrl+F", ID_EDIT_FIND
|
||||
MENUITEM "Zn&ajdŸ nastêpny\tF3", ID_EDIT_FINDNEXT
|
||||
END
|
||||
POPUP "&Widok"
|
||||
BEGIN
|
||||
|
@ -139,6 +139,22 @@ BEGIN
|
|||
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
|
||||
END
|
||||
|
||||
IDD_FIND DIALOG DISCARDABLE 22, 17, 210, 85
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Wyszukaj w rejestrze"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "ZnajdŸ:",IDC_STATIC,5,7,119,8
|
||||
EDITTEXT IDC_VALUE_NAME,40,5,125,12, WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL
|
||||
LTEXT "Szukaj w:",IDC_STATIC,5, 22, 119, 8
|
||||
CHECKBOX "Kluczach", IDC_FIND_KEYS, 5, 34, 90, 10, WS_TABSTOP | WS_GROUP | BS_AUTOCHECKBOX
|
||||
CHECKBOX "Nazwach wartoœci", IDC_FIND_VALUES, 5, 46, 90, 10, WS_TABSTOP | BS_AUTOCHECKBOX
|
||||
CHECKBOX "Treœci wartoœci", IDC_FIND_CONTENT, 5, 58, 90, 10, WS_TABSTOP | BS_AUTOCHECKBOX
|
||||
CHECKBOX "Tylko pe³ne dopasowanie", IDC_FIND_WHOLE, 5, 70, 120, 10, WS_TABSTOP | BS_AUTOCHECKBOX
|
||||
DEFPUSHBUTTON "ZnajdŸ",IDOK,175,5,30,11,WS_GROUP
|
||||
PUSHBUTTON "Zamknij",IDCANCEL,175,22,30,11, WS_GROUP
|
||||
END
|
||||
|
||||
IDD_ADDFAVORITE DIALOG DISCARDABLE 22, 17, 210, 55
|
||||
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dodaj do ulubionych"
|
||||
|
@ -263,6 +279,7 @@ BEGIN
|
|||
IDS_DELETE_BOX_TEXT "Jesteœ pewien, ¿e chcesz usun¹æ dan¹ '%s'?"
|
||||
IDS_NEWKEY "Nowy klucz #%d"
|
||||
IDS_NEWVALUE "Nowa dana #%d"
|
||||
IDS_NOTFOUND "Nie uda³o siê wyszukaæ ci¹gu '%s'"
|
||||
END
|
||||
|
||||
/*****************************************************************/
|
||||
|
|
|
@ -75,7 +75,7 @@ static INT messagebox(HWND hwnd, INT buttons, INT titleId, INT resId, ...)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void error(HWND hwnd, INT resId, ...)
|
||||
void error(HWND hwnd, INT resId, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
static TCHAR favoritesKey[] = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\RegEdit\\Favorites");
|
||||
static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
|
||||
static TCHAR favoriteName[128];
|
||||
static TCHAR searchString[128];
|
||||
static int searchMask = SEARCH_KEYS | SEARCH_VALUES | SEARCH_CONTENT;
|
||||
|
||||
/*******************************************************************************
|
||||
* Local module support methods
|
||||
|
@ -101,6 +103,8 @@ static void UpdateMenuItems(HMENU hMenu) {
|
|||
if (keyName && *keyName) { /* can't modify root keys */
|
||||
bIsKeySelected = TRUE;
|
||||
}
|
||||
EnableMenuItem(hMenu, ID_EDIT_FIND, MF_ENABLED | MF_BYCOMMAND);
|
||||
EnableMenuItem(hMenu, ID_EDIT_FINDNEXT, MF_ENABLED | MF_BYCOMMAND);
|
||||
EnableMenuItem(hMenu, ID_EDIT_MODIFY, (bIsKeySelected ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
|
||||
EnableMenuItem(hMenu, ID_EDIT_DELETE, (bIsKeySelected ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
|
||||
EnableMenuItem(hMenu, ID_EDIT_RENAME, (bIsKeySelected ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
|
||||
|
@ -469,6 +473,49 @@ static BOOL CopyKeyName(HWND hWnd, LPCTSTR keyName)
|
|||
return result;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK find_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_NAME);
|
||||
|
||||
switch(uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
|
||||
CheckDlgButton(hwndDlg, IDC_FIND_KEYS, searchMask&SEARCH_KEYS ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_FIND_VALUES, searchMask&SEARCH_VALUES ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_FIND_CONTENT, searchMask&SEARCH_CONTENT ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hwndDlg, IDC_FIND_WHOLE, searchMask&SEARCH_WHOLE ? BST_CHECKED : BST_UNCHECKED);
|
||||
SendMessage(hwndValue, EM_SETLIMITTEXT, 127, 0);
|
||||
SetWindowText(hwndValue, searchString);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(wParam)) {
|
||||
case IDC_VALUE_NAME:
|
||||
if (HIWORD(wParam) == EN_UPDATE) {
|
||||
EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(hwndValue)>0);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case IDOK:
|
||||
if (GetWindowTextLength(hwndValue)>0) {
|
||||
int mask = 0;
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_KEYS)) mask |= SEARCH_KEYS;
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_VALUES)) mask |= SEARCH_VALUES;
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_CONTENT)) mask |= SEARCH_CONTENT;
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_FIND_WHOLE)) mask |= SEARCH_WHOLE;
|
||||
searchMask = mask;
|
||||
GetWindowText(hwndValue, searchString, 128);
|
||||
EndDialog(hwndDlg, IDOK);
|
||||
}
|
||||
return TRUE;
|
||||
case IDCANCEL:
|
||||
EndDialog(hwndDlg, IDCANCEL);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK addtofavorites_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_NAME);
|
||||
|
@ -630,6 +677,38 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
if (ModifyValue(hWnd, hKeyRoot, keyPath, valueName))
|
||||
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, valueName);
|
||||
break;
|
||||
case ID_EDIT_FIND:
|
||||
case ID_EDIT_FINDNEXT:
|
||||
{
|
||||
HTREEITEM hItem;
|
||||
if (LOWORD(wParam) == ID_EDIT_FIND &&
|
||||
DialogBox(0, MAKEINTRESOURCE(IDD_FIND), hWnd, find_dlgproc) != IDOK)
|
||||
break;
|
||||
if (!*searchString)
|
||||
break;
|
||||
hItem = TreeView_GetSelection(g_pChildWnd->hTreeWnd);
|
||||
if (hItem) {
|
||||
int row = ListView_GetNextItem(g_pChildWnd->hListWnd, -1, LVNI_FOCUSED);
|
||||
HCURSOR hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
|
||||
hItem = FindNext(g_pChildWnd->hTreeWnd, hItem, searchString, searchMask, &row);
|
||||
SetCursor(hcursorOld);
|
||||
if (hItem) {
|
||||
TreeView_SelectItem(g_pChildWnd->hTreeWnd, hItem);
|
||||
InvalidateRect(g_pChildWnd->hTreeWnd, NULL, TRUE);
|
||||
UpdateWindow(g_pChildWnd->hTreeWnd);
|
||||
if (row != -1) {
|
||||
ListView_SetItemState(g_pChildWnd->hListWnd, -1, 0, LVIS_FOCUSED|LVIS_SELECTED);
|
||||
ListView_SetItemState(g_pChildWnd->hListWnd, row, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
|
||||
SetFocus(g_pChildWnd->hListWnd);
|
||||
} else {
|
||||
SetFocus(g_pChildWnd->hTreeWnd);
|
||||
}
|
||||
} else {
|
||||
error(hWnd, IDS_NOTFOUND, searchString);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ID_EDIT_COPYKEYNAME:
|
||||
{
|
||||
LPTSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE);
|
||||
|
|
|
@ -58,6 +58,13 @@ enum OPTION_FLAGS {
|
|||
OPTIONS_VIEW_DATA_ONLY = 0x40,
|
||||
};
|
||||
|
||||
enum SEARCH_FLAGS {
|
||||
SEARCH_WHOLE = 0x01,
|
||||
SEARCH_KEYS = 0x02,
|
||||
SEARCH_VALUES = 0x04,
|
||||
SEARCH_CONTENT = 0x08,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
HWND hWnd;
|
||||
HWND hTreeWnd;
|
||||
|
@ -110,11 +117,12 @@ extern BOOL IsDefaultValue(HWND hwndLV, int i);
|
|||
extern HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id);
|
||||
extern BOOL RefreshTreeView(HWND hWndTV);
|
||||
extern BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv);
|
||||
extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
|
||||
extern LPTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
|
||||
extern BOOL DeleteNode(HWND hwndTV, HTREEITEM hItem);
|
||||
extern HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name);
|
||||
extern HWND StartKeyRename(HWND hwndTV);
|
||||
extern HTREEITEM FindPathInTree(HWND hwndTV, LPCTSTR lpKeyName);
|
||||
extern HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode, int *row);
|
||||
|
||||
/* edit.c */
|
||||
extern BOOL CreateKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPTSTR newKeyName);
|
||||
|
@ -124,6 +132,7 @@ extern BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath);
|
|||
extern BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath, LPCTSTR valueName);
|
||||
extern BOOL RenameValue(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR oldName, LPCTSTR newName);
|
||||
extern BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCTSTR keyPath, LPCTSTR newName);
|
||||
extern void error(HWND hwnd, INT resId, ...);
|
||||
|
||||
/* hexedit.c */
|
||||
extern void HexEdit_Register(void);
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#define IDI_ROOT 134
|
||||
#define IDD_DELFAVORITE 134
|
||||
#define IDI_STRING 135
|
||||
#define IDD_FIND 135
|
||||
#define IDI_BIN 136
|
||||
#define IDR_POPUP_MENUS 137
|
||||
#define IDC_LICENSE_EDIT 1029
|
||||
|
@ -113,6 +114,7 @@
|
|||
#define IDS_TOO_BIG_VALUE 32839
|
||||
#define IDS_DELETE_BOX_TITLE 32840
|
||||
#define IDS_DELETE_BOX_TEXT 32841
|
||||
#define IDS_NOTFOUND 32842
|
||||
#define IDD_EDIT_DWORD 32850
|
||||
#define IDC_DWORD_BASE 32852
|
||||
#define IDC_DWORD_HEX 32853
|
||||
|
@ -128,7 +130,11 @@
|
|||
#define IDD_EDIT_STRING 2000
|
||||
#define IDC_VALUE_NAME 2001
|
||||
#define IDC_VALUE_DATA 2002
|
||||
#define IDD_EDIT_BINARY 2003
|
||||
#define IDC_NAME_LIST 2004
|
||||
#define IDD_EDIT_BINARY 2003
|
||||
#define IDC_NAME_LIST 2004
|
||||
#define IDC_FIND_KEYS 2005
|
||||
#define IDC_FIND_VALUES 2006
|
||||
#define IDC_FIND_CONTENT 2007
|
||||
#define IDC_FIND_WHOLE 2008
|
||||
|
||||
#define IDC_STATIC -1
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
#include <wine/debug.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "regproc.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(regedit);
|
||||
|
||||
|
@ -41,12 +43,12 @@ int Image_Open;
|
|||
int Image_Closed;
|
||||
int Image_Root;
|
||||
|
||||
static LPTSTR pathBuffer;
|
||||
|
||||
#define CX_ICON 16
|
||||
#define CY_ICON 16
|
||||
#define NUM_ICONS 3
|
||||
|
||||
static BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state);
|
||||
|
||||
static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKeyPath, int* pPathLen, int* pMaxLen)
|
||||
{
|
||||
TVITEM item;
|
||||
|
@ -89,11 +91,12 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPTSTR* pKe
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
|
||||
LPTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
|
||||
{
|
||||
int pathLen = 0, maxLen;
|
||||
TCHAR *pathBuffer;
|
||||
|
||||
if (!pathBuffer) pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024);
|
||||
pathBuffer = HeapAlloc(GetProcessHeap(), 0, 1024);
|
||||
if (!pathBuffer) return NULL;
|
||||
*pathBuffer = 0;
|
||||
maxLen = HeapSize(GetProcessHeap(), 0, pathBuffer);
|
||||
|
@ -153,9 +156,9 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCTSTR lpKeyName) {
|
|||
}
|
||||
hItem = TreeView_GetNextSibling(hwndTV, hItem);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, lpItemName);
|
||||
if (!hItem)
|
||||
return hOldItem;
|
||||
HeapFree(GetProcessHeap(), 0, lpItemName);
|
||||
}
|
||||
else
|
||||
return hItem;
|
||||
|
@ -194,17 +197,151 @@ static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HK
|
|||
return TreeView_InsertItem(hwndTV, &tvins);
|
||||
}
|
||||
|
||||
static BOOL match_string(LPCTSTR sstring1, LPCTSTR sstring2, int mode)
|
||||
{
|
||||
if (mode & SEARCH_WHOLE)
|
||||
return !stricmp(sstring1, sstring2);
|
||||
else
|
||||
return NULL != StrStrI(sstring1, sstring2);
|
||||
}
|
||||
|
||||
static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode, int *row)
|
||||
{
|
||||
TVITEM item;
|
||||
TCHAR keyname[KEY_MAX_LEN];
|
||||
item.mask = TVIF_TEXT;
|
||||
item.hItem = hItem;
|
||||
item.pszText = keyname;
|
||||
item.cchTextMax = KEY_MAX_LEN;
|
||||
if (!TreeView_GetItem(hwndTV, &item)) return FALSE;
|
||||
if ((mode & SEARCH_KEYS) && match_string(keyname, sstring, mode)) {
|
||||
*row = -1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (mode & (SEARCH_VALUES | SEARCH_CONTENT)) {
|
||||
int i, adjust;
|
||||
TCHAR valName[KEY_MAX_LEN], *KeyPath;
|
||||
HKEY hKey, hRoot;
|
||||
DWORD lenName;
|
||||
|
||||
KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
|
||||
|
||||
if (!KeyPath || !hRoot)
|
||||
return FALSE;
|
||||
|
||||
if (RegOpenKeyEx(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
|
||||
HeapFree(GetProcessHeap(), 0, KeyPath);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, KeyPath);
|
||||
lenName = KEY_MAX_LEN;
|
||||
adjust = 0;
|
||||
/* RegEnumValue won't return empty default value, so fake it when dealing with *row,
|
||||
which corresponds to list view rows, not value ids */
|
||||
if (ERROR_SUCCESS == RegEnumValue(hKey, 0, valName, &lenName, NULL, NULL, NULL, NULL) && *valName)
|
||||
adjust = 1;
|
||||
|
||||
i = (*row)-adjust;
|
||||
if (i < 0) i = 0;
|
||||
while(1) {
|
||||
DWORD lenValue = 0, type = 0;
|
||||
lenName = KEY_MAX_LEN;
|
||||
|
||||
if (ERROR_SUCCESS != RegEnumValue(hKey,
|
||||
i, valName, &lenName, NULL, &type, NULL, &lenValue))
|
||||
break;
|
||||
|
||||
if (mode & SEARCH_VALUES) {
|
||||
if (match_string(valName, sstring, mode)) {
|
||||
RegCloseKey(hKey);
|
||||
*row = i+adjust;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mode & SEARCH_CONTENT) && (type == REG_EXPAND_SZ || type == REG_SZ)) {
|
||||
LPTSTR buffer;
|
||||
buffer = HeapAlloc(GetProcessHeap(), 0, lenValue);
|
||||
RegEnumValue(hKey, i, valName, &lenName, NULL, &type, (LPBYTE)buffer, &lenValue);
|
||||
if (match_string(buffer, sstring, mode)) {
|
||||
HeapFree(GetProcessHeap(), 0, buffer);
|
||||
RegCloseKey(hKey);
|
||||
*row = i+adjust;
|
||||
return TRUE;
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, buffer);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HTREEITEM FindNext(HWND hwndTV, HTREEITEM hItem, LPCTSTR sstring, int mode, int *row)
|
||||
{
|
||||
HTREEITEM hTry, hLast;
|
||||
|
||||
hLast = hItem;
|
||||
(*row)++;
|
||||
if (match_item(hwndTV, hLast, sstring, mode & ~SEARCH_KEYS, row)) {
|
||||
return hLast;
|
||||
}
|
||||
*row = 0;
|
||||
|
||||
while(hLast) {
|
||||
/* first look in subtree */
|
||||
/* no children? maybe we haven't loaded them yet? */
|
||||
if (!TreeView_GetChild(hwndTV, hLast)) {
|
||||
UpdateExpandingTree(hwndTV, hLast, TreeView_GetItemState(hwndTV, hLast, -1));
|
||||
}
|
||||
hTry = TreeView_GetChild(hwndTV, hLast);
|
||||
if (hTry) {
|
||||
if (match_item(hwndTV, hTry, sstring, mode, row))
|
||||
return hTry;
|
||||
hLast = hTry;
|
||||
continue;
|
||||
}
|
||||
/* no more children, maybe there are any siblings? */
|
||||
hTry = TreeView_GetNextSibling(hwndTV, hLast);
|
||||
if (hTry) {
|
||||
if (match_item(hwndTV, hTry, sstring, mode, row))
|
||||
return hTry;
|
||||
hLast = hTry;
|
||||
continue;
|
||||
}
|
||||
/* no more siblings, look at the next siblings in parent(s) */
|
||||
hLast = TreeView_GetParent(hwndTV, hLast);
|
||||
if (!hLast)
|
||||
return NULL;
|
||||
while (hLast && (hTry = TreeView_GetNextSibling(hwndTV, hLast)) == NULL) {
|
||||
hLast = TreeView_GetParent(hwndTV, hLast);
|
||||
}
|
||||
if (match_item(hwndTV, hTry, sstring, mode, row))
|
||||
return hTry;
|
||||
hLast = hTry;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
|
||||
{
|
||||
HKEY hRoot, hKey, hSubKey;
|
||||
HTREEITEM childItem;
|
||||
LPCTSTR KeyPath;
|
||||
LPTSTR KeyPath;
|
||||
DWORD dwCount, dwIndex, dwMaxSubKeyLen;
|
||||
LPSTR Name;
|
||||
TVITEM tvItem;
|
||||
|
||||
hRoot = NULL;
|
||||
KeyPath = GetItemPath(hwndTV, hItem, &hRoot);
|
||||
|
||||
if (!KeyPath || !hRoot)
|
||||
return FALSE;
|
||||
|
||||
if (*KeyPath) {
|
||||
if (RegOpenKeyEx(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
|
||||
WINE_TRACE("RegOpenKeyEx failed, \"%s\" was probably removed.\n", KeyPath);
|
||||
|
@ -213,6 +350,7 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
|
|||
} else {
|
||||
hKey = hRoot;
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, KeyPath);
|
||||
|
||||
if (RegQueryInfoKey(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
|
||||
return FALSE;
|
||||
|
@ -269,7 +407,7 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!strcmp(tvItem.pszText, Name)) {
|
||||
if (!stricmp(tvItem.pszText, Name)) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -315,6 +453,7 @@ BOOL RefreshTreeView(HWND hwndTV)
|
|||
}
|
||||
|
||||
SendMessage(hwndTV, WM_SETREDRAW, TRUE, 0);
|
||||
InvalidateRect(hwndTV, NULL, FALSE);
|
||||
SetCursor(hcursorOld);
|
||||
|
||||
/* We reselect the currently selected node, this will prompt a refresh of the listview. */
|
||||
|
@ -437,25 +576,25 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
|
||||
BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state)
|
||||
{
|
||||
DWORD dwCount, dwIndex, dwMaxSubKeyLen;
|
||||
HKEY hRoot, hNewKey, hKey;
|
||||
LPCTSTR keyPath;
|
||||
LPTSTR keyPath;
|
||||
LPTSTR Name;
|
||||
LONG errCode;
|
||||
HCURSOR hcursorOld;
|
||||
|
||||
static int expanding;
|
||||
if (expanding) return FALSE;
|
||||
if (pnmtv->itemNew.state & TVIS_EXPANDEDONCE ) {
|
||||
if (state & TVIS_EXPANDEDONCE ) {
|
||||
return TRUE;
|
||||
}
|
||||
expanding = TRUE;
|
||||
hcursorOld = SetCursor(LoadCursor(NULL, IDC_WAIT));
|
||||
SendMessage(hwndTV, WM_SETREDRAW, FALSE, 0);
|
||||
|
||||
keyPath = GetItemPath(hwndTV, pnmtv->itemNew.hItem, &hRoot);
|
||||
keyPath = GetItemPath(hwndTV, hItem, &hRoot);
|
||||
if (!keyPath) goto done;
|
||||
|
||||
if (*keyPath) {
|
||||
|
@ -482,19 +621,27 @@ BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
|
|||
RegCloseKey(hKey);
|
||||
}
|
||||
if (errCode != ERROR_SUCCESS) dwSubCount = 0;
|
||||
AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwSubCount);
|
||||
AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
|
||||
}
|
||||
RegCloseKey(hNewKey);
|
||||
HeapFree(GetProcessHeap(), 0, Name);
|
||||
|
||||
done:
|
||||
TreeView_SetItemState(hwndTV, hItem, TVIS_EXPANDEDONCE, TVIS_EXPANDEDONCE);
|
||||
SendMessage(hwndTV, WM_SETREDRAW, TRUE, 0);
|
||||
SetCursor(hcursorOld);
|
||||
expanding = FALSE;
|
||||
if (keyPath)
|
||||
HeapFree(GetProcessHeap(), 0, keyPath);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv)
|
||||
{
|
||||
return UpdateExpandingTree(hwndTV, pnmtv->itemNew.hItem, pnmtv->itemNew.state);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CreateTreeView - creates a tree view control.
|
||||
|
|
Loading…
Reference in a new issue