mirror of
https://github.com/reactos/reactos.git
synced 2024-12-25 16:50:57 +00:00
Updates with progress on TreeView, ChildWnd type and more...
svn path=/trunk/; revision=3232
This commit is contained in:
parent
4f0371f4af
commit
cc89fd7bba
8 changed files with 489 additions and 54 deletions
|
@ -34,6 +34,7 @@ OBJS = about.o \
|
|||
childwnd.o \
|
||||
listview.o \
|
||||
treeview.o \
|
||||
trace.o \
|
||||
main.o
|
||||
|
||||
LIBS = -lgdi32 -luser32 -lkernel32 -lcomctl32
|
||||
|
|
|
@ -50,11 +50,11 @@
|
|||
#define hRightWnd hListWnd
|
||||
|
||||
|
||||
HWND hTreeWnd; // Tree Control Window
|
||||
HWND hListWnd; // List Control Window
|
||||
//HWND hTreeWnd; // Tree Control Window
|
||||
//HWND hListWnd; // List Control Window
|
||||
|
||||
static int nSplitPos = 250;
|
||||
static int nFocusPanel;
|
||||
//static int nSplitPos = 250;
|
||||
//static int nFocusPanel;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -72,21 +72,21 @@ static void draw_splitbar(HWND hWnd, int x)
|
|||
|
||||
#define _NO_EXTENSIONS
|
||||
|
||||
static void ResizeWnd(int cx, int cy)
|
||||
static void ResizeWnd(ChildWnd* pChildWnd, int cx, int cy)
|
||||
{
|
||||
HDWP hdwp = BeginDeferWindowPos(2);
|
||||
RECT rt = {0, 0, cx, cy};
|
||||
|
||||
cx = nSplitPos + SPLIT_WIDTH/2;
|
||||
DeferWindowPos(hdwp, hTreeWnd, 0, rt.left, rt.top, nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
DeferWindowPos(hdwp, hListWnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
cx = pChildWnd->nSplitPos + SPLIT_WIDTH/2;
|
||||
DeferWindowPos(hdwp, pChildWnd->hTreeWnd, 0, rt.left, rt.top, pChildWnd->nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
DeferWindowPos(hdwp, pChildWnd->hListWnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
EndDeferWindowPos(hdwp);
|
||||
}
|
||||
|
||||
static void OnSize(WPARAM wParam, LPARAM lParam)
|
||||
static void OnSize(ChildWnd* pChildWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (wParam != SIZE_MINIMIZED) {
|
||||
ResizeWnd(LOWORD(lParam), HIWORD(lParam));
|
||||
if (wParam != SIZE_MINIMIZED && pChildWnd != NULL) {
|
||||
ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,13 +142,34 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
{
|
||||
static int last_split;
|
||||
// ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
// ASSERT(pChildWnd);
|
||||
static ChildWnd* pChildWnd;
|
||||
|
||||
switch (message) {
|
||||
case WM_CREATE:
|
||||
//HWND CreateListView(HWND hwndParent/*, Pane* pane*/, int id, LPTSTR lpszPathName);
|
||||
hTreeWnd = CreateTreeView(hWnd, 1000, _T("c:\\foobar.txt"));
|
||||
hListWnd = CreateListView(hWnd, 1001, _T(""));
|
||||
/*
|
||||
typedef struct tagCREATESTRUCT {
|
||||
LPVOID lpCreateParams;
|
||||
HINSTANCE hInstance;
|
||||
HMENU hMenu;
|
||||
HWND hwndParent;
|
||||
int cy;
|
||||
int cx;
|
||||
int y;
|
||||
int x;
|
||||
LONG style;
|
||||
LPCTSTR lpszName;
|
||||
LPCTSTR lpszClass;
|
||||
DWORD dwExStyle;
|
||||
} CREATESTRUCT, *LPCREATESTRUCT;
|
||||
*/
|
||||
pChildWnd = (ChildWnd*)((LPCREATESTRUCT)lParam)->lpCreateParams;
|
||||
ASSERT(pChildWnd);
|
||||
|
||||
pChildWnd->nSplitPos = 250;
|
||||
|
||||
pChildWnd->hTreeWnd = CreateTreeView(hWnd, TREE_WINDOW, &pChildWnd->root);
|
||||
pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW, &pChildWnd->root);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
|
||||
|
@ -163,7 +184,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
POINT pt;
|
||||
GetCursorPos(&pt);
|
||||
ScreenToClient(hWnd, &pt);
|
||||
if (pt.x>=nSplitPos-SPLIT_WIDTH/2 && pt.x<nSplitPos+SPLIT_WIDTH/2+1) {
|
||||
if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
||||
SetCursor(LoadCursor(0, IDC_SIZEWE));
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -178,8 +199,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
RECT rt;
|
||||
int x = LOWORD(lParam);
|
||||
GetClientRect(hWnd, &rt);
|
||||
if (x>=nSplitPos-SPLIT_WIDTH/2 && x<nSplitPos+SPLIT_WIDTH/2+1) {
|
||||
last_split = nSplitPos;
|
||||
if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) {
|
||||
last_split = pChildWnd->nSplitPos;
|
||||
#ifdef _NO_EXTENSIONS
|
||||
draw_splitbar(hWnd, last_split);
|
||||
#endif
|
||||
|
@ -195,8 +216,8 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
draw_splitbar(hWnd, last_split);
|
||||
last_split = -1;
|
||||
GetClientRect(hWnd, &rt);
|
||||
nSplitPos = x;
|
||||
ResizeWnd(rt.right, rt.bottom);
|
||||
pChildWnd->nSplitPos = x;
|
||||
ResizeWnd(pChildWnd, rt.right, rt.bottom);
|
||||
#endif
|
||||
ReleaseCapture();
|
||||
}
|
||||
|
@ -215,10 +236,10 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
#ifdef _NO_EXTENSIONS
|
||||
draw_splitbar(hWnd, last_split);
|
||||
#else
|
||||
nSplitPos = last_split;
|
||||
pChildWnd->nSplitPos = last_split;
|
||||
#endif
|
||||
GetClientRect(hWnd, &rt);
|
||||
ResizeWnd(rt.right, rt.bottom);
|
||||
ResizeWnd(pChildWnd, rt.right, rt.bottom);
|
||||
last_split = -1;
|
||||
ReleaseCapture();
|
||||
SetCursor(LoadCursor(0, IDC_ARROW));
|
||||
|
@ -243,7 +264,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
#else
|
||||
GetClientRect(hWnd, &rt);
|
||||
if (x>=0 && x<rt.right) {
|
||||
nSplitPos = x;
|
||||
pChildWnd->nSplitPos = x;
|
||||
//resize_tree(pChildWnd, rt.right, rt.bottom);
|
||||
rt.left = x-SPLIT_WIDTH/2;
|
||||
rt.right = x+SPLIT_WIDTH/2+1;
|
||||
|
@ -267,15 +288,38 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
|
||||
case WM_SETFOCUS:
|
||||
// SetCurrentDirectory(szPath);
|
||||
SetFocus(nFocusPanel? hRightWnd: hLeftWnd);
|
||||
if (pChildWnd != NULL) {
|
||||
SetFocus(pChildWnd->nFocusPanel? pChildWnd->hRightWnd: pChildWnd->hLeftWnd);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_TIMER:
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
if ((int)wParam == TREE_WINDOW) {
|
||||
if ((((LPNMHDR)lParam)->code) == TVN_SELCHANGED) {
|
||||
Entry* entry = (Entry*)((NMTREEVIEW*)lParam)->itemNew.lParam;
|
||||
if (entry != NULL) {
|
||||
//RefreshList(pChildWnd->right.hWnd, entry);
|
||||
//void set_curdir(ChildWnd* child, Entry* entry)
|
||||
//set_curdir(pChildWnd, entry);
|
||||
}
|
||||
}
|
||||
if (!SendMessage(pChildWnd->hTreeWnd, message, wParam, lParam)) {
|
||||
goto def;
|
||||
}
|
||||
}
|
||||
if ((int)wParam == LIST_WINDOW) {
|
||||
if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) {
|
||||
goto def;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
if (wParam != SIZE_MINIMIZED) {
|
||||
OnSize(wParam, lParam);
|
||||
OnSize(pChildWnd, wParam, lParam);
|
||||
}
|
||||
// fall through
|
||||
default: def:
|
||||
|
|
|
@ -252,18 +252,26 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
// WM_DESTROY - post a quit message and return
|
||||
//
|
||||
//
|
||||
static ChildWnd Child;
|
||||
|
||||
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
switch (message) {
|
||||
case WM_CREATE:
|
||||
{
|
||||
//Child.root.entry = ;
|
||||
_tcsncpy(Child.root.path, _T("My Computer"), MAX_PATH);
|
||||
|
||||
// HMENU hMenuWindow = GetSubMenu(hMenuFrame, GetMenuItemCount(hMenuFrame)-2);
|
||||
hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"),
|
||||
// hChildWnd = CreateWindowEx(0, (LPCTSTR)(int)hChildWndClass, _T("regedit child window"),
|
||||
// WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,
|
||||
WS_CHILD|WS_VISIBLE|WS_BORDER,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
hWnd, (HMENU)0, hInst, NULL/*lpParam*/);
|
||||
// hWnd, (HMENU)0, hInst, NULL/*lpParam*/);
|
||||
hWnd, (HMENU)0, hInst, &Child);
|
||||
|
||||
}
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
|
|
|
@ -196,7 +196,7 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
|
|||
}
|
||||
|
||||
|
||||
HWND CreateListView(HWND hwndParent/*, Pane* pane*/, int id, LPTSTR lpszPathName)
|
||||
HWND CreateListView(HWND hwndParent/*, Pane* pane*/, int id, Root* pRoot/*Entry* pEntry*/)
|
||||
{
|
||||
RECT rcClient; // dimensions of client area
|
||||
HWND hwndLV; // handle to list view control
|
||||
|
@ -221,7 +221,7 @@ HWND CreateListView(HWND hwndParent/*, Pane* pane*/, int id, LPTSTR lpszPathName
|
|||
ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT);
|
||||
CreateListColumns(hwndLV);
|
||||
|
||||
SetWindowLong(hwndLV, GWL_USERDATA, (LPARAM)lpszPathName);
|
||||
SetWindowLong(hwndLV, GWL_USERDATA, (LPARAM)pRoot);
|
||||
g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc);
|
||||
//SendMessage(hwndLV, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
|
||||
|
||||
|
@ -233,7 +233,7 @@ HWND CreateListView(HWND hwndParent/*, Pane* pane*/, int id, LPTSTR lpszPathName
|
|||
return hwndLV;
|
||||
}
|
||||
|
||||
void RefreshList(HWND hWnd/*, Entry* entry*/)
|
||||
void RefreshList(HWND hWnd, Entry* entry)
|
||||
{
|
||||
if (hWnd != NULL) {
|
||||
ListView_DeleteAllItems(hWnd);
|
||||
|
|
|
@ -32,8 +32,8 @@ extern "C" {
|
|||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
HWND CreateListView(HWND hwndParent/*, Pane* pane*/, int id, LPTSTR lpszPathName);
|
||||
void RefreshList(HWND hWnd/*, Entry* entry*/);
|
||||
HWND CreateListView(HWND hwndParent, int id, Root* pRoot);
|
||||
void RefreshList(HWND hWnd, Entry* entry);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -32,6 +32,38 @@ extern "C" {
|
|||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "resource.h"
|
||||
#include "regproc.h"
|
||||
|
||||
|
||||
typedef struct _Entry {
|
||||
struct _Entry* next;
|
||||
struct _Entry* down;
|
||||
struct _Entry* up;
|
||||
BOOL expanded;
|
||||
BOOL scanned;
|
||||
int level;
|
||||
BOOL bKey; // key or value?
|
||||
HKEY hKey;
|
||||
// BOOL bRoot;
|
||||
HTREEITEM hTreeItem;
|
||||
} Entry;
|
||||
|
||||
|
||||
typedef struct {
|
||||
Entry entry;
|
||||
TCHAR path[MAX_PATH];
|
||||
// DWORD _flags;
|
||||
} Root;
|
||||
|
||||
typedef struct {
|
||||
HWND hWnd;
|
||||
HWND hTreeWnd;
|
||||
HWND hListWnd;
|
||||
int nFocusPanel; // 0: left 1: right
|
||||
WINDOWPLACEMENT pos;
|
||||
int nSplitPos;
|
||||
Root root;
|
||||
} ChildWnd;
|
||||
|
||||
|
||||
#define STATUS_WINDOW 2001
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "main.h"
|
||||
#include "treeview.h"
|
||||
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
// Global variables and constants
|
||||
// Image_Open, Image_Closed, and Image_Root - integer variables for
|
||||
|
@ -55,6 +57,8 @@ int Image_Root;
|
|||
#define NUM_BITMAPS 3
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
// AddItemToTree - adds items to a tree view control.
|
||||
// Returns the handle to the newly added item.
|
||||
// hwndTV - handle to the tree view control.
|
||||
|
@ -119,6 +123,9 @@ HTREEITEM AddItemToTree(HWND hwndTV, LPTSTR lpszItem, int nLevel)
|
|||
|
||||
return hPrev;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
static void init_output(HWND hWnd)
|
||||
{
|
||||
|
@ -136,29 +143,277 @@ static void init_output(HWND hWnd)
|
|||
// SelectFont(hdc, old_font);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
}
|
||||
/*
|
||||
HTREEITEM AddEntryToTree(HWND hwndTV, Entry* entry)
|
||||
|
||||
static HTREEITEM AddEntryToTree(HWND hwndTV, Entry* entry, LPTSTR label)
|
||||
{
|
||||
HTREEITEM hItem = 0;
|
||||
TVITEM tvi;
|
||||
TVINSERTSTRUCT tvins;
|
||||
static HTREEITEM hPrev = (HTREEITEM)TVI_FIRST;
|
||||
static HTREEITEM hPrevRootItem = NULL;
|
||||
static HTREEITEM hPrevLev2Item = NULL;
|
||||
|
||||
//TRACE("AddEntryToTree(level:%u - %s)\n", entry->level, entry->data.cFileName);
|
||||
|
||||
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM;
|
||||
/*
|
||||
// Set the text of the item.
|
||||
tvi.pszText = entry->data.cFileName;
|
||||
tvi.cchTextMax = lstrlen(entry->data.cFileName);
|
||||
// Assume the item is not a parent item, so give it an image.
|
||||
tvi.iImage = Image_Root;
|
||||
tvi.iSelectedImage = Image_Root;
|
||||
tvi.cChildren = 1;
|
||||
// Save the heading level in the item's application-defined data area.
|
||||
//tvi.lParam = (LPARAM)entry->level;
|
||||
*/
|
||||
if (label != NULL) {
|
||||
tvi.pszText = label;
|
||||
tvi.cchTextMax = _tcslen(label);
|
||||
} else {
|
||||
tvi.pszText = LPSTR_TEXTCALLBACK;
|
||||
tvi.cchTextMax = 0;
|
||||
}
|
||||
tvi.iImage = I_IMAGECALLBACK;
|
||||
tvi.iSelectedImage = I_IMAGECALLBACK;
|
||||
tvi.cChildren = I_CHILDRENCALLBACK;
|
||||
// Save the entry pointer in the item's application-defined data area.
|
||||
tvi.lParam = (LPARAM)entry;
|
||||
|
||||
tvins.item = tvi;
|
||||
tvins.hInsertAfter = hPrev;
|
||||
|
||||
// Set the parent item based on the specified level.
|
||||
if (entry->level == 0) {
|
||||
tvins.hParent = TVI_ROOT;
|
||||
} else if (entry->level == 1) {
|
||||
tvins.hParent = hPrevRootItem;
|
||||
} else {
|
||||
tvins.hParent = hPrevLev2Item;
|
||||
if (hPrevLev2Item) {
|
||||
tvins.hParent = entry->up->hTreeItem;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the item to the tree view control.
|
||||
hPrev = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
|
||||
|
||||
// Save the handle to the item.
|
||||
if (entry->level == 0)
|
||||
hPrevRootItem = hPrev;
|
||||
else if (entry->level == 1)
|
||||
hPrevLev2Item = hPrev;
|
||||
/*
|
||||
// The new item is a child item. Give the parent item a
|
||||
// closed folder bitmap to indicate it now has child items.
|
||||
if (entry->level > 1) {
|
||||
HTREEITEM hti;
|
||||
hti = TreeView_GetParent(hwndTV, hPrev);
|
||||
tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||||
tvi.hItem = hti;
|
||||
tvi.iImage = Image_Closed;
|
||||
tvi.iSelectedImage = Image_Closed;
|
||||
TreeView_SetItem(hwndTV, &tvi);
|
||||
}
|
||||
*/
|
||||
hItem = hPrev;
|
||||
return hItem;
|
||||
}
|
||||
|
||||
// insert treectrl entries after index idx
|
||||
static void insert_tree_entries(HWND hWnd, Entry* entry, int idx)
|
||||
{
|
||||
static HTREEITEM hItemVisible;
|
||||
static int hItemVisibleIdx;
|
||||
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
if (entry->hTreeItem)
|
||||
return;
|
||||
|
||||
ShowWindow(hWnd, SW_HIDE);
|
||||
for(; entry; entry=entry->next) {
|
||||
/*
|
||||
#ifndef _LEFT_FILES
|
||||
if (!(entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
|
||||
continue;
|
||||
#endif
|
||||
// don't display entries "." and ".." in the left pane
|
||||
if ((entry->data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && entry->data.cFileName[0]==_T('.')) {
|
||||
if (entry->data.cFileName[1] == _T('\0') ||
|
||||
(entry->data.cFileName[1] == _T('.') &&
|
||||
entry->data.cFileName[2] == _T('\0'))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//TRACE("Adding item %u [level:%u] - %s\n", ++idx, entry->level, entry->data.cFileName);
|
||||
*/
|
||||
if (entry->hTreeItem) continue;
|
||||
|
||||
static BOOL InitTreeViewItems(HWND hwndTV)
|
||||
entry->hTreeItem = AddEntryToTree(hWnd, entry, NULL);
|
||||
if (entry->expanded) {
|
||||
insert_tree_entries(hWnd, entry->down, idx + 1);
|
||||
TreeView_Expand(hWnd, entry->hTreeItem, TVE_EXPAND);
|
||||
}
|
||||
if (idx > hItemVisibleIdx) {
|
||||
hItemVisibleIdx = idx;
|
||||
hItemVisible = entry->hTreeItem;
|
||||
}
|
||||
}
|
||||
if (hItemVisible && idx == 0) {
|
||||
TreeView_SelectSetFirstVisible(hWnd, hItemVisible);
|
||||
}
|
||||
ShowWindow(hWnd, SW_SHOW);
|
||||
}
|
||||
|
||||
static BOOL InitTreeViewItems(HWND hwndTV, Root* pRoot/*LPCTSTR pHostName*/)
|
||||
{
|
||||
HTREEITEM hItem;
|
||||
|
||||
hItem = AddItemToTree(hwndTV, _T("My Computer"), 1);
|
||||
AddItemToTree(hwndTV, _T("HKEY_CLASSES_ROOT"), 2);
|
||||
AddItemToTree(hwndTV, _T("HKEY_CURRENT_USER"), 2);
|
||||
AddItemToTree(hwndTV, _T("HKEY_LOCAL_MACHINE"), 2);
|
||||
AddItemToTree(hwndTV, _T("HKEY_USERS"), 2);
|
||||
AddItemToTree(hwndTV, _T("HKEY_CURRENT_CONFIG"), 2);
|
||||
// HRESULT key;
|
||||
//HRESULT openKey(LPSTR stdInput)
|
||||
// key = openKey("HKEY_CLASSES_ROOT");
|
||||
//LPSTR getRegKeyName(LPSTR lpLine);
|
||||
//HKEY getRegClass(LPSTR lpLine);
|
||||
// closeKey();
|
||||
|
||||
#define MAX_NAME_LEN 500
|
||||
|
||||
HKEY hKey;
|
||||
LONG errCode;
|
||||
Entry* pPrevEntry;
|
||||
Entry* pEntry = &pRoot->entry;
|
||||
HTREEITEM hRootItem;
|
||||
|
||||
// TCHAR* pHostName = _T("My Computer");
|
||||
// HTREEITEM hRootItem = AddItemToTree(hwndTV, pHostName, 1);
|
||||
// pEntry = malloc(sizeof(Entry));
|
||||
// memset(pEntry, 0, sizeof(Entry));
|
||||
// memset(pEntry, 0, sizeof(Entry));
|
||||
//insert_tree_entries(hwndTV, pEntry, 0);
|
||||
pEntry->level = 0;
|
||||
pEntry->hTreeItem = AddEntryToTree(hwndTV, pEntry, pRoot->path);
|
||||
hRootItem = pEntry->hTreeItem;
|
||||
pPrevEntry = pEntry;
|
||||
//HTREEITEM AddItemToTree(HWND hwndTV, LPTSTR lpszItem, int nLevel)
|
||||
//HTREEITEM AddEntryToTree(HWND hwndTV, Entry* entry)
|
||||
//static void insert_tree_entries(HWND hWnd, Entry* entry, int idx)
|
||||
|
||||
pEntry = malloc(sizeof(Entry));
|
||||
memset(pEntry, 0, sizeof(Entry));
|
||||
pEntry->up = &pRoot->entry;
|
||||
pEntry->level = 1;
|
||||
pEntry->hTreeItem = AddEntryToTree(hwndTV, pEntry, _T("HKEY_CLASSES_ROOT"));
|
||||
|
||||
pEntry = malloc(sizeof(Entry));
|
||||
memset(pEntry, 0, sizeof(Entry));
|
||||
pEntry->up = &pRoot->entry;
|
||||
pEntry->level = 1;
|
||||
pEntry->hTreeItem = AddEntryToTree(hwndTV, pEntry, _T("HKEY_CURRENT_USER"));
|
||||
|
||||
pEntry = malloc(sizeof(Entry));
|
||||
memset(pEntry, 0, sizeof(Entry));
|
||||
pEntry->up = &pRoot->entry;
|
||||
pEntry->level = 1;
|
||||
pEntry->hTreeItem = AddEntryToTree(hwndTV, pEntry, _T("HKEY_LOCAL_MACHINE"));
|
||||
|
||||
pPrevEntry = pEntry;
|
||||
|
||||
errCode = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NULL, 0, KEY_READ, &hKey);
|
||||
if (errCode == ERROR_SUCCESS) {
|
||||
TCHAR Name[MAX_NAME_LEN];
|
||||
TCHAR Class[MAX_NAME_LEN];
|
||||
FILETIME LastWriteTime;
|
||||
DWORD dwIndex = 0L;
|
||||
DWORD cName = MAX_NAME_LEN;
|
||||
DWORD cClass = MAX_NAME_LEN;
|
||||
while (RegEnumKeyEx(hKey, dwIndex, Name, &cName, NULL, Class, &cClass, &LastWriteTime) == ERROR_SUCCESS) {
|
||||
//AddItemToTree(hwndTV, Name, 2);
|
||||
pEntry = malloc(sizeof(Entry));
|
||||
memset(pEntry, 0, sizeof(Entry));
|
||||
pEntry->up = pPrevEntry;
|
||||
pEntry->hKey = hKey;
|
||||
pEntry->bKey = TRUE;
|
||||
//insert_tree_entries(hwndTV, pEntry, 0);
|
||||
pEntry->level = 2;
|
||||
// pEntry->hTreeItem = AddEntryToTree(hwndTV, pEntry, Name);
|
||||
pEntry->hTreeItem = AddEntryToTree(hwndTV, pEntry, NULL);
|
||||
cName = MAX_NAME_LEN;
|
||||
cClass = MAX_NAME_LEN;
|
||||
++dwIndex;
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
TreeView_Expand(hwndTV, hRootItem, TVE_EXPAND);
|
||||
}
|
||||
|
||||
pEntry = malloc(sizeof(Entry));
|
||||
memset(pEntry, 0, sizeof(Entry));
|
||||
pEntry->up = &pRoot->entry;
|
||||
pEntry->level = 1;
|
||||
pEntry->hTreeItem = AddEntryToTree(hwndTV, pEntry, _T("HKEY_USERS"));
|
||||
|
||||
pEntry = malloc(sizeof(Entry));
|
||||
memset(pEntry, 0, sizeof(Entry));
|
||||
pEntry->up = &pRoot->entry;
|
||||
pEntry->level = 1;
|
||||
pEntry->hTreeItem = AddEntryToTree(hwndTV, pEntry, _T("HKEY_CURRENT_CONFIG"));
|
||||
|
||||
TreeView_Expand(hwndTV, hItem, TVE_EXPAND);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
AddItemToTree(hwndTV, _T("HKEY_CLASSES_ROOT"), 2);
|
||||
AddItemToTree(hwndTV, _T("HKEY_CURRENT_USER"), 2);
|
||||
AddItemToTree(hwndTV, _T("HKEY_LOCAL_MACHINE"), 2);
|
||||
AddItemToTree(hwndTV, _T("HKEY_USERS"), 2);
|
||||
AddItemToTree(hwndTV, _T("HKEY_CURRENT_CONFIG"), 2);
|
||||
*/
|
||||
/*
|
||||
LONG RegOpenKeyEx(
|
||||
HKEY hKey, // handle to open key
|
||||
LPCTSTR lpSubKey, // subkey name
|
||||
DWORD ulOptions, // reserved
|
||||
REGSAM samDesired, // security access mask
|
||||
PHKEY phkResult // handle to open key
|
||||
);
|
||||
|
||||
LONG RegEnumKey(
|
||||
HKEY hKey, // handle to key to query
|
||||
DWORD dwIndex, // index of subkey to query
|
||||
LPTSTR lpName, // buffer for subkey name
|
||||
DWORD cbName // size of subkey name buffer
|
||||
);
|
||||
|
||||
LONG RegEnumKeyEx(
|
||||
HKEY hKey, // handle to key to enumerate
|
||||
DWORD dwIndex, // subkey index
|
||||
LPTSTR lpName, // subkey name
|
||||
LPDWORD lpcName, // size of subkey buffer
|
||||
LPDWORD lpReserved, // reserved
|
||||
LPTSTR lpClass, // class string buffer
|
||||
LPDWORD lpcClass, // size of class string buffer
|
||||
PFILETIME lpftLastWriteTime // last write time
|
||||
);
|
||||
*/
|
||||
|
||||
/*
|
||||
RegCloseKey
|
||||
RegConnectRegistryW
|
||||
RegCreateKeyW
|
||||
RegDeleteKeyW
|
||||
RegDeleteValueW
|
||||
RegEnumKeyW
|
||||
RegEnumValueW
|
||||
RegFlushKey
|
||||
RegOpenKeyExA
|
||||
RegOpenKeyExW
|
||||
RegOpenKeyW
|
||||
RegQueryInfoKeyW
|
||||
RegQueryValueExA
|
||||
RegQueryValueExW
|
||||
RegSetValueExA
|
||||
RegSetValueExW
|
||||
RegSetValueW
|
||||
*/
|
||||
|
||||
// InitTreeViewImageLists - creates an image list, adds three bitmaps
|
||||
// to it, and associates the image list with a tree view control.
|
||||
// Returns TRUE if successful, or FALSE otherwise.
|
||||
|
@ -204,9 +459,15 @@ static BOOL InitTreeViewImageLists(HWND hwndTV)
|
|||
|
||||
static void OnGetDispInfo(NMTVDISPINFO* ptvdi)
|
||||
{
|
||||
/*
|
||||
Entry* entry = (Entry*)ptvdi->item.lParam;
|
||||
ASSERT(entry);
|
||||
FILETIME LastWriteTime;
|
||||
TCHAR Class[MAX_NAME_LEN];
|
||||
DWORD cClass = MAX_NAME_LEN;
|
||||
// TCHAR Name[MAX_NAME_LEN];
|
||||
// DWORD cName = MAX_NAME_LEN;
|
||||
// DWORD dwIndex = 0L;
|
||||
|
||||
Entry* pEntry = (Entry*)ptvdi->item.lParam;
|
||||
ASSERT(pEntry);
|
||||
|
||||
if (ptvdi->item.mask & TVIF_CHILDREN ) {
|
||||
ptvdi->item.cChildren = 5;
|
||||
|
@ -218,12 +479,60 @@ static void OnGetDispInfo(NMTVDISPINFO* ptvdi)
|
|||
ptvdi->item.iSelectedImage = Image_Closed;
|
||||
}
|
||||
if (ptvdi->item.mask & TVIF_TEXT) {
|
||||
ptvdi->item.pszText = entry->data.cFileName;
|
||||
ptvdi->item.cchTextMax = lstrlen(entry->data.cFileName);
|
||||
ptvdi->item.pszText = _T("Unknown");
|
||||
ptvdi->item.cchTextMax = _tcslen(ptvdi->item.pszText);
|
||||
if (pEntry->bKey == TRUE) {
|
||||
DWORD nSubKeys;
|
||||
DWORD MaxSubKeyLen;
|
||||
DWORD MaxClassLen;
|
||||
DWORD ValueCount;
|
||||
DWORD MaxValueNameLen;
|
||||
DWORD MaxValueLen;
|
||||
DWORD SecurityDescriptorLen;
|
||||
|
||||
HKEY hKey = pEntry->hKey;
|
||||
LONG result = RegQueryInfoKey(pEntry->hKey, Class, &cClass, 0,
|
||||
&nSubKeys, &MaxSubKeyLen, &MaxClassLen, &ValueCount,
|
||||
&MaxValueNameLen, &MaxValueLen, &SecurityDescriptorLen,
|
||||
&LastWriteTime);
|
||||
if (result == ERROR_SUCCESS) {
|
||||
// ptvdi->item.pszText = Class;
|
||||
// ptvdi->item.cchTextMax = cClass;
|
||||
}
|
||||
}
|
||||
// ptvdi->item.pszText = entry->data.cFileName;
|
||||
// ptvdi->item.cchTextMax = lstrlen(entry->data.cFileName);
|
||||
}
|
||||
}
|
||||
|
||||
// OnEndLabelEdit - processes the LVN_ENDLABELEDIT notification message.
|
||||
// Returns TRUE if the label is changed, or FALSE otherwise.
|
||||
|
||||
static BOOL OnEndLabelEdit(NMTVDISPINFO* ptvdi)
|
||||
{
|
||||
// if (ptvdi->item.iItem == -1)
|
||||
// return FALSE;
|
||||
|
||||
// Copy the new label text to the application-defined structure.
|
||||
// lstrcpyn(rgPetInfo[ptvdi->item.iItem].szKind, ptvdi->item.pszText, 10);
|
||||
|
||||
return TRUE;
|
||||
// To make a more robust application you should send an EM_LIMITTEXT
|
||||
// message to the edit control to prevent the user from entering too
|
||||
// many characters in the field.
|
||||
}
|
||||
|
||||
static BOOL OnExpand(int flag, HTREEITEM* pti)
|
||||
{
|
||||
TRACE(_T("TreeWndProc(...) OnExpand()\n"));
|
||||
//TRACE("OnExpand(...) entry name: %s\n", entry->data.cFileName);
|
||||
/*
|
||||
TVE_COLLAPSE Collapses the list.
|
||||
TVE_COLLAPSERESET Collapses the list and removes the child items. The TVIS_EXPANDEDONCE state flag is reset. This flag must be used with the TVE_COLLAPSE flag.
|
||||
TVE_EXPAND Expands the list.
|
||||
TVE_EXPANDPARTIAL Version 4.70. Partially expands the list. In this state, the child items are visible and the parent item's plus symbol is displayed. This flag must be used in combination with the TVE_EXPAND flag.
|
||||
TVE_TOGGLE Collapses the list if it is expanded or expands it if it is collapsed.
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -231,13 +540,17 @@ static BOOL OnExpanding(HWND hWnd, NMTREEVIEW* pnmtv)
|
|||
{
|
||||
static int expanding;
|
||||
|
||||
Entry* entry = (Entry*)pnmtv->itemNew.lParam;
|
||||
TRACE(_T("TreeWndProc(...) OnExpanding() entry: %p\n"), entry);
|
||||
if (expanding) return FALSE;
|
||||
expanding = TRUE;
|
||||
if (entry) {
|
||||
insert_tree_entries(hWnd, entry->down, 0);
|
||||
// insert_tree_entries(hWnd, entry, 0);
|
||||
}
|
||||
expanding = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
static BOOL OnSelChanged(NMTREEVIEW* pnmtv)
|
||||
|
@ -257,7 +570,44 @@ static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
|
|||
// Pane* pane = (Pane*)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
// ASSERT(child);
|
||||
switch (message) {
|
||||
default:
|
||||
case WM_NOTIFY:
|
||||
switch (((LPNMHDR)lParam)->code) {
|
||||
case TVM_EXPAND:
|
||||
//return OnExpand((int)wParam, (HTREEITEM*)lParam);
|
||||
OnExpand((int)wParam, (HTREEITEM*)lParam);
|
||||
break;
|
||||
case TVN_GETDISPINFO:
|
||||
OnGetDispInfo((NMTVDISPINFO*)lParam);
|
||||
break;
|
||||
case TVN_ITEMEXPANDING:
|
||||
return OnExpanding(hWnd, (NMTREEVIEW*)lParam);
|
||||
break;
|
||||
case TVN_SELCHANGED:
|
||||
// return OnSelChanged((NMTREEVIEW*)lParam);
|
||||
// break;
|
||||
#if 0
|
||||
case TVN_SINGLEEXPAND:
|
||||
TRACE("TreeWndProc(...) TVN_SINGLEEXPAND\n");
|
||||
//lpnmtv = (LPNMTREEVIEW)lParam;
|
||||
//return TVNRET_DEFAULT;
|
||||
// return TVNRET_SKIPOLD; // Skip default processing of the item being unselected.
|
||||
// return TVNRET_SKIPNEW; // Skip default processing of the item being selected.
|
||||
break;
|
||||
#endif
|
||||
case TVN_ENDLABELEDIT:
|
||||
return OnEndLabelEdit((NMTVDISPINFO*)lParam);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
//child->nFocusPanel = pane == &child->right? 1: 0;
|
||||
//TODO: check menu items
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_TAB) {
|
||||
//SetFocus(child->nFocusPanel ? child->left.hWnd: child->right.hWnd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return CallWindowProc(g_orgTreeWndProc, hWnd, message, wParam, lParam);
|
||||
|
@ -268,7 +618,7 @@ static LRESULT CALLBACK TreeWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
|
|||
// or NULL otherwise.
|
||||
// hwndParent - handle to the control's parent window.
|
||||
|
||||
HWND CreateTreeView(HWND hwndParent/*, Pane* pane*/, int id, LPTSTR lpszPathName)
|
||||
HWND CreateTreeView(HWND hwndParent/*, Pane* pane*/, int id, Root* pRoot/*LPTSTR lpszPathName*/)
|
||||
{
|
||||
RECT rcClient; // dimensions of client area
|
||||
HWND hwndTV; // handle to tree view control
|
||||
|
@ -284,7 +634,7 @@ HWND CreateTreeView(HWND hwndParent/*, Pane* pane*/, int id, LPTSTR lpszPathName
|
|||
0, 0, rcClient.right, rcClient.bottom,
|
||||
hwndParent, (HMENU)id, hInst, NULL);
|
||||
// Initialize the image list, and add items to the control.
|
||||
if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV)) {
|
||||
if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pRoot)) {
|
||||
DestroyWindow(hwndTV);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ extern "C" {
|
|||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
HWND CreateTreeView(HWND hwndParent/*, Pane* pane*/, int id, LPTSTR lpszPathName);
|
||||
HWND CreateTreeView(HWND hwndParent, int id, Root* pRoot);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in a new issue