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>
|
2003-12-12 05:08:59 +01:00
|
|
|
#include <tchar.h>
|
|
|
|
#include <stdio.h>
|
2003-08-07 05:10:13 +02:00
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
2004-05-04 04:55:28 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* Local module support methods
|
|
|
|
*/
|
|
|
|
|
2005-09-26 11:57:56 +02:00
|
|
|
LPCTSTR GetRootKeyName(HKEY hRootKey)
|
2003-08-07 05:10:13 +02:00
|
|
|
{
|
2003-12-12 05:08:59 +01:00
|
|
|
if (hRootKey == HKEY_CLASSES_ROOT) return _T("HKEY_CLASSES_ROOT");
|
|
|
|
if (hRootKey == HKEY_CURRENT_USER) return _T("HKEY_CURRENT_USER");
|
|
|
|
if (hRootKey == HKEY_LOCAL_MACHINE) return _T("HKEY_LOCAL_MACHINE");
|
|
|
|
if (hRootKey == HKEY_USERS) return _T("HKEY_USERS");
|
|
|
|
if (hRootKey == HKEY_CURRENT_CONFIG) return _T("HKEY_CURRENT_CONFIG");
|
2004-07-08 22:14:10 +02:00
|
|
|
if (hRootKey == HKEY_DYN_DATA) return _T("HKEY_DYN_DATA");
|
2005-09-26 11:57:56 +02:00
|
|
|
return _T("UNKNOWN HKEY, PLEASE REPORT");
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|
|
|
|
|
2008-08-10 13:52:44 +02:00
|
|
|
LPCWSTR GetRootKeyNameW(HKEY hRootKey)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
static const WCHAR unknown_key[] = {'U','N','K','N','O','W','N',' ','H','K','E','Y',',',' ',
|
|
|
|
'P','L','E','A','S','E',' ','R','E','P','O','R','T',0};
|
|
|
|
return unknown_key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
GetClientRect(hWnd, &rt);
|
|
|
|
hdc = 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);
|
|
|
|
}
|
|
|
|
|
2005-09-26 11:57:56 +02:00
|
|
|
static LPTSTR CombinePaths(LPCTSTR pPaths[], int nPaths) {
|
|
|
|
int i, len, pos;
|
|
|
|
LPTSTR combined;
|
|
|
|
for (i=0, len=0; i<nPaths; i++) {
|
|
|
|
if (pPaths[i] && *pPaths[i]) {
|
|
|
|
len += lstrlen(pPaths[i])+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
combined = HeapAlloc(GetProcessHeap(), 0, len * sizeof(TCHAR));
|
|
|
|
*combined = '\0';
|
|
|
|
for (i=0, pos=0; i<nPaths; i++) {
|
|
|
|
if (pPaths[i] && *pPaths[i]) {
|
|
|
|
int llen = _tcslen(pPaths[i]);
|
|
|
|
if (!*combined)
|
|
|
|
_tcscpy(combined, pPaths[i]);
|
|
|
|
else {
|
|
|
|
combined[pos++] = (TCHAR)'\\';
|
|
|
|
_tcscpy(combined+pos, pPaths[i]);
|
|
|
|
}
|
|
|
|
pos += llen;
|
2005-03-21 12:23:40 +01:00
|
|
|
}
|
|
|
|
}
|
2005-09-26 11:57:56 +02:00
|
|
|
return combined;
|
|
|
|
}
|
|
|
|
|
2008-08-10 13:52:44 +02:00
|
|
|
static LPWSTR CombinePathsW(LPCWSTR pPaths[], int nPaths) {
|
|
|
|
int i, len, pos;
|
|
|
|
LPWSTR combined;
|
|
|
|
for (i=0, len=0; i<nPaths; i++) {
|
|
|
|
if (pPaths[i] && *pPaths[i]) {
|
|
|
|
len += lstrlenW(pPaths[i])+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
combined = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
*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 {
|
|
|
|
combined[pos++] = (TCHAR)'\\';
|
|
|
|
lstrcpyW(combined+pos, pPaths[i]);
|
|
|
|
}
|
|
|
|
pos += llen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return combined;
|
|
|
|
}
|
|
|
|
|
2006-06-29 03:06:39 +02:00
|
|
|
static LPTSTR GetPathRoot(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
|
|
|
|
LPCTSTR parts[2] = {_T(""), _T("")};
|
2005-09-26 11:57:56 +02:00
|
|
|
TCHAR text[260];
|
|
|
|
HKEY hRootKey = NULL;
|
|
|
|
if (!hItem)
|
|
|
|
hItem = TreeView_GetSelection(hwndTV);
|
2006-06-29 03:06:39 +02:00
|
|
|
GetItemPath(hwndTV, hItem, &hRootKey);
|
|
|
|
if (!bFull && !hRootKey)
|
2005-09-26 11:57:56 +02:00
|
|
|
return NULL;
|
|
|
|
if (hRootKey)
|
|
|
|
parts[1] = GetRootKeyName(hRootKey);
|
|
|
|
if (bFull) {
|
|
|
|
DWORD dwSize = sizeof(text)/sizeof(TCHAR);
|
|
|
|
GetComputerName(text, &dwSize);
|
|
|
|
parts[0] = text;
|
|
|
|
}
|
2006-06-29 03:06:39 +02:00
|
|
|
return CombinePaths(parts, 2);
|
|
|
|
}
|
|
|
|
|
2008-08-10 13:52:44 +02:00
|
|
|
static LPWSTR GetPathRootW(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
|
|
|
|
LPCWSTR parts[2] = {0,0};
|
|
|
|
WCHAR text[260];
|
|
|
|
HKEY hRootKey = NULL;
|
|
|
|
if (!hItem)
|
|
|
|
hItem = TreeView_GetSelection(hwndTV);
|
|
|
|
GetItemPathW(hwndTV, hItem, &hRootKey);
|
|
|
|
if (!bFull && !hRootKey)
|
|
|
|
return NULL;
|
|
|
|
if (hRootKey)
|
|
|
|
parts[1] = GetRootKeyNameW(hRootKey);
|
|
|
|
if (bFull) {
|
|
|
|
DWORD dwSize = sizeof(text)/sizeof(TCHAR);
|
|
|
|
GetComputerNameW(text, &dwSize);
|
|
|
|
parts[0] = text;
|
|
|
|
}
|
|
|
|
return CombinePathsW(parts, 2);
|
|
|
|
}
|
|
|
|
|
2006-06-29 03:06:39 +02:00
|
|
|
LPTSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
|
2006-08-16 21:14:08 +02:00
|
|
|
LPTSTR parts[2];
|
2006-06-29 03:06:39 +02:00
|
|
|
LPTSTR ret;
|
2006-08-16 21:14:08 +02:00
|
|
|
HKEY hRootKey = NULL;
|
|
|
|
|
2006-06-29 03:06:39 +02:00
|
|
|
parts[0] = GetPathRoot(hwndTV, hItem, bFull);
|
|
|
|
parts[1] = GetItemPath(hwndTV, hItem, &hRootKey);
|
|
|
|
ret = CombinePaths((LPCTSTR *)parts, 2);
|
|
|
|
HeapFree(GetProcessHeap(), 0, parts[0]);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-08-10 13:52:44 +02:00
|
|
|
LPWSTR GetItemFullPathW(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
|
|
|
|
LPWSTR parts[2];
|
|
|
|
LPWSTR ret;
|
|
|
|
HKEY hRootKey = NULL;
|
|
|
|
|
|
|
|
parts[0] = GetPathRootW(hwndTV, hItem, bFull);
|
|
|
|
parts[1] = GetItemPathW(hwndTV, hItem, &hRootKey);
|
|
|
|
ret = CombinePathsW((LPCWSTR *)parts, 2);
|
|
|
|
HeapFree(GetProcessHeap(), 0, parts[0]);
|
2008-08-26 20:02:59 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, parts[1]);
|
2008-08-10 13:52:44 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static LPTSTR GetPathFullPath(HWND hwndTV, LPTSTR path) {
|
2006-08-16 21:14:08 +02:00
|
|
|
LPTSTR parts[2];
|
|
|
|
LPTSTR ret;
|
|
|
|
|
2006-06-29 03:06:39 +02:00
|
|
|
parts[0] = GetPathRoot(hwndTV, 0, TRUE);
|
|
|
|
parts[1] = path;
|
|
|
|
ret = CombinePaths((LPCTSTR *)parts, 2);
|
|
|
|
HeapFree(GetProcessHeap(), 0, parts[0]);
|
|
|
|
return ret;
|
2005-09-26 11:57:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BOOL bRefreshLV)
|
|
|
|
{
|
|
|
|
if (bRefreshLV) {
|
|
|
|
LPCTSTR keyPath;
|
|
|
|
HKEY hRootKey = NULL;
|
|
|
|
keyPath = GetItemPath(hwndTV, hItem, &hRootKey);
|
|
|
|
RefreshListView(hwndLV, hRootKey, keyPath, NULL);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* 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:
|
2007-02-08 00:14:15 +01:00
|
|
|
g_pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd));
|
|
|
|
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);
|
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) {
|
2003-12-08 23:48:07 +01:00
|
|
|
SetCursor(LoadCursor(0, IDC_SIZEWE));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto def;
|
2003-08-07 05:10:13 +02:00
|
|
|
case WM_DESTROY:
|
2007-02-08 00:14:15 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, g_pChildWnd);
|
|
|
|
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
|
|
|
|
|
|
|
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();
|
|
|
|
SetCursor(LoadCursor(0, IDC_ARROW));
|
|
|
|
}
|
|
|
|
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:
|
2007-02-08 00:14:15 +01:00
|
|
|
if (((int)wParam == TREE_WINDOW) && (g_pChildWnd != NULL)) {
|
2003-08-07 05:10:13 +02:00
|
|
|
switch (((LPNMHDR)lParam)->code) {
|
|
|
|
case TVN_ITEMEXPANDING:
|
2007-02-08 00:14:15 +01:00
|
|
|
return !OnTreeExpanding(g_pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam);
|
2005-03-21 12:23:40 +01:00
|
|
|
case TVN_SELCHANGED:
|
2007-02-08 00:14:15 +01:00
|
|
|
OnTreeSelectionChanged(g_pChildWnd->hTreeWnd, g_pChildWnd->hListWnd,
|
2005-03-21 12:23:40 +01:00
|
|
|
((NMTREEVIEW *)lParam)->itemNew.hItem, TRUE);
|
2003-08-07 05:10:13 +02:00
|
|
|
break;
|
2004-01-16 22:20:54 +01:00
|
|
|
case NM_SETFOCUS:
|
2007-02-08 00:14:15 +01:00
|
|
|
g_pChildWnd->nFocusPanel = 0;
|
2004-01-16 22:20:54 +01:00
|
|
|
break;
|
2004-05-04 04:55:28 +02:00
|
|
|
case NM_RCLICK: {
|
|
|
|
POINT pt;
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
TrackPopupMenu(GetSubMenu(hPopupMenus, PM_NEW),
|
|
|
|
TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
|
|
|
|
break;
|
|
|
|
}
|
2004-03-15 21:19:38 +01:00
|
|
|
case TVN_ENDLABELEDIT: {
|
|
|
|
HKEY hRootKey;
|
|
|
|
LPNMTVDISPINFO dispInfo = (LPNMTVDISPINFO)lParam;
|
2007-02-08 00:14:15 +01:00
|
|
|
LPCTSTR path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
|
2004-03-15 21:19:38 +01:00
|
|
|
BOOL res = RenameKey(hWnd, hRootKey, path, dispInfo->item.pszText);
|
|
|
|
if (res) {
|
|
|
|
TVITEMEX item;
|
2007-02-08 00:14:15 +01:00
|
|
|
LPTSTR fullPath = GetPathFullPath(g_pChildWnd->hTreeWnd,
|
2006-06-29 03:06:39 +02:00
|
|
|
dispInfo->item.pszText);
|
2004-03-15 21:19:38 +01:00
|
|
|
item.mask = TVIF_HANDLE | TVIF_TEXT;
|
2007-02-08 00:14:15 +01:00
|
|
|
item.hItem = TreeView_GetSelection(g_pChildWnd->hTreeWnd);
|
2004-03-15 21:19:38 +01:00
|
|
|
item.pszText = dispInfo->item.pszText;
|
2007-02-08 00:14:15 +01:00
|
|
|
SendMessage( g_pChildWnd->hTreeWnd, TVM_SETITEMW, 0, (LPARAM)&item );
|
2006-06-29 03:06:39 +02:00
|
|
|
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath);
|
|
|
|
HeapFree(GetProcessHeap(), 0, fullPath);
|
2004-03-15 21:19:38 +01:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
2003-08-07 05:10:13 +02:00
|
|
|
default:
|
2004-05-04 04:55:28 +02:00
|
|
|
return 0; /* goto def; */
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|
|
|
|
} else
|
2007-02-08 00:14:15 +01:00
|
|
|
if (((int)wParam == LIST_WINDOW) && (g_pChildWnd != NULL)) {
|
2004-01-16 22:20:54 +01:00
|
|
|
if (((LPNMHDR)lParam)->code == NM_SETFOCUS) {
|
2007-02-08 00:14:15 +01:00
|
|
|
g_pChildWnd->nFocusPanel = 1;
|
|
|
|
} else if (!SendMessage(g_pChildWnd->hListWnd, WM_NOTIFY_REFLECT, wParam, lParam)) {
|
2003-12-08 23:48:07 +01:00
|
|
|
goto def;
|
|
|
|
}
|
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:
|
2003-08-07 05:10:13 +02:00
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
2003-12-08 23:48:07 +01:00
|
|
|
}
|
|
|
|
return 0;
|
2003-08-07 05:10:13 +02:00
|
|
|
}
|