I unleashed winetreediff on the regedit merge, and manually edited the patch to fix up several spooky carridge returns in the resource files. License: I'm not sure? LGPL I guess... ChangeLog: * programs/regedit: .cvsignore, Makefile.in, regedit.c, regproc.c, regproc.h, En.rc (new), about.c (new), about.h (new), childwnd.c (new), childwnd.h (new), framewnd.c (new), framewnd.h (new), hex_str.c (new), hex_str.h (new), listview.c (new), listview.h (new), main.c (new), main.h (new), regedit.rc (new), resource.h (new), resource.rc (new), rsrc.rc (new), treeview.c (new), treeview.h (new), version.rc (new). - merge Reactos's regedit gui (by Robert Dickenson <robd@reactos.org>) -- diff -ur --minimal --exclude-from=/home/greg/bin/winetreediff_excl ../wine.vanilla/programs/regedit/Makefile.in ./programs/regedit/Makefile.in --- ../wine.vanilla/programs/regedit/Makefile.in 2003-04-09 16:44:43.000000000 -0500 +++ ./programs/regedit/Makefile.in 2003-06-05 00:18:00.000000000 -0500 @@ -4,13 +4,22 @@ VPATH = @srcdir@ MODULE = regedit.exe APPMODE = gui -IMPORTS = msvcrt advapi32 kernel32 +IMPORTS = msvcrt advapi32 kernel32 user32 comctl32 comdlg32 gdi32 EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt EXTRADEFS = -DNO_LIBWINE_PORT C_SRCS = \ + about.c \ + childwnd.c \ + framewnd.c \ + hex_str.c \ + listview.c \ + main.c \ regedit.c \ - regproc.c + regproc.c \ + treeview.c \ + +RC_SRCS = rsrc.rc PLTESTS = \ tests/regedit.pl diff -ur --minimal --exclude-from=/home/greg/bin/winetreediff_excl ../wine.vanilla/programs/regedit/regedit.c ./programs/regedit/regedit.c --- ../wine.vanilla/programs/regedit/regedit.c 2003-01-29 21:50:18.000000000 -0600 +++ ./programs/regedit/regedit.c 2003-06-05 00:18:00.000000000 -0500 @@ -59,6 +59,8 @@ ACTION_UNDEF, ACTION_ADD, ACTION_EXPORT, ACTION_DELETE } REGEDIT_ACTION; +BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s); + /** * Process unknown switch. * @@ -78,8 +80,7 @@ exit(1); } -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpCmdLine, int nCmdShow) +BOOL ProcessCmdLine(LPSTR lpCmdLine) { REGEDIT_ACTION action = ACTION_UNDEF; LPSTR s = lpCmdLine; /* command line pointer */ @@ -153,10 +154,13 @@ } if (action == ACTION_UNDEF) - { - action = ACTION_ADD; + return FALSE; + + return PerformRegAction(action, s); } +BOOL PerformRegAction(REGEDIT_ACTION action, LPSTR s) +{ switch (action) { case ACTION_ADD: @@ -167,7 +171,8 @@ get_file_name(&s, filename); if (!filename[0]) { - printf("%s: No file name is specified\n%s", getAppName(), usage); + printf("%s: No file name is specified\n", getAppName()); + printf(usage); exit(1); } @@ -193,8 +198,9 @@ get_file_name(&s, reg_key_name); if (!reg_key_name[0]) { - printf("%s: No registry key is specified for removal\n%s", - getAppName(), usage); + printf("%s: No registry key is specified for removal\n", + getAppName()); + printf(usage); exit(1); } delete_registry_key(reg_key_name); @@ -208,7 +214,8 @@ get_file_name(&s, filename); if (!filename[0]) { - printf("%s: No file name is specified\n%s", getAppName(), usage); + printf("%s: No file name is specified\n", getAppName()); + printf(usage); exit(1); } @@ -230,3 +237,4 @@ } return 0; } + diff -ur --minimal --exclude-from=/home/greg/bin/winetreediff_excl ../wine.vanilla/programs/regedit/regproc.c ./programs/regedit/regproc.c --- ../wine.vanilla/programs/regedit/regproc.c 2003-01-29 21:50:18.000000000 -0600 +++ ./programs/regedit/regproc.c 2003-06-05 00:18:00.000000000 -0500 @@ -103,7 +103,7 @@ /****************************************************************************** * Copies file name from command line string to the buffer. - * Rewinds the command line string pointer to the next non-spece character + * Rewinds the command line string pointer to the next non-space character * after the file name. * Buffer contains an empty string if no filename was found; * @@ -616,7 +616,7 @@ closeKey(); /* Close the previous key before */ if ( openKey(stdInput) != ERROR_SUCCESS ) - printf ("%s: doSetValue failed to open key %s\n", getAppName(), stdInput); + printf("%s: setValue failed to open key %s\n", getAppName(), stdInput); } else if( ( bTheKeyIsOpen ) && (( stdInput[0] == '@') || /* reading a default @=data pair */ @@ -655,7 +655,7 @@ closeKey(); /* Close the previous key before */ if ( openKey(stdInput) != ERROR_SUCCESS ) - printf ("%s: doSetValue failed to open key %s\n", getAppName(), stdInput); + printf("%s: queryValue failed to open key %s\n", getAppName(), stdInput); } else if( ( bTheKeyIsOpen ) && (( stdInput[0] == '@') || /* reading a default @=data pair */ @@ -743,14 +743,14 @@ if (line[line_idx] != '=') { line[line_idx] = '\"'; - printf("Warning! uncrecognized line:\n%s\n", line); + printf("Warning! unrecognized line:\n%s\n", line); return; } } else { - printf("Warning! uncrecognized line:\n%s\n", line); + printf("Warning! unrecognized line:\n%s\n", line); return; } line_idx++; /* skip the '=' character */ @@ -890,7 +890,7 @@ currentKeyName); else - printf("%s: ERROR Value \"%s\" not found. for key \"%s\"\n", + printf("%s: ERROR Value \"%s\" not found for key \"%s\".\n", getAppName(), keyValue, currentKeyName); @@ -1375,7 +1375,7 @@ * reg_key_name - registry branch to export. The whole registry is exported if * reg_key_name is NULL or contains an empty string. */ -void export_registry_key(CHAR *file_name, CHAR *reg_key_name) +BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name) { HKEY reg_key_class; @@ -1463,6 +1463,21 @@ } HeapFree(GetProcessHeap(), 0, reg_key_name); HeapFree(GetProcessHeap(), 0, val_buf); + return TRUE; +} + +/****************************************************************************** + * Reads contents of the specified file into the registry. + */ +BOOL import_registry_file(LPTSTR filename) +{ + FILE* reg_file = fopen(filename, "r"); + + if (reg_file) { + processRegLines(reg_file, doSetValue); + return TRUE; + } + return FALSE; } /****************************************************************************** diff -ur --minimal --exclude-from=/home/greg/bin/winetreediff_excl ../wine.vanilla/programs/regedit/regproc.h ./programs/regedit/regproc.h --- ../wine.vanilla/programs/regedit/regproc.h 2003-01-29 21:50:18.000000000 -0600 +++ ./programs/regedit/regproc.h 2003-06-05 00:18:00.000000000 -0500 @@ -36,7 +36,8 @@ void doRegisterDLL(LPSTR lpsLine); void doUnregisterDLL(LPSTR lpsLine); -void export_registry_key(CHAR *file_name, CHAR *reg_key_name); +BOOL export_registry_key(CHAR *file_name, CHAR *reg_key_name); +BOOL import_registry_file(LPTSTR filename); void delete_registry_key(CHAR *reg_key_name); void setAppName(CHAR *name); --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/En.rc 2003-06-03 14:16:50.000000000 -0500 @@ -0,0 +1,221 @@ +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(850) + +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDC_REGEDIT MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", ID_REGISTRY_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About ...", ID_HELP_ABOUT + END +END + +IDR_REGEDIT_MENU MENU DISCARDABLE +BEGIN + POPUP "&Registry" + BEGIN + MENUITEM "&Import Registry File...", ID_REGISTRY_IMPORTREGISTRYFILE + + MENUITEM "&Export Registry File...", ID_REGISTRY_EXPORTREGISTRYFILE + + MENUITEM SEPARATOR + MENUITEM "&Connect Network Registry...", + ID_REGISTRY_CONNECTNETWORKREGISTRY + , GRAYED + MENUITEM "&Disconnect Network Registry...", + ID_REGISTRY_DISCONNECTNETWORKREGISTRY + , GRAYED + MENUITEM SEPARATOR + MENUITEM "&Print\tCtrl+P", ID_REGISTRY_PRINT, GRAYED + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_REGISTRY_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Modify", ID_EDIT_MODIFY + MENUITEM SEPARATOR + POPUP "&New" + BEGIN + MENUITEM "&Key", ID_EDIT_NEW_KEY + MENUITEM SEPARATOR + MENUITEM "&String Value", ID_EDIT_NEW_STRINGVALUE + MENUITEM "&Binary Value", ID_EDIT_NEW_BINARYVALUE + MENUITEM "&DWORD Value", ID_EDIT_NEW_DWORDVALUE + END + MENUITEM SEPARATOR + MENUITEM "&Delete\tDel", ID_EDIT_DELETE + MENUITEM "&Rename", ID_EDIT_RENAME + 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 + END + POPUP "&View" + BEGIN + MENUITEM "Status &Bar", ID_VIEW_STATUSBAR + MENUITEM SEPARATOR + MENUITEM "Sp&lit", ID_VIEW_SPLIT + MENUITEM SEPARATOR + MENUITEM "&Refresh\tF5", ID_VIEW_REFRESH + END + POPUP "&Favourites" + BEGIN + MENUITEM "&Add to Favourites", ID_FAVOURITES_ADDTOFAVOURITES + , GRAYED + MENUITEM "&Remove Favourite", ID_FAVOURITES_REMOVEFAVOURITE + , GRAYED + END + POPUP "&Help" + BEGIN +// MENUITEM "&Help Topics", ID_HELP_HELPTOPICS +// MENUITEM SEPARATOR + MENUITEM "&About Registry Editor", ID_HELP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75 +STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "System" +BEGIN + ICON IDI_REGEDIT,IDI_REGEDIT,14,9,16,16 + LTEXT "ReactOS regedit Version 1.0",IDC_STATIC,49,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8 + DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP +END + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_LIST_COLUMN_NAME "Name" + IDS_LIST_COLUMN_TYPE "Type" + IDS_LIST_COLUMN_DATA "Data" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APP_TITLE "Registry Editor" + IDC_REGEDIT "REGEDIT" + IDC_REGEDIT_FRAME "REGEDIT_FRAME" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_REGISTRY_MENU "Contains commands for working with the whole registry" + ID_EDIT_MENU "Contains commands for editing values or keys" + ID_VIEW_MENU "Contains commands for customising the registry window" + ID_FAVOURITES_MENU "Contains commands for accessing frequently used keys" + ID_HELP_MENU "Contains commands for displaying help and information about registry editor" + ID_EDIT_NEW_MENU "Contains commands for creating new keys or values" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_EDIT_MODIFY "Modifies the value's data" + ID_EDIT_NEW_KEY "Adds a new key" + ID_EDIT_NEW_STRINGVALUE "Adds a new string value" + ID_EDIT_NEW_BINARYVALUE "Adds a new binary value" + ID_EDIT_NEW_DWORDVALUE "Adds a new double word value" + ID_REGISTRY_IMPORTREGISTRYFILE "Imports a text file into the registry" + ID_REGISTRY_EXPORTREGISTRYFILE + "Exports all or part of the registry to a text file" + ID_REGISTRY_CONNECTNETWORKREGISTRY + "Connects to a remote computer's registry" + ID_REGISTRY_DISCONNECTNETWORKREGISTRY + "Disconnects from a remote computer's registry" + ID_REGISTRY_PRINT "Prints all or part of the registry" +// ID_HELP_HELPTOPICS "Opens registry editor help" + ID_HELP_ABOUT "Displays program information, version number and copyright" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_REGISTRY_EXIT "Quits the registry editor" + ID_FAVOURITES_ADDTOFAVOURITES "Adds keys to the favourites list" + ID_FAVOURITES_REMOVEFAVOURITE "Removes keys from the favourites list" + ID_VIEW_STATUSBAR "Shows or hides the status bar" + ID_VIEW_SPLIT "Change position of split between two panes" + ID_VIEW_REFRESH "Refreshes the window" + ID_EDIT_DELETE "Deletes the selection" + ID_EDIT_RENAME "Renames the selection" + ID_EDIT_COPYKEYNAME "Copies the name of the selected key to the clipboard" + ID_EDIT_FIND "Finds a text string in a key, value or data" + ID_EDIT_FINDNEXT "Finds next occurrence of text specified in previous search" +END + +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DIALOG1 DIALOG DISCARDABLE 50, 50, 268, 98 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | + WS_BORDER +FONT 8, "MS Sans Serif" +BEGIN +END + +IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 187, 95 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,130,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,130,24,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +//STRINGTABLE DISCARDABLE +//BEGIN +// ID_HELP_HELPTOPICS "Opens Registry Editor Help." +// ID_HELP_ABOUT "Displays program information, version number, and copyright." +//END + +///////////////////////////////////////////////////////////////////////////// + --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/about.c 2003-06-03 14:12:49.000000000 -0500 @@ -0,0 +1,63 @@ +/* + * ReactOS About Dialog Box + * + * about.c + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ +#include <windows.h> +#include <commctrl.h> +#include <stdlib.h> +#include <tchar.h> +#include <process.h> +#include <stdio.h> + +#include "main.h" +#include "about.h" + + +extern HINSTANCE hInst; + + +LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + HWND hLicenseEditWnd; + TCHAR strLicense[0x1000]; + + switch (message) { + case WM_INITDIALOG: + hLicenseEditWnd = GetDlgItem(hDlg, IDC_LICENSE_EDIT); + LoadString(hInst, IDS_LICENSE, strLicense, 0x1000); + SetWindowText(hLicenseEditWnd, strLicense); + return TRUE; + case WM_COMMAND: + if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) { + EndDialog(hDlg, LOWORD(wParam)); + return TRUE; + } + break; + } + return 0; +} + +void ShowAboutBox(HWND hWnd) +{ + DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)AboutDialogWndProc); +} + --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/about.h 2003-06-03 14:13:10.000000000 -0500 @@ -0,0 +1,37 @@ +/* + * ReactOS About Dialog Box + * + * about.h + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ABOUT_H__ +#define __ABOUT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +void ShowAboutBox(HWND hWnd); + + +#ifdef __cplusplus +}; +#endif + +#endif /* __ABOUT_H__ */ --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/childwnd.c 2003-06-03 14:13:21.000000000 -0500 @@ -0,0 +1,277 @@ +/* + * ReactOS regedit + * + * childwnd.c + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ +#include <windows.h> +#include <tchar.h> +#include <commctrl.h> +#include <assert.h> +#define ASSERT assert + +#include "main.h" +#include "framewnd.h" +#include "childwnd.h" +#include "treeview.h" +#include "listview.h" + + +/******************************************************************************* + * Local module support methods + */ + +static void MakeFullRegPath(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, int max) +{ + TVITEM item; + item.mask = TVIF_PARAM; + item.hItem = hItem; + if (TreeView_GetItem(hwndTV, &item)) { + if (item.hItem != TreeView_GetRoot(hwndTV)) { + /* recurse */ + MakeFullRegPath(hwndTV, TreeView_GetParent(hwndTV, hItem), keyPath, pPathLen, max); + keyPath[*pPathLen] = _T('\\'); + ++(*pPathLen); + } + item.mask = TVIF_TEXT; + item.hItem = hItem; + item.pszText = &keyPath[*pPathLen]; + item.cchTextMax = max - *pPathLen; + if (TreeView_GetItem(hwndTV, &item)) { + *pPathLen += _tcslen(item.pszText); + } + } +} + +static void draw_splitbar(HWND hWnd, int x) +{ + RECT rt; + HDC hdc = GetDC(hWnd); + + GetClientRect(hWnd, &rt); + rt.left = x - SPLIT_WIDTH/2; + rt.right = x + SPLIT_WIDTH/2+1; + InvertRect(hdc, &rt); + ReleaseDC(hWnd, hdc); +} + +static void ResizeWnd(ChildWnd* pChildWnd, int cx, int cy) +{ + HDWP hdwp = BeginDeferWindowPos(2); + RECT rt = {0, 0, cx, cy}; + + 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 , rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE); + EndDeferWindowPos(hdwp); +} + +static void OnPaint(HWND hWnd) +{ + PAINTSTRUCT ps; + RECT rt; + HDC hdc; + + GetClientRect(hWnd, &rt); + hdc = BeginPaint(hWnd, &ps); + FillRect(ps.hdc, &rt, GetStockObject(LTGRAY_BRUSH)); + EndPaint(hWnd, &ps); +} + +/******************************************************************************* + * + * 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) +{ + switch (LOWORD(wParam)) { + /* Parse the menu selections: */ + case ID_REGISTRY_EXIT: + DestroyWindow(hWnd); + break; + case ID_VIEW_REFRESH: + /* TODO */ + break; + default: + return FALSE; + } + return TRUE; +} + +/******************************************************************************* + * + * 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) +{ + static int last_split; +/* ChildWnd* pChildWnd = (ChildWnd*)GetWindowLong(hWnd, GWL_USERDATA); */ + static ChildWnd* pChildWnd; + + switch (message) { + case WM_CREATE: + pChildWnd = (ChildWnd*)((LPCREATESTRUCT)lParam)->lpCreateParams; + ASSERT(pChildWnd); + pChildWnd->nSplitPos = 250; + pChildWnd->hTreeWnd = CreateTreeView(hWnd, pChildWnd->szPath, TREE_WINDOW); + pChildWnd->hListWnd = CreateListView(hWnd, LIST_WINDOW/*, pChildWnd->szPath*/); + break; + case WM_COMMAND: + if (!_CmdWndProc(hWnd, message, wParam, lParam)) { + goto def; + } + break; + case WM_PAINT: + OnPaint(hWnd); + return 0; + case WM_SETCURSOR: + if (LOWORD(lParam) == HTCLIENT) { + POINT pt; + GetCursorPos(&pt); + ScreenToClient(hWnd, &pt); + if (pt.x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && pt.x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) { + SetCursor(LoadCursor(0, IDC_SIZEWE)); + return TRUE; + } + } + goto def; + case WM_DESTROY: + PostQuitMessage(0); + break; + case WM_LBUTTONDOWN: { + RECT rt; + int x = LOWORD(lParam); + GetClientRect(hWnd, &rt); + if (x>=pChildWnd->nSplitPos-SPLIT_WIDTH/2 && x<pChildWnd->nSplitPos+SPLIT_WIDTH/2+1) { + last_split = pChildWnd->nSplitPos; + draw_splitbar(hWnd, last_split); + SetCapture(hWnd); + } + break;} + + case WM_LBUTTONUP: + if (GetCapture() == hWnd) { + RECT rt; + int x = LOWORD(lParam); + draw_splitbar(hWnd, last_split); + last_split = -1; + GetClientRect(hWnd, &rt); + pChildWnd->nSplitPos = x; + ResizeWnd(pChildWnd, rt.right, rt.bottom); + ReleaseCapture(); + } + break; + + case WM_CAPTURECHANGED: + if (GetCapture()==hWnd && last_split>=0) + draw_splitbar(hWnd, last_split); + break; + + case WM_KEYDOWN: + if (wParam == VK_ESCAPE) + if (GetCapture() == hWnd) { + RECT rt; + draw_splitbar(hWnd, last_split); + GetClientRect(hWnd, &rt); + ResizeWnd(pChildWnd, rt.right, rt.bottom); + last_split = -1; + ReleaseCapture(); + SetCursor(LoadCursor(0, IDC_ARROW)); + } + break; + + 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; + + case WM_SETFOCUS: + if (pChildWnd != NULL) { + SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd); + } + break; + + case WM_TIMER: + break; + + case WM_NOTIFY: + if ((int)wParam == TREE_WINDOW) { + switch (((LPNMHDR)lParam)->code) { + case TVN_ITEMEXPANDING: + return !OnTreeExpanding(pChildWnd->hTreeWnd, (NMTREEVIEW*)lParam); + case TVN_SELCHANGED: + { + HKEY hKey; + TCHAR keyPath[1000]; + int keyPathLen = 0; + keyPath[0] = _T('\0'); + hKey = FindRegRoot(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, keyPath, &keyPathLen, sizeof(keyPath)/sizeof(TCHAR)); + RefreshListView(pChildWnd->hListWnd, hKey, keyPath); + + keyPathLen = 0; + keyPath[0] = _T('\0'); + MakeFullRegPath(pChildWnd->hTreeWnd, ((NMTREEVIEW*)lParam)->itemNew.hItem, keyPath, &keyPathLen, sizeof(keyPath)/sizeof(TCHAR)); + SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)keyPath); + } + break; + default: + goto def; + } + } else + if ((int)wParam == LIST_WINDOW) { + if (!SendMessage(pChildWnd->hListWnd, message, wParam, lParam)) { + goto def; + } + } + break; + + case WM_SIZE: + if (wParam != SIZE_MINIMIZED && pChildWnd != NULL) { + ResizeWnd(pChildWnd, LOWORD(lParam), HIWORD(lParam)); + } + /* fall through */ + default: def: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/childwnd.h 2003-06-03 14:13:36.000000000 -0500 @@ -0,0 +1,38 @@ +/* + * ReactOS regedit + * + * childwnd.h + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __CHILDWND_H__ +#define __CHILDWND_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM); + + +#ifdef __cplusplus +}; +#endif + +#endif /* __CHILDWND_H__ */ --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/framewnd.c 2003-06-03 14:36:27.000000000 -0500 @@ -0,0 +1,558 @@ +/* + * ReactOS regedit + * + * framewnd.c + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ + +#include <windows.h> +#include <tchar.h> +#include <commctrl.h> +#include <commdlg.h> +#include <cderr.h> +#include <stdlib.h> +#include <stdio.h> + +#include "main.h" +#include "about.h" +#include "framewnd.h" +#include "treeview.h" +#include "listview.h" +#include <shellapi.h> + +#include "regproc.h" + +/******************************************************************************** + * Global and Local Variables: + */ + +static BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */ + +static HWND hChildWnd; + +/******************************************************************************* + * Local module support methods + */ + +static void resize_frame_rect(HWND hWnd, PRECT prect) +{ + RECT rt; +/* + if (IsWindowVisible(hToolBar)) { + SendMessage(hToolBar, WM_SIZE, 0, 0); + GetClientRect(hToolBar, &rt); + prect->top = rt.bottom+3; + prect->bottom -= rt.bottom+3; + } + */ + if (IsWindowVisible(hStatusBar)) { + SetupStatusBar(hWnd, TRUE); + GetClientRect(hStatusBar, &rt); + prect->bottom -= rt.bottom; + } + MoveWindow(hChildWnd, prect->left, prect->top, prect->right, prect->bottom, TRUE); +} + +void resize_frame_client(HWND hWnd) +{ + RECT rect; + + GetClientRect(hWnd, &rect); + resize_frame_rect(hWnd, &rect); +} + +/********************************************************************************/ + +static void OnEnterMenuLoop(HWND hWnd) +{ + int nParts; + + /* Update the status bar pane sizes */ + nParts = -1; + SendMessage(hStatusBar, SB_SETPARTS, 1, (long)&nParts); + bInMenuLoop = TRUE; + SendMessage(hStatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)_T("")); +} + +static void OnExitMenuLoop(HWND hWnd) +{ + bInMenuLoop = FALSE; + /* Update the status bar pane sizes*/ + SetupStatusBar(hWnd, TRUE); + UpdateStatusBar(); +} + +static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu) +{ + TCHAR str[100]; + + _tcscpy(str, _T("")); + if (nFlags & MF_POPUP) { + if (hSysMenu != GetMenu(hWnd)) { + if (nItemID == 2) nItemID = 5; + } + } + if (LoadString(hInst, nItemID, str, 100)) { + /* load appropriate string*/ + LPTSTR lpsz = str; + /* first newline terminates actual string*/ + lpsz = _tcschr(lpsz, '\n'); + if (lpsz != NULL) + *lpsz = '\0'; + } + SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)str); +} + +void SetupStatusBar(HWND hWnd, BOOL bResize) +{ + RECT rc; + int nParts; + GetClientRect(hWnd, &rc); + nParts = rc.right; +/* nParts = -1;*/ + if (bResize) + SendMessage(hStatusBar, WM_SIZE, 0, 0); + SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts); +} + +void UpdateStatusBar(void) +{ + TCHAR text[260]; + DWORD size; + + size = sizeof(text)/sizeof(TCHAR); + GetComputerName(text, &size); + SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)text); +} + +static void toggle_child(HWND hWnd, UINT cmd, HWND hchild) +{ + BOOL vis = IsWindowVisible(hchild); + HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU); + + CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED); + ShowWindow(hchild, vis?SW_HIDE:SW_SHOW); + resize_frame_client(hWnd); +} + +static BOOL CheckCommDlgError(HWND hWnd) +{ + DWORD dwErrorCode = CommDlgExtendedError(); + switch (dwErrorCode) { + case CDERR_DIALOGFAILURE: + break; + case CDERR_FINDRESFAILURE: + break; + case CDERR_NOHINSTANCE: + break; + case CDERR_INITIALIZATION: + break; + case CDERR_NOHOOK: + break; + case CDERR_LOCKRESFAILURE: + break; + case CDERR_NOTEMPLATE: + break; + case CDERR_LOADRESFAILURE: + break; + case CDERR_STRUCTSIZE: + break; + case CDERR_LOADSTRFAILURE: + break; + case FNERR_BUFFERTOOSMALL: + break; + case CDERR_MEMALLOCFAILURE: + break; + case FNERR_INVALIDFILENAME: + break; + case CDERR_MEMLOCKFAILURE: + break; + case FNERR_SUBCLASSFAILURE: + break; + default: + break; + } + return TRUE; +} + +UINT_PTR CALLBACK ImportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + OPENFILENAME* pOpenFileName; + OFNOTIFY* pOfNotify; + + switch (uiMsg) { + case WM_INITDIALOG: + pOpenFileName = (OPENFILENAME*)lParam; + break; + case WM_NOTIFY: + pOfNotify = (OFNOTIFY*)lParam; + if (pOfNotify->hdr.code == CDN_INITDONE) { + } + break; + default: + break; + } + return 0L; +} + +#define MAX_CUSTOM_FILTER_SIZE 50 +TCHAR CustomFilterBuffer[MAX_CUSTOM_FILTER_SIZE]; +TCHAR FileNameBuffer[_MAX_PATH]; +TCHAR FileTitleBuffer[_MAX_PATH]; + +static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn) +{ + memset(pofn, 0, sizeof(OPENFILENAME)); + pofn->lStructSize = sizeof(OPENFILENAME); + pofn->hwndOwner = hWnd; + pofn->hInstance = hInst; + + pofn->lpstrFilter = _T("Registration Files\0*.reg\0Win9x/NT4 Registration Files (REGEDIT4)\0*.reg\0All Files (*.*)\0*.*\0\0"); + pofn->lpstrCustomFilter = CustomFilterBuffer; + pofn->nMaxCustFilter = MAX_CUSTOM_FILTER_SIZE; + pofn->nFilterIndex = 0; + pofn->lpstrFile = FileNameBuffer; + pofn->nMaxFile = _MAX_PATH; + pofn->lpstrFileTitle = FileTitleBuffer; + pofn->nMaxFileTitle = _MAX_PATH; +/* pofn->lpstrInitialDir = _T("");*/ +/* pofn->lpstrTitle = _T("Import Registry File");*/ +/* pofn->Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER + OFN_ENABLESIZING;*/ + pofn->Flags = OFN_HIDEREADONLY; +/* pofn->nFileOffset = ;*/ +/* pofn->nFileExtension = ;*/ +/* pofn->lpstrDefExt = _T("");*/ +/* pofn->lCustData = ;*/ +/* pofn->lpfnHook = ImportRegistryFile_OFNHookProc;*/ +/* pofn->lpTemplateName = _T("ID_DLG_IMPORT_REGFILE");*/ +/* pofn->lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1);*/ +/* pofn->FlagsEx = ;*/ + return TRUE; +} + +static BOOL ImportRegistryFile(HWND hWnd) +{ + OPENFILENAME ofn; + + InitOpenFileName(hWnd, &ofn); + ofn.lpstrTitle = _T("Import Registry File"); +/* ofn.lCustData = ;*/ + if (GetOpenFileName(&ofn)) { + if (!import_registry_file(ofn.lpstrFile)) { + /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/ + return FALSE; + } +#if 0 + get_file_name(&s, filename, MAX_PATH); + if (!filename[0]) { + printf("No file name is specified\n%s", usage); + return FALSE; + /*exit(1);*/ + } + while (filename[0]) { + if (!import_registry_file(filename)) { + perror(""); + printf("Can't open file \"%s\"\n", filename); + return FALSE; + /*exit(1);*/ + } + get_file_name(&s, filename, MAX_PATH); + } +#endif + } else { + CheckCommDlgError(hWnd); + } + return TRUE; +} + + +static BOOL ExportRegistryFile(HWND hWnd) +{ + OPENFILENAME ofn; + TCHAR ExportKeyPath[_MAX_PATH]; + + ExportKeyPath[0] = _T('\0'); + InitOpenFileName(hWnd, &ofn); + ofn.lpstrTitle = _T("Export Registry File"); +/* ofn.lCustData = ;*/ + ofn.Flags = OFN_ENABLETEMPLATE + OFN_EXPLORER; + ofn.lpfnHook = ImportRegistryFile_OFNHookProc; + ofn.lpTemplateName = MAKEINTRESOURCE(IDD_DIALOG1); + if (GetSaveFileName(&ofn)) { + BOOL result; + result = export_registry_key(ofn.lpstrFile, ExportKeyPath); + /*result = export_registry_key(ofn.lpstrFile, NULL);*/ + /*if (!export_registry_key(ofn.lpstrFile, NULL)) {*/ + if (!result) { + /*printf("Can't open file \"%s\"\n", ofn.lpstrFile);*/ + return FALSE; + } +#if 0 + TCHAR filename[MAX_PATH]; + filename[0] = '\0'; + get_file_name(&s, filename, MAX_PATH); + if (!filename[0]) { + printf("No file name is specified\n%s", usage); + return FALSE; + /*exit(1);*/ + } + if (s[0]) { + TCHAR reg_key_name[KEY_MAX_LEN]; + get_file_name(&s, reg_key_name, KEY_MAX_LEN); + export_registry_key(filename, reg_key_name); + } else { + export_registry_key(filename, NULL); + } +#endif + } else { + CheckCommDlgError(hWnd); + } + return TRUE; +} + +BOOL PrintRegistryHive(HWND hWnd, LPTSTR path) +{ +#if 1 + PRINTDLG pd; + + ZeroMemory(&pd, sizeof(PRINTDLG)); + pd.lStructSize = sizeof(PRINTDLG); + pd.hwndOwner = hWnd; + pd.hDevMode = NULL; /* Don't forget to free or store hDevMode*/ + pd.hDevNames = NULL; /* Don't forget to free or store hDevNames*/ + pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC; + pd.nCopies = 1; + pd.nFromPage = 0xFFFF; + pd.nToPage = 0xFFFF; + pd.nMinPage = 1; + pd.nMaxPage = 0xFFFF; + if (PrintDlg(&pd) == TRUE) { + /* GDI calls to render output. */ + DeleteDC(pd.hDC); /* Delete DC when done.*/ + } +#else + HRESULT hResult; + PRINTDLGEX pd; + + hResult = PrintDlgEx(&pd); + if (hResult == S_OK) { + switch (pd.dwResultAction) { + case PD_RESULT_APPLY: + /*The user clicked the Apply button and later clicked the Cancel button. This indicates that the user wants to apply the changes made in the property sheet, but does not yet want to print. The PRINTDLGEX structure contains the information specified by the user at the time the Apply button was clicked. */ + break; + case PD_RESULT_CANCEL: + /*The user clicked the Cancel button. The information in the PRINTDLGEX structure is unchanged. */ + break; + case PD_RESULT_PRINT: + /*The user clicked the Print button. The PRINTDLGEX structure contains the information specified by the user. */ + break; + default: + break; + } + } else { + switch (hResult) { + case E_OUTOFMEMORY: + /*Insufficient memory. */ + break; + case E_INVALIDARG: + /* One or more arguments are invalid. */ + break; + case E_POINTER: + /*Invalid pointer. */ + break; + case E_HANDLE: + /*Invalid handle. */ + break; + case E_FAIL: + /*Unspecified error. */ + break; + default: + break; + } + return FALSE; + } +#endif + return TRUE; +} + +BOOL CopyKeyName(HWND hWnd, LPTSTR keyName) +{ + BOOL result; + + result = OpenClipboard(hWnd); + if (result) { + result = EmptyClipboard(); + if (result) { + + /*HANDLE hClipData;*/ + /*hClipData = SetClipboardData(UINT uFormat, HANDLE hMem);*/ + + } else { + /* error emptying clipboard*/ + /* DWORD dwError = GetLastError(); */ + ; + } + if (!CloseClipboard()) { + /* error closing clipboard*/ + /* DWORD dwError = GetLastError(); */ + ; + } + } else { + /* error opening clipboard*/ + /* DWORD dwError = GetLastError(); */ + ; + } + return result; +} + +BOOL RefreshView(HWND hWnd) +{ + /* TODO:*/ + MessageBeep(-1); + MessageBeep(MB_ICONASTERISK); + MessageBeep(MB_ICONEXCLAMATION); + MessageBeep(MB_ICONHAND); + MessageBeep(MB_ICONQUESTION); + MessageBeep(MB_OK); + return TRUE; +} + +/******************************************************************************* + * + * 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) +{ + switch (LOWORD(wParam)) { + /* Parse the menu selections:*/ + case ID_REGISTRY_IMPORTREGISTRYFILE: + ImportRegistryFile(hWnd); + break; + case ID_REGISTRY_EXPORTREGISTRYFILE: + ExportRegistryFile(hWnd); + break; + case ID_REGISTRY_CONNECTNETWORKREGISTRY: + break; + case ID_REGISTRY_DISCONNECTNETWORKREGISTRY: + break; + case ID_REGISTRY_PRINT: + PrintRegistryHive(hWnd, _T("")); + break; + case ID_EDIT_COPYKEYNAME: + CopyKeyName(hWnd, _T("")); + break; + case ID_REGISTRY_PRINTERSETUP: + /*PRINTDLG pd;*/ + /*PrintDlg(&pd);*/ + /*PAGESETUPDLG psd;*/ + /*PageSetupDlg(&psd);*/ + break; + case ID_REGISTRY_OPENLOCAL: + break; + case ID_REGISTRY_EXIT: + DestroyWindow(hWnd); + break; + case ID_VIEW_REFRESH: + RefreshView(hWnd); + break; +/* case ID_OPTIONS_TOOLBAR:*/ +/* toggle_child(hWnd, LOWORD(wParam), hToolBar);*/ +/* break;*/ + case ID_VIEW_STATUSBAR: + toggle_child(hWnd, LOWORD(wParam), hStatusBar); + break; + case ID_HELP_HELPTOPICS: +/* WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);*/ + WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0); + break; + case ID_HELP_ABOUT: +#ifdef WINSHELLAPI +/* ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));*/ +#else + ShowAboutBox(hWnd); +#endif + break; + default: + return FALSE; + } + return TRUE; +} + +/******************************************************************************** + * + * FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG) + * + * PURPOSE: Processes messages for the main frame window. + * + * WM_COMMAND - process the application menu + * WM_DESTROY - post a quit message and return + * + */ + +LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + static ChildWnd* pChildWnd = NULL; + + switch (message) { + case WM_CREATE: + { + pChildWnd = HeapAlloc(GetProcessHeap(), 0, sizeof(ChildWnd)); + _tcsncpy(pChildWnd->szPath, _T("My Computer"), MAX_PATH); + hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"), +/* WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,*/ + WS_CHILD|WS_VISIBLE | WS_EX_CLIENTEDGE, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + hWnd, (HMENU)0, hInst, pChildWnd); + } + break; + case WM_COMMAND: + if (!_CmdWndProc(hWnd, message, wParam, lParam)) { + return DefWindowProc(hWnd, message, wParam, lParam); + } + break; + case WM_SIZE: + resize_frame_client(hWnd); + break; + case WM_TIMER: + break; + case WM_ENTERMENULOOP: + OnEnterMenuLoop(hWnd); + break; + case WM_EXITMENULOOP: + OnExitMenuLoop(hWnd); + break; + case WM_MENUSELECT: + OnMenuSelect(hWnd, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam); + break; + case WM_DESTROY: + if (pChildWnd) { + HeapFree(GetProcessHeap(), 0, pChildWnd); + pChildWnd = NULL; + } + WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0); + PostQuitMessage(0); + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/framewnd.h 2003-06-03 14:24:44.000000000 -0500 @@ -0,0 +1,41 @@ +/* + * ReactOS regedit + * + * framewnd.h + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __FRAMEWND_H__ +#define __FRAMEWND_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +LRESULT CALLBACK FrameWndProc(HWND, UINT, WPARAM, LPARAM); + +void SetupStatusBar(HWND hWnd, BOOL bResize); +void UpdateStatusBar(void); + + +#ifdef __cplusplus +}; +#endif + +#endif /* __FRAMEWND_H__ */ --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/hex_str.c 2003-06-03 14:32:13.000000000 -0500 @@ -0,0 +1,153 @@ +/****************************************************************************** + * HEX_STR.C + * Copyright (c) 1995 by Robert Dickenson + */ +#include "hex_str.h" + + +#define LOBYTE(w) ((unsigned char)(w)) +#define HIBYTE(w) ((unsigned char)((unsigned short)(w) >> 8)) + + +unsigned char AsciiTable[256][3] = { + "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0A", "0B", "0C", "0D", "0E", "0F", + "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1A", "1B", "1C", "1D", "1E", "1F", + "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2A", "2B", "2C", "2D", "2E", "2F", + "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3A", "3B", "3C", "3D", "3E", "3F", + "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4A", "4B", "4C", "4D", "4E", "4F", + "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5A", "5B", "5C", "5D", "5E", "5F", + "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6A", "6B", "6C", "6D", "6E", "6F", + "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7A", "7B", "7C", "7D", "7E", "7F", + "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8A", "8B", "8C", "8D", "8E", "8F", + "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9A", "9B", "9C", "9D", "9E", "9F", + "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "AA", "AB", "AC", "AD", "AE", "AF", + "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "BA", "BB", "BC", "BD", "BE", "BF", + "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "CA", "CB", "CC", "CD", "CE", "CF", + "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "DA", "DB", "DC", "DD", "DE", "DF", + "E0", "E1", "E2", "E3", "E4", "E5", "E6", "E7", "E8", "E9", "EA", "EB", "EC", "ED", "EE", "EF", + "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "FA", "FB", "FC", "FD", "FE", "FF" +}; + +unsigned char HexTable[24] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15, 16 +}; + +unsigned long BinaryNibbles[] = { + (unsigned long)"0000", + (unsigned long)"0001", + (unsigned long)"0010", + (unsigned long)"0011", + (unsigned long)"0100", + (unsigned long)"0101", + (unsigned long)"0110", + (unsigned long)"0111", + (unsigned long)"1000", + (unsigned long)"1001", + (unsigned long)"1010", + (unsigned long)"1011", + (unsigned long)"1100", + (unsigned long)"1101", + (unsigned long)"1110", + (unsigned long)"1111" +}; + + +void ByteBinStr(char* dst, unsigned char num) +{ + *(unsigned long*)dst++ = BinaryNibbles[(num >> 4) & 0x07]; + *(unsigned long*)dst++ = BinaryNibbles[num & 0x07]; +} + +void WordBinStr(char* dst, unsigned short num) +{ + ByteBinStr(dst, HIBYTE(num)); + ByteBinStr(dst+4, LOBYTE(num)); +} + +unsigned short Byte2Hex(unsigned char data) +{ + register unsigned short result; + + result = AsciiTable[data][1] << 8; + result += AsciiTable[data][0]; + return result; +} + +unsigned long Word2Hex(unsigned short data) +{ + register unsigned long result; + + result = (unsigned long)Byte2Hex(LOBYTE(data)) << 16; + result += Byte2Hex(HIBYTE(data)); + return result; +} + +unsigned char HexByte(char* str) +{ + register unsigned char result; + + result = HexTable[*str++ - '0'] * 16; + result += HexTable[*str++ - '0']; + return result; +} + +unsigned int HexWord(char* str) +{ + register unsigned int result; + + result = HexByte(str) << 8; + result += HexByte(str+2); + return result; +} + +unsigned long HexLong(char* str) +{ + register unsigned long result; + + result = HexByte(str++) << 24; + result += HexByte(str++) << 16; + result += HexByte(str++) << 8; + result += HexByte(str); + return result; +} + +unsigned long HexString(char* str) +{ + unsigned long temp = 0; + + while ( *str ) + { + temp <<= 4; + switch ( *str++ ) + { + case '0': break; + case '1': temp += 1; break; + case '2': temp += 2; break; + case '3': temp += 3; break; + case '4': temp += 4; break; + case '5': temp += 5; break; + case '6': temp += 6; break; + case '7': temp += 7; break; + case '8': temp += 8; break; + case '9': temp += 9; break; + case 'A': temp += 10; break; + case 'B': temp += 11; break; + case 'C': temp += 12; break; + case 'D': temp += 13; break; + case 'E': temp += 14; break; + case 'F': temp += 15; break; + case 'a': temp += 10; break; + case 'b': temp += 11; break; + case 'c': temp += 12; break; + case 'd': temp += 13; break; + case 'e': temp += 14; break; + case 'f': temp += 15; break; + case 'X': temp = 0; break; + case 'x': temp = 0; break; + default: return temp; + } + } + return temp; +} + +/*****************************************************************************/ --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/hex_str.h 2003-06-03 14:25:28.000000000 -0500 @@ -0,0 +1,30 @@ +/****************************************************************************** + * HEX_STR.H + * Copyright (c) 1995 by Robert Dickenson + */ +#ifndef __HEX_STR_H__ +#define __HEX_STR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +unsigned short Byte2Hex(unsigned char); +unsigned long Word2Hex(unsigned short); +unsigned char HexByte(char*); +unsigned int HexWord(char*); +unsigned long HexLong(char*); +unsigned long HexString(char*); + +void ByteBinStr(char*, unsigned char); +void WordBinStr(char*, unsigned short); +unsigned long HexString(char*); + + +#ifdef __cplusplus +} +#endif + +#endif /* __HEX_STR_H__ */ +/******************************************************************************/ --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/listview.c 2003-06-03 14:14:24.000000000 -0500 @@ -0,0 +1,385 @@ +/* + * ReactOS regedit + * + * listview.c + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <windows.h> +#include <commctrl.h> +#include <stdlib.h> +#include <tchar.h> +#include <process.h> +#include <stdio.h> + +#include "commctrl.h" + +#include <windowsx.h> +#include "main.h" +#include "listview.h" +#include "hex_str.h" + + +/******************************************************************************* + * Global and Local Variables: + */ + +static WNDPROC g_orgListWndProc; + +#define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1) +static int default_column_widths[MAX_LIST_COLUMNS] = { 200, 175, 400 }; +static int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_LEFT }; + + +/******************************************************************************* + * Local module support methods + */ +extern unsigned char AsciiTable[256][3]; + +static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValBuf, DWORD dwCount) +{ + LVITEM item; + int index; + + item.mask = LVIF_TEXT | LVIF_PARAM; + item.iItem = 0;/*idx; */ + item.iSubItem = 0; + item.state = 0; + item.stateMask = 0; + item.pszText = Name; + item.cchTextMax = _tcslen(item.pszText); + if (item.cchTextMax == 0) + item.pszText = LPSTR_TEXTCALLBACK; + item.iImage = 0; + item.lParam = (LPARAM)dwValType; +/* item.lParam = (LPARAM)ValBuf; */ +#if (_WIN32_IE >= 0x0300) + item.iIndent = 0; +#endif + + index = ListView_InsertItem(hwndLV, &item); + if (index != -1) { +/* LPTSTR pszText = NULL; */ + LPTSTR pszText = _T("value"); + switch (dwValType) { + case REG_SZ: + case REG_EXPAND_SZ: + ListView_SetItemText(hwndLV, index, 2, ValBuf); + break; + case REG_DWORD: + { + TCHAR buf[64]; + wsprintf(buf, _T("0x%08X (%d)"), *(DWORD*)ValBuf, *(DWORD*)ValBuf); + ListView_SetItemText(hwndLV, index, 2, buf); + } +/* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */ + break; + case REG_BINARY: + { + unsigned int i; + LPTSTR pData = (LPTSTR)ValBuf; + LPTSTR strBinary = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(TCHAR) * 3 + 1); + memset(strBinary, _T(' '), dwCount * sizeof(TCHAR) * 3); + strBinary[dwCount * sizeof(TCHAR) * 3] = _T('\0'); + for (i = 0; i < dwCount; i++) { + unsigned short* pShort; + pShort = (unsigned short*)&(strBinary[i*3]); +/* strBinary[i*3] = Byte2Hex((LPTSTR)ValBuf+i); */ +/* *pShort++ = Byte2Hex(*(pData+i)); */ + *pShort = Byte2Hex(*(pData+i)); + } + ListView_SetItemText(hwndLV, index, 2, strBinary); + HeapFree(GetProcessHeap(), 0, strBinary); + } + break; + default: +/* lpsRes = convertHexToHexCSV(lpbData, dwLen); */ + ListView_SetItemText(hwndLV, index, 2, pszText); + break; + } + } +} + +static void CreateListColumns(HWND hWndListView) +{ + TCHAR szText[50]; + int index; + LV_COLUMN lvC; + + /* Create columns. */ + lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvC.pszText = szText; + + /* Load the column labels from the resource file. */ + for (index = 0; index < MAX_LIST_COLUMNS; index++) { + lvC.iSubItem = index; + lvC.cx = default_column_widths[index]; + lvC.fmt = column_alignment[index]; + LoadString(hInst, IDS_LIST_COLUMN_FIRST + index, szText, sizeof(szText)/sizeof(TCHAR)); + if (ListView_InsertColumn(hWndListView, index, &lvC) == -1) { + /* TODO: handle failure condition... */ + break; + } + } +} + +/* OnGetDispInfo - processes the LVN_GETDISPINFO notification message. */ + +static void OnGetDispInfo(NMLVDISPINFO* plvdi) +{ + static TCHAR buffer[200]; + + plvdi->item.pszText = NULL; + plvdi->item.cchTextMax = 0; + + switch (plvdi->item.iSubItem) { + case 0: + plvdi->item.pszText = _T("(Default)"); + break; + case 1: + switch (plvdi->item.lParam) { + case REG_SZ: + plvdi->item.pszText = _T("REG_SZ"); + break; + case REG_EXPAND_SZ: + plvdi->item.pszText = _T("REG_EXPAND_SZ"); + break; + case REG_BINARY: + plvdi->item.pszText = _T("REG_BINARY"); + break; + case REG_DWORD: + plvdi->item.pszText = _T("REG_DWORD"); + break; +/* case REG_DWORD_LITTLE_ENDIAN: */ +/* plvdi->item.pszText = _T("REG_DWORD_LITTLE_ENDIAN"); */ +/* break; */ + case REG_DWORD_BIG_ENDIAN: + plvdi->item.pszText = _T("REG_DWORD_BIG_ENDIAN"); + break; + case REG_MULTI_SZ: + plvdi->item.pszText = _T("REG_MULTI_SZ"); + break; + case REG_LINK: + plvdi->item.pszText = _T("REG_LINK"); + break; + case REG_RESOURCE_LIST: + plvdi->item.pszText = _T("REG_RESOURCE_LIST"); + break; + case REG_NONE: + plvdi->item.pszText = _T("REG_NONE"); + break; + default: + wsprintf(buffer, _T("unknown(%d)"), plvdi->item.lParam); + plvdi->item.pszText = buffer; + break; + } + break; + case 2: + plvdi->item.pszText = _T("(value not set)"); + break; + case 3: + plvdi->item.pszText = _T(""); + break; + } +} + +#if 0 +static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) +{ + TCHAR buf1[1000]; + TCHAR buf2[1000]; + + ListView_GetItemText((HWND)lParamSort, lParam1, 0, buf1, sizeof(buf1)); + ListView_GetItemText((HWND)lParamSort, lParam2, 0, buf2, sizeof(buf2)); + return _tcscmp(buf1, buf2); +} +#endif + +static void ListViewPopUpMenu(HWND hWnd, POINT pt) +{ +} + +static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (LOWORD(wParam)) { +/* case ID_FILE_OPEN: */ +/* break; */ + default: + return FALSE; + } + return TRUE; +} + +static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { + case WM_COMMAND: + if (!_CmdWndProc(hWnd, message, wParam, lParam)) { + return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); + } + break; + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->code) { + case LVN_GETDISPINFO: + OnGetDispInfo((NMLVDISPINFO*)lParam); + break; + case NM_DBLCLK: + { + NMITEMACTIVATE* nmitem = (LPNMITEMACTIVATE)lParam; + LVHITTESTINFO info; + + if (nmitem->hdr.hwndFrom != hWnd) break; +/* if (nmitem->hdr.idFrom != IDW_LISTVIEW) break; */ +/* if (nmitem->hdr.code != ???) break; */ +#ifdef _MSC_VER + switch (nmitem->uKeyFlags) { + case LVKF_ALT: /* The ALT key is pressed. */ + /* properties dialog box ? */ + break; + case LVKF_CONTROL: /* The CTRL key is pressed. */ + /* run dialog box for providing parameters... */ + break; + case LVKF_SHIFT: /* The SHIFT key is pressed. */ + break; + } +#endif + info.pt.x = nmitem->ptAction.x; + info.pt.y = nmitem->ptAction.y; + if (ListView_HitTest(hWnd, &info) != -1) { + LVITEM item; + item.mask = LVIF_PARAM; + item.iItem = info.iItem; + if (ListView_GetItem(hWnd, &item)) { + } + } + } + break; + + case NM_RCLICK: + { + int idx; + LV_HITTESTINFO lvH; + NM_LISTVIEW* pNm = (NM_LISTVIEW*)lParam; + lvH.pt.x = pNm->ptAction.x; + lvH.pt.y = pNm->ptAction.y; + idx = ListView_HitTest(hWnd, &lvH); + if (idx != -1) { + POINT pt; + GetCursorPos(&pt); + ListViewPopUpMenu(hWnd, pt); + return idx; + } + } + break; + + default: + return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); + } + break; + case WM_KEYDOWN: + if (wParam == VK_TAB) { + /*TODO: SetFocus(Globals.hDriveBar) */ + /*SetFocus(child->nFocusPanel? child->left.hWnd: child->right.hWnd); */ + } + /* fall thru... */ + default: + return CallWindowProc(g_orgListWndProc, hWnd, message, wParam, lParam); + break; + } + return 0; +} + + +HWND CreateListView(HWND hwndParent, int id) +{ + RECT rcClient; + HWND hwndLV; + + /* Get the dimensions of the parent window's client area, and create the list view control. */ + GetClientRect(hwndParent, &rcClient); + hwndLV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, _T("List View"), + WS_VISIBLE | WS_CHILD | LVS_REPORT, + 0, 0, rcClient.right, rcClient.bottom, + hwndParent, (HMENU)id, hInst, NULL); + ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT); + + /* Initialize the image list, and add items to the control. */ +/* + if (!InitListViewImageLists(hwndLV) || + !InitListViewItems(hwndLV, szName)) { + DestroyWindow(hwndLV); + return FALSE; + } + */ + CreateListColumns(hwndLV); + g_orgListWndProc = SubclassWindow(hwndLV, ListWndProc); + return hwndLV; +} + +BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPTSTR keyPath) +{ + if (hwndLV != NULL) { + ListView_DeleteAllItems(hwndLV); + } + + if (hKey != NULL) { + HKEY hNewKey; + LONG errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey); + if (errCode == ERROR_SUCCESS) { + DWORD max_sub_key_len; + DWORD max_val_name_len; + DWORD max_val_size; + DWORD val_count; + ShowWindow(hwndLV, SW_HIDE); + /* get size information and resize the buffers if necessary */ + errCode = RegQueryInfoKey(hNewKey, NULL, NULL, NULL, NULL, + &max_sub_key_len, NULL, &val_count, &max_val_name_len, &max_val_size, NULL, NULL); + +#define BUF_HEAD_SPACE 2 /* TODO: check why this is required with ROS ??? */ + + if (errCode == ERROR_SUCCESS) { + TCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(TCHAR) + BUF_HEAD_SPACE); + DWORD dwValNameLen = max_val_name_len; + BYTE* ValBuf = HeapAlloc(GetProcessHeap(), 0, ++max_val_size/* + BUF_HEAD_SPACE*/); + DWORD dwValSize = max_val_size; + DWORD dwIndex = 0L; + DWORD dwValType; +/* if (RegQueryValueEx(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */ +/* AddEntryToList(hwndLV, _T("(Default)"), dwValType, ValBuf, dwValSize); */ +/* } */ +/* dwValSize = max_val_size; */ + while (RegEnumValue(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { + ValBuf[dwValSize] = 0; + AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize); + dwValNameLen = max_val_name_len; + dwValSize = max_val_size; + dwValType = 0L; + ++dwIndex; + } + HeapFree(GetProcessHeap(), 0, ValBuf); + HeapFree(GetProcessHeap(), 0, ValName); + } + /*ListView_SortItemsEx(hwndLV, CompareFunc, hwndLV); */ +/* SendMessage(hwndLV, LVM_SORTITEMSEX, (WPARAM)CompareFunc, (LPARAM)hwndLV); */ + ShowWindow(hwndLV, SW_SHOW); + RegCloseKey(hNewKey); + } + } + return TRUE; +} + --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/listview.h 2003-06-03 14:17:34.000000000 -0500 @@ -0,0 +1,39 @@ +/* + * ReactOS regedit + * + * listview.h + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LISTVIEW_H__ +#define __LISTVIEW_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +HWND CreateListView(HWND hwndParent, int id); +BOOL RefreshListView(HWND hwndTV, HKEY hKey, LPTSTR keyPath); + + +#ifdef __cplusplus +}; +#endif + +#endif /* __LISTVIEW_H__ */ --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/main.c 2003-06-04 00:38:52.000000000 -0500 @@ -0,0 +1,196 @@ +/* + * ReactOS regedit + * + * main.c + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ +#include <windows.h> +#include <commctrl.h> +#include <stdlib.h> +#include <tchar.h> +#include <process.h> +#include <stdio.h> +#include <fcntl.h> + +#include "main.h" +#include "framewnd.h" +#include "childwnd.h" + + +BOOL ProcessCmdLine(LPSTR lpCmdLine); + + +/******************************************************************************* + * Global Variables: + */ + +HINSTANCE hInst; +HWND hFrameWnd; +HWND hStatusBar; +HMENU hMenuFrame; +UINT nClipboardFormat; +LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT"); + + +TCHAR szTitle[MAX_LOADSTRING]; +TCHAR szFrameClass[MAX_LOADSTRING]; +TCHAR szChildClass[MAX_LOADSTRING]; + + +/******************************************************************************* + * + * + * FUNCTION: InitInstance(HANDLE, int) + * + * PURPOSE: Saves instance handle and creates main window + * + * COMMENTS: + * + * In this function, we save the instance handle in a global variable and + * create and display the main program window. + */ + +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + WNDCLASSEX wcFrame = { + sizeof(WNDCLASSEX), + CS_HREDRAW | CS_VREDRAW/*style*/, + FrameWndProc, + 0/*cbClsExtra*/, + 0/*cbWndExtra*/, + hInstance, + LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)), + LoadCursor(0, IDC_ARROW), + 0/*hbrBackground*/, + 0/*lpszMenuName*/, + szFrameClass, + (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) + }; + ATOM hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */ + + WNDCLASSEX wcChild = { + sizeof(WNDCLASSEX), + CS_HREDRAW | CS_VREDRAW/*style*/, + ChildWndProc, + 0/*cbClsExtra*/, + sizeof(HANDLE)/*cbWndExtra*/, + hInstance, + LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)), + LoadCursor(0, IDC_ARROW), + 0/*hbrBackground*/, + 0/*lpszMenuName*/, + szChildClass, + (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED) + + }; + ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */ + hChildWndClass = hChildWndClass; /* warning eater */ + + hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU)); + + /* Initialize the Windows Common Controls DLL */ + InitCommonControls(); + + nClipboardFormat = RegisterClipboardFormat(strClipboardFormat); + /* if (nClipboardFormat == 0) { + DWORD dwError = GetLastError(); + } */ + + hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle, + WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + NULL, hMenuFrame, hInstance, NULL/*lpParam*/); + + if (!hFrameWnd) { + return FALSE; + } + + /* Create the status bar */ + hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, + _T(""), hFrameWnd, STATUS_WINDOW); + if (hStatusBar) { + /* Create the status bar panes */ + SetupStatusBar(hFrameWnd, FALSE); + CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED); + } + ShowWindow(hFrameWnd, nCmdShow); + UpdateWindow(hFrameWnd); + return TRUE; +} + +/******************************************************************************/ + +void ExitInstance(void) +{ + DestroyMenu(hMenuFrame); +} + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ + MSG msg; + HACCEL hAccel; +/* + int hCrt; + FILE *hf; + AllocConsole(); + hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); + hf = _fdopen(hCrt, "w"); + *stdout = *hf; + setvbuf(stdout, NULL, _IONBF, 0); + + wprintf(L"command line exit, hInstance = %d\n", hInstance); + getch(); + FreeConsole(); + return 0; + */ + + if (ProcessCmdLine(lpCmdLine)) { + return 0; + } + + /* Initialize global strings */ + LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + LoadString(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING); + LoadString(hInstance, IDC_REGEDIT, szChildClass, MAX_LOADSTRING); + + /* Store instance handle in our global variable */ + hInst = hInstance; + + /* Perform application initialization */ + if (!InitInstance(hInstance, nCmdShow)) { + return FALSE; + } + hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_REGEDIT); + + /* Main message loop */ + while (GetMessage(&msg, (HWND)NULL, 0, 0)) { + if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + ExitInstance(); + return msg.wParam; +} --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/main.h 2003-06-03 14:25:43.000000000 -0500 @@ -0,0 +1,83 @@ +/* + * ReactOS regedit + * + * main.h + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "resource.h" + + +#define STATUS_WINDOW 2001 +#define TREE_WINDOW 2002 +#define LIST_WINDOW 2003 + +#define MAX_LOADSTRING 100 +#define SPLIT_WIDTH 5 +#define MAX_NAME_LEN 500 + + +/******************************************************************************/ + +enum OPTION_FLAGS { + OPTIONS_AUTO_REFRESH = 0x01, + OPTIONS_READ_ONLY_MODE = 0x02, + OPTIONS_CONFIRM_ON_DELETE = 0x04, + OPTIONS_SAVE_ON_EXIT = 0x08, + OPTIONS_DISPLAY_BINARY_DATA = 0x10, + OPTIONS_VIEW_TREE_ONLY = 0x20, + OPTIONS_VIEW_DATA_ONLY = 0x40, +}; + +typedef struct { + HWND hWnd; + HWND hTreeWnd; + HWND hListWnd; + int nFocusPanel; /* 0: left 1: right */ + int nSplitPos; + WINDOWPLACEMENT pos; + TCHAR szPath[MAX_PATH]; +} ChildWnd; + +/******************************************************************************* + * Global Variables: + */ +extern HINSTANCE hInst; +extern HWND hFrameWnd; +extern HMENU hMenuFrame; +extern HWND hStatusBar; +extern HFONT hFont; +extern enum OPTION_FLAGS Options; + +extern TCHAR szTitle[]; +extern TCHAR szFrameClass[]; +extern TCHAR szChildClass[]; + +#ifdef __cplusplus +}; +#endif + +#endif /* __MAIN_H__ */ --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/regedit.rc 2003-06-03 14:16:16.000000000 -0500 @@ -0,0 +1,380 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "resource.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_REGEDIT ICON DISCARDABLE "res/regedit.ico" +IDI_SMALL ICON DISCARDABLE "res/small.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_OPEN_FILE BITMAP DISCARDABLE "res/folder3.bmp" +IDB_CLOSED_FILE BITMAP DISCARDABLE "res/folder1.bmp" +IDB_ROOT BITMAP DISCARDABLE "res/folder2.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDC_REGEDIT MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", ID_REGISTRY_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About ...", ID_HELP_ABOUT + END +END + +IDR_REGEDIT_MENU MENU DISCARDABLE +BEGIN + POPUP "&Registry" + BEGIN + MENUITEM "&Import Registry File...", ID_REGISTRY_IMPORTREGISTRYFILE + + MENUITEM "&Export Registry File...", ID_REGISTRY_EXPORTREGISTRYFILE + + MENUITEM SEPARATOR + MENUITEM "&Connect Network Registry...", + ID_REGISTRY_CONNECTNETWORKREGISTRY + , GRAYED + MENUITEM "&Disconnect Network Registry...", + ID_REGISTRY_DISCONNECTNETWORKREGISTRY + , GRAYED + MENUITEM SEPARATOR + MENUITEM "&Print\tCtrl+P", ID_REGISTRY_PRINT, GRAYED + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_REGISTRY_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Modify", ID_EDIT_MODIFY + MENUITEM SEPARATOR + POPUP "&New" + BEGIN + MENUITEM "&Key", ID_EDIT_NEW_KEY + MENUITEM SEPARATOR + MENUITEM "&String Value", ID_EDIT_NEW_STRINGVALUE + MENUITEM "&Binary Value", ID_EDIT_NEW_BINARYVALUE + MENUITEM "&DWORD Value", ID_EDIT_NEW_DWORDVALUE + END + MENUITEM SEPARATOR + MENUITEM "&Delete\tDel", ID_EDIT_DELETE + MENUITEM "&Rename", ID_EDIT_RENAME + 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 + END + POPUP "&View" + BEGIN + MENUITEM "Status &Bar", ID_VIEW_STATUSBAR + MENUITEM SEPARATOR + MENUITEM "Sp&lit", ID_VIEW_SPLIT + MENUITEM SEPARATOR + MENUITEM "&Refresh\tF5", ID_VIEW_REFRESH + END + POPUP "&Favourites" + BEGIN + MENUITEM "&Add to Favourites", ID_FAVOURITES_ADDTOFAVOURITES + , GRAYED + MENUITEM "&Remove Favourite", ID_FAVOURITES_REMOVEFAVOURITE + , GRAYED + END + POPUP "&Help" + BEGIN + MENUITEM "&Help Topics", ID_HELP_HELPTOPICS + MENUITEM SEPARATOR + MENUITEM "&About Registry Editor", ID_HELP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75 +STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "System" +BEGIN + ICON IDI_REGEDIT,IDI_REGEDIT,14,9,16,16 + LTEXT "ReactOS regedit Version 1.0",IDC_STATIC,49,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 2002 ReactOS Team",IDC_STATIC,49,20,119,8 + DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""resource.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +(1) VERSIONINFO + FILEVERSION 0,0,21,3 + PRODUCTVERSION 0,0,21,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Absolutely no warranties whatsoever - Use at your own risk\0" + VALUE "CompanyName", "ReactOS Development Team\0" + VALUE "FileDescription", "ReactOS Registry Editor by Robert Dickenson\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "regedit\0" + VALUE "LegalCopyright", "Copyright © 2002 Robert Dickenson\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "regedit.exe\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "ReactOS Operating System\0" + VALUE "ProductVersion", "0.0.21\0" + VALUE "SpecialBuild", "Non-versioned Development Beta Release\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0xc09, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_LIST_COLUMN_NAME "Name" + IDS_LIST_COLUMN_TYPE "Type" + IDS_LIST_COLUMN_DATA "Data" +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APP_TITLE "ReactOS Registry Editor" + IDC_REGEDIT "REGEDIT" + IDC_REGEDIT_FRAME "REGEDIT_FRAME" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_REGISTRY_MENU "Contains commands for working with the whole registry" + ID_EDIT_MENU "Contains commands for editing values or keys" + ID_VIEW_MENU "Contains commands for customising the registry window" + ID_FAVOURITES_MENU "Contains commands for accessing frequently used keys" + ID_HELP_MENU "Contains commands for displaying help and information about registry editor" + ID_EDIT_NEW_MENU "Contains commands for creating new keys or values" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_EDIT_MODIFY "Modifies the value's data" + ID_EDIT_NEW_KEY "Adds a new key" + ID_EDIT_NEW_STRINGVALUE "Adds a new string value" + ID_EDIT_NEW_BINARYVALUE "Adds a new binary value" + ID_EDIT_NEW_DWORDVALUE "Adds a new double word value" + ID_REGISTRY_IMPORTREGISTRYFILE "Imports a text file into the registry" + ID_REGISTRY_EXPORTREGISTRYFILE + "Exports all or part of the registry to a text file" + ID_REGISTRY_CONNECTNETWORKREGISTRY + "Connects to a remote computer's registry" + ID_REGISTRY_DISCONNECTNETWORKREGISTRY + "Disconnects from a remote computer's registry" + ID_REGISTRY_PRINT "Prints all or part of the registry" + ID_HELP_HELPTOPICS "Opens registry editor help" + ID_HELP_ABOUT "Displays program information, version number and copyright" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_REGISTRY_EXIT "Quits the registry editor" + ID_FAVOURITES_ADDTOFAVOURITES "Adds keys to the favourites list" + ID_FAVOURITES_REMOVEFAVOURITE "Removes keys from the favourites list" + ID_VIEW_STATUSBAR "Shows or hides the status bar" + ID_VIEW_SPLIT "Change position of split between two panes" + ID_VIEW_REFRESH "Refreshes the window" + ID_EDIT_DELETE "Deletes the selection" + ID_EDIT_RENAME "Renames the selection" + ID_EDIT_COPYKEYNAME "Copies the name of the selected key to the clipboard" + ID_EDIT_FIND "Finds a text string in a key, value or data" + ID_EDIT_FINDNEXT "Finds next occurrence of text specified in previous search" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (Australia) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DIALOG1 DIALOG DISCARDABLE 50, 50, 268, 98 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | + WS_BORDER +FONT 8, "MS Sans Serif" +BEGIN +END + +IDD_DIALOG2 DIALOG DISCARDABLE 0, 0, 187, 95 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,130,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,130,24,50,14 +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_DIALOG1, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 261 + TOPMARGIN, 7 + BOTTOMMARGIN, 91 + END + + IDD_DIALOG2, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 180 + TOPMARGIN, 7 + BOTTOMMARGIN, 88 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + ID_HELP_HELPTOPICS "Opens Registry Editor Help." + ID_HELP_ABOUT "Displays program information, version number, and copyright." +END + +#endif // English (Australia) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/resource.h 2003-06-04 00:42:41.000000000 -0500 @@ -0,0 +1,86 @@ +#define ID_REGISTRY_MENU 0 +#define ID_EDIT_MENU 1 +#define ID_VIEW_MENU 2 +#define ID_FAVOURITES_MENU 3 +#define ID_HELP_MENU 4 +#define ID_EDIT_NEW_MENU 5 +#define IDS_LIST_COLUMN_FIRST 91 +#define IDS_LIST_COLUMN_NAME 91 +#define IDS_LIST_COLUMN_TYPE 92 +#define IDS_LIST_COLUMN_DATA 93 +#define IDS_LIST_COLUMN_LAST 93 +#define IDD_ABOUTBOX 103 +#define IDS_APP_TITLE 103 +#define IDI_REGEDIT 107 +#define IDI_SMALL 108 +#define IDC_REGEDIT 109 +#define IDC_REGEDIT_FRAME 110 +#define IDR_REGEDIT_MENU 130 +#define IDD_DIALOG1 131 +#define IDB_OPEN_FILE 132 +#define IDD_DIALOG2 132 +#define IDB_CLOSED_FILE 133 +#define IDB_ROOT 134 +#define IDC_LICENSE_EDIT 1029 +#define ID_REGISTRY_EXIT 32770 +#define ID_FAVOURITES_ADDTOFAVOURITES 32772 +#define ID_FAVOURITES_REMOVEFAVOURITE 32773 +#define ID_VIEW_STATUSBAR 32774 +#define ID_VIEW_SPLIT 32775 +#define ID_VIEW_REFRESH 32776 +#define ID_EDIT_DELETE 32778 +#define ID_EDIT_RENAME 32779 +#define ID_EDIT_COPYKEYNAME 32781 +#define ID_EDIT_FIND 32782 +#define ID_EDIT_FINDNEXT 32783 +#define ID_EDIT_MODIFY 32784 +#define ID_EDIT_NEW_KEY 32785 +#define ID_EDIT_NEW_STRINGVALUE 32786 +#define ID_EDIT_NEW_BINARYVALUE 32787 +#define ID_EDIT_NEW_DWORDVALUE 32788 +#define ID_REGISTRY_IMPORTREGISTRYFILE 32789 +#define ID_REGISTRY_EXPORTREGISTRYFILE 32790 +#define ID_REGISTRY_CONNECTNETWORKREGISTRY 32791 +#define ID_REGISTRY_DISCONNECTNETWORKREGISTRY 32792 +#define ID_REGISTRY_PRINT 32793 +#define ID_HELP_HELPTOPICS 32794 +#define ID_HELP_ABOUT 32795 +#define ID_WINDOW_CASCADE 32797 +#define ID_WINDOW_TILE 32798 +#define ID_WINDOW_ARRANGEICONS 32799 +#define ID_OPTIONS_FONT 32800 +#define ID_OPTIONS_AUTOREFRESH 32801 +#define ID_OPTIONS_READONLYMODE 32802 +#define ID_OPTIONS_CONFIRMONDELETE 32803 +#define ID_OPTIONS_SAVESETTINGSONEXIT 32804 +#define ID_SECURITY_PERMISSIONS 32805 +#define ID_VIEW_TREEANDDATA 32806 +#define ID_VIEW_TREEONLY 32807 +#define ID_VIEW_DATAONLY 32808 +#define ID_VIEW_DISPLAYBINARYDATA 32810 +#define ID_VIEW_REFRESHALL 32811 +#define ID_VIEW_REFRESHACTIVE 32812 +#define ID_VIEW_FINDKEY 32813 +#define ID_TREE_EXPANDONELEVEL 32814 +#define ID_TREE_EXPANDBRANCH 32815 +#define ID_TREE_EXPANDALL 32816 +#define ID_TREE_COLLAPSEBRANCH 32817 +#define ID_EDIT_ADDKEY 32818 +#define ID_EDIT_ADDVALUE 32819 +#define ID_EDIT_BINARY 32821 +#define ID_EDIT_STRING 32822 +#define ID_EDIT_DWORD 32823 +#define ID_EDIT_MULTISTRING 32824 +#define ID_REGISTRY_OPENLOCAL 32825 +#define ID_REGISTRY_CLOSE 32826 +#define ID_REGISTRY_LOADHIVE 32827 +#define ID_REGISTRY_UNLOADHIVE 32828 +#define ID_REGISTRY_RESTORE 32829 +#define ID_REGISTRY_SAVEKEY 32830 +#define ID_REGISTRY_SELECTCOMPUTER 32831 +#define ID_REGISTRY_PRINTSUBTREE 32832 +#define ID_REGISTRY_PRINTERSETUP 32833 +#define ID_REGISTRY_SAVESUBTREEAS 32834 +#define IDS_LICENSE 32835 +#define IDC_STATIC -1 + --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/resource.rc 2003-03-26 04:09:14.000000000 -0600 @@ -0,0 +1,74 @@ +IDB_OPEN_FILE BITMAP DISCARDABLE +#ifdef _WIN32 +"res/folder3.bmp" +#else +/* BINRES folder3.bmp */ +{ + '42 4D F6 00 00 00 00 00 00 00 76 00 00 00 28 00' + '00 00 10 00 00 00 10 00 00 00 01 00 04 00 00 00' + '00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00' + '00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80' + '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80' + '00 00 80 80 80 00 FF FF FF 00 00 00 FF 00 00 FF' + '00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF' + '00 00 FF FF FF 00 88 88 88 88 88 88 88 88 88 88' + '88 88 88 88 88 88 88 88 88 88 88 88 88 88 80 00' + '00 00 00 00 88 88 80 33 33 33 33 33 08 88 80 03' + '33 33 33 33 38 88 80 B3 33 33 33 33 30 88 80 B0' + '33 33 33 33 33 88 80 BB 33 33 33 33 33 08 80 BB' + '00 00 00 00 00 08 80 BB BB BB BB BB 08 88 80 BB' + 'BB BB BB BB 08 88 80 BB B0 00 00 00 08 88 80 00' + '00 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88' + '88 88 88 88 88 88' +} +#endif + +IDB_CLOSED_FILE BITMAP DISCARDABLE +#ifdef _WIN32 +"res/folder2.bmp" +#else +/* BINRES folder2.bmp */ +{ + '42 4D F6 00 00 00 00 00 00 00 76 00 00 00 28 00' + '00 00 10 00 00 00 10 00 00 00 01 00 04 00 00 00' + '00 00 80 00 00 00 12 0B 00 00 12 0B 00 00 10 00' + '00 00 10 00 00 00 00 00 00 00 00 00 80 00 00 80' + '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80' + '00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF' + '00 00 00 00 FF 00 FF 00 00 00 FF 00 FF 00 FF FF' + '00 00 FF FF FF 00 FF FF FF FF FF FF FF FF FF FF' + 'FF FF FF FF FF FF FF 00 00 00 00 00 00 00 F8 88' + '88 88 88 88 88 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7' + 'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7' + 'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7' + 'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 FF' + 'FF FF FF FF FF 80 F8 B7 B7 B7 B8 88 88 8F FF 8B' + '7B 7B 8F FF FF FF FF F8 88 88 FF FF FF FF FF FF' + 'FF FF FF FF FF FF' +} +#endif + +IDB_ROOT BITMAP DISCARDABLE +#ifdef _WIN32 +"res/folder1.bmp" +#else +/* BINRES folder1.bmp */ +{ + '42 4D F6 00 00 00 00 00 00 00 76 00 00 00 28 00' + '00 00 10 00 00 00 10 00 00 00 01 00 04 00 00 00' + '00 00 80 00 00 00 00 00 00 00 00 00 00 00 10 00' + '00 00 10 00 00 00 00 00 00 00 00 00 80 00 00 80' + '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80' + '00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF' + '00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF' + '00 00 FF FF FF 00 FF FF FF FF FF FF FF FF FF FF' + 'FF FF FF FF FF FF FF 00 00 00 00 00 00 00 F8 88' + '88 88 88 88 88 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7' + 'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7' + 'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 F7' + 'B7 B7 B7 B7 B7 80 F8 FB 7B 7B 7B 7B 7B 80 F8 FF' + 'FF FF FF FF FF 80 F8 B7 B7 B7 B8 88 88 8F FF 8B' + '7B 7B 8F FF FF FF FF F8 88 88 FF FF FF FF FF FF' + 'FF FF FF FF FF FF' +} +#endif --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/rsrc.rc 2003-03-27 00:57:52.000000000 -0600 @@ -0,0 +1,34 @@ +/* + * Copyright 2002 Robert Dickenson - ReactOS Project + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "windows.h" +#include "resource.h" + +/* define language neutral resources */ + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#include "resource.rc" + +/* include localised resources */ + +#include "En.rc" + +/* include version resources */ + +#include "version.rc" --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/treeview.c 2003-06-03 14:20:30.000000000 -0500 @@ -0,0 +1,256 @@ +/* + * ReactOS regedit + * + * treeview.c + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ +#include <windows.h> +#include <commctrl.h> +#include <stdlib.h> +#include <tchar.h> +#include <process.h> +#include <stdio.h> + +#include "main.h" +#include "treeview.h" + + +/* Global variables and constants */ +/* Image_Open, Image_Closed, and Image_Root - integer variables for indexes of the images. */ +/* CX_BITMAP and CY_BITMAP - width and height of an icon. */ +/* NUM_BITMAPS - number of bitmaps to add to the image list. */ +int Image_Open; +int Image_Closed; +int Image_Root; + +#define CX_BITMAP 16 +#define CY_BITMAP 16 +#define NUM_BITMAPS 3 + + +HKEY FindRegRoot(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, int max) +{ + HKEY hKey = NULL; + TVITEM item; + item.mask = TVIF_PARAM; + item.hItem = TreeView_GetParent(hwndTV, hItem); + + if (TreeView_GetItem(hwndTV, &item)) { + if (item.lParam == 0) { + /* recurse */ + hKey = FindRegRoot(hwndTV, item.hItem, keyPath, pPathLen, max); + keyPath[*pPathLen] = _T('\\'); + ++(*pPathLen); + item.mask = TVIF_TEXT; + item.hItem = hItem; + item.pszText = &keyPath[*pPathLen]; + item.cchTextMax = max - *pPathLen; + if (TreeView_GetItem(hwndTV, &item)) { + *pPathLen += _tcslen(item.pszText); + } + } else { + /* found root key with valid key value */ + hKey = (HKEY)item.lParam; + item.mask = TVIF_TEXT; + item.hItem = hItem; +/* item.pszText = &keyPath[*pPathLen]; */ + item.pszText = keyPath; + item.cchTextMax = max; + if (TreeView_GetItem(hwndTV, &item)) { + *pPathLen += _tcslen(item.pszText); + } + } + } + return hKey; +} + +static HTREEITEM AddEntryToTree(HWND hwndTV, HTREEITEM hParent, LPTSTR label, HKEY hKey, DWORD dwChildren) +{ + HTREEITEM hItem = 0; + TVITEM tvi; + TVINSERTSTRUCT tvins; + + tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM; + tvi.pszText = label; + tvi.cchTextMax = lstrlen(tvi.pszText); + tvi.iImage = Image_Closed; + tvi.iSelectedImage = Image_Open; + tvi.cChildren = dwChildren; + tvi.lParam = (LPARAM)hKey; + tvins.item = tvi; + if (hKey) tvins.hInsertAfter = (HTREEITEM)TVI_LAST; + else tvins.hInsertAfter = (HTREEITEM)TVI_SORT; + tvins.hParent = hParent; + hItem = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins); + return hItem; +} + + +static BOOL InitTreeViewItems(HWND hwndTV, LPTSTR pHostName) +{ + TVITEM tvi; + TVINSERTSTRUCT tvins; + HTREEITEM hRoot; + + tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN | TVIF_PARAM; + /* Set the text of the item. */ + tvi.pszText = pHostName; + tvi.cchTextMax = lstrlen(tvi.pszText); + /* Assume the item is not a parent item, so give it an image. */ + tvi.iImage = Image_Root; + tvi.iSelectedImage = Image_Root; + tvi.cChildren = 5; + /* Save the heading level in the item's application-defined data area. */ + tvi.lParam = (LPARAM)NULL; + tvins.item = tvi; + tvins.hInsertAfter = (HTREEITEM)TVI_FIRST; + tvins.hParent = TVI_ROOT; + /* Add the item to the tree view control. */ + hRoot = (HTREEITEM)SendMessage(hwndTV, TVM_INSERTITEM, 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins); + + AddEntryToTree(hwndTV, hRoot, _T("HKEY_CLASSES_ROOT"), HKEY_CLASSES_ROOT, 1); + AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_USER"), HKEY_CURRENT_USER, 1); + AddEntryToTree(hwndTV, hRoot, _T("HKEY_LOCAL_MACHINE"), HKEY_LOCAL_MACHINE, 1); + AddEntryToTree(hwndTV, hRoot, _T("HKEY_USERS"), HKEY_USERS, 1); + AddEntryToTree(hwndTV, hRoot, _T("HKEY_CURRENT_CONFIG"), HKEY_CURRENT_CONFIG, 1); + + return TRUE; +} + +/* + * 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. + * hwndTV - handle to the tree view control. + */ + +static BOOL InitTreeViewImageLists(HWND hwndTV) +{ + HIMAGELIST himl; /* handle to image list */ + HBITMAP hbmp; /* handle to bitmap */ + + /* Create the image list. */ + if ((himl = ImageList_Create(CX_BITMAP, CY_BITMAP, + FALSE, NUM_BITMAPS, 0)) == NULL) + return FALSE; + + /* Add the open file, closed file, and document bitmaps. */ + hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_OPEN_FILE)); + Image_Open = ImageList_Add(himl, hbmp, (HBITMAP) NULL); + DeleteObject(hbmp); + + hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_CLOSED_FILE)); + Image_Closed = ImageList_Add(himl, hbmp, (HBITMAP) NULL); + DeleteObject(hbmp); + + hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_ROOT)); + Image_Root = ImageList_Add(himl, hbmp, (HBITMAP) NULL); + DeleteObject(hbmp); + + /* Fail if not all of the images were added. */ + if (ImageList_GetImageCount(himl) < 3) + return FALSE; + + /* Associate the image list with the tree view control. */ + TreeView_SetImageList(hwndTV, himl, TVSIL_NORMAL); + + return TRUE; +} + +BOOL OnTreeExpanding(HWND hwndTV, NMTREEVIEW* pnmtv) +{ + HKEY hKey; + TCHAR keyPath[1000]; + int keyPathLen = 0; + + static int expanding; + if (expanding) return FALSE; + if (pnmtv->itemNew.state & TVIS_EXPANDEDONCE ) { + return TRUE; + } + expanding = TRUE; + + /* check if this is either the root or a subkey item... */ + if ((HKEY)pnmtv->itemNew.lParam == NULL) { + keyPath[0] = _T('\0'); + hKey = FindRegRoot(hwndTV, pnmtv->itemNew.hItem, keyPath, &keyPathLen, sizeof(keyPath)/sizeof(TCHAR)); + } else { + hKey = (HKEY)pnmtv->itemNew.lParam; + keyPath[0] = _T('\0'); + } + + if (hKey != NULL) { + HKEY hNewKey; + LONG errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey); + if (errCode == ERROR_SUCCESS) { + TCHAR Name[MAX_NAME_LEN]; + DWORD cName = MAX_NAME_LEN; + FILETIME LastWriteTime; + DWORD dwIndex = 0L; + /*ShowWindow(hwndTV, SW_HIDE); */ + while (RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, NULL, NULL, NULL, &LastWriteTime) == ERROR_SUCCESS) { + DWORD dwCount = 0L; + errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_READ, &hKey); + if (errCode == ERROR_SUCCESS) { + TCHAR SubName[MAX_NAME_LEN]; + DWORD cSubName = MAX_NAME_LEN; +/* if (RegEnumKeyEx(hKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { */ + while (RegEnumKeyEx(hKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { + ++dwCount; + } + } + RegCloseKey(hKey); + AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwCount); + cName = MAX_NAME_LEN; + ++dwIndex; + } + /*ShowWindow(hwndTV, SW_SHOWNOACTIVATE); */ + RegCloseKey(hNewKey); + } + } else { + } + expanding = FALSE; + return TRUE; +} + +/* + * CreateTreeView - creates a tree view control. + * Returns the handle to the new control if successful, or NULL otherwise. + * hwndParent - handle to the control's parent window. + */ + +HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id) +{ + RECT rcClient; + HWND hwndTV; + + /* Get the dimensions of the parent window's client area, and create the tree view control. */ + GetClientRect(hwndParent, &rcClient); + hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, _T("Tree View"), + WS_VISIBLE | WS_CHILD | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT, + 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, pHostName)) { + DestroyWindow(hwndTV); + return NULL; + } + return hwndTV; +} --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/treeview.h 2003-06-03 14:20:48.000000000 -0500 @@ -0,0 +1,40 @@ +/* + * ReactOS regedit + * + * treeview.h + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __TREEVIEW_H__ +#define __TREEVIEW_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id); +BOOL OnTreeExpanding(HWND hWnd, NMTREEVIEW* pnmtv); +HKEY FindRegRoot(HWND hwndTV, HTREEITEM hItem, LPTSTR keyPath, int* pPathLen, int max); + + +#ifdef __cplusplus +}; +#endif + +#endif /* __TREEVIEW_H__ */ --- /dev/null 1969-12-31 18:00:00.000000000 -0600 +++ ./programs/regedit/version.rc 2003-06-03 14:16:24.000000000 -0500 @@ -0,0 +1,63 @@ +/* + * Copyright 2002 Robert Dickenson - ReactOS Project + * + * 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 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "windows.h" +#include "resource.h" + +#ifndef _WIN32 +#include "wine/wine_common_ver.rc" +#else + +(1) VERSIONINFO + FILEVERSION 0,0,21,3 + PRODUCTVERSION 0,0,21,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Absolutely no warranties whatsoever - Use at your own risk\0" + VALUE "CompanyName", "ReactOS Development Team\0" + VALUE "FileDescription", "ReactOS Registry Editor by Robert Dickenson\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "regedit\0" + VALUE "LegalCopyright", "Copyright © 2002 Robert Dickenson\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "regedit.exe\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "ReactOS Operating System\0" + VALUE "ProductVersion", "0.0.21\0" + VALUE "SpecialBuild", "Non-versioned Development Beta Release\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0xc09, 1200 + END +END + +#endif -- "A just security to property is not afforded by that government, under which unequal taxes oppress one species of property and reward another species." --James Madison gmt