Commit in reactos/subsys/system/regedit on MAIN
hexedit.c+207added 1.1
hexedit.h+16added 1.1
En.rc+141.6 -> 1.7
edit.c+781.8 -> 1.9
main.c+6-21.5 -> 1.6
makefile+3-21.2 -> 1.3
resource.h+11.5 -> 1.6
+325-4
2 added + 5 modified, total 7 files
some work on editing binary registry values (not working yet)

reactos/subsys/system/regedit
hexedit.c added at 1.1
diff -N hexedit.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ hexedit.c	20 Jun 2004 12:21:47 -0000	1.1
@@ -0,0 +1,207 @@
+/*
+ * Hex editor control
+ *
+ * Copyright (C) 2004 Thomas Weidenmueller <w3seek@reactos.com>
+ *
+ * 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 <tchar.h>
+
+#include "hexedit.h"
+
+typedef struct
+{
+  HWND hWndSelf;
+  HWND hWndParent;
+  HLOCAL hData;
+  DWORD style;
+  INT LineHeight;
+  INT CharWidth;
+  HFONT hFont;
+  INT LeftMargin;
+  INT TopMargin;
+  INT CaretX;
+  INT CaretY;
+} HEXEDIT_DATA, *PHEXEDIT_DATA;
+
+LRESULT WINAPI HexEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+ATOM
+STDCALL
+RegisterHexEditorClass(HINSTANCE hInstance)
+{
+  WNDCLASSEX WndClass;
+  
+  ZeroMemory(&WndClass, sizeof(WNDCLASSEX));
+  WndClass.cbSize = sizeof(WNDCLASSEX);
+  WndClass.style = CS_DBLCLKS | CS_PARENTDC;
+  WndClass.lpfnWndProc = (WNDPROC)HexEditWndProc;
+  WndClass.cbWndExtra = sizeof(PHEXEDIT_DATA);
+  WndClass.hInstance = hInstance;
+  WndClass.hCursor = LoadCursor(0, IDC_IBEAM);
+  WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+  WndClass.lpszClassName = HEX_EDIT_CLASS_NAME;
+  
+  return RegisterClassEx(&WndClass);
+}
+
+BOOL
+STDCALL
+UnregisterHexEditorClass(HINSTANCE hInstance)
+{
+  return UnregisterClass(HEX_EDIT_CLASS_NAME, hInstance);
+}
+
+/*** Helper functions *********************************************************/
+
+static VOID
+HEXEDIT_MoveCaret(PHEXEDIT_DATA hed, INT Col, INT Line)
+{
+  /* FIXME - include the scroll position */
+  SetCaretPos(hed->LeftMargin + (Col * hed->CharWidth), hed->TopMargin + (Line * hed->LineHeight));
+}
+
+/*** Message Proc *************************************************************/
+
+static LRESULT
+HEXEDIT_WM_NCCREATE(HWND hWnd, CREATESTRUCT *cs)
+{
+  PHEXEDIT_DATA hed;
+  
+  if(!(hed = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HEXEDIT_DATA))))
+  {
+    return FALSE;
+  }
+  
+  hed->hWndSelf = hWnd;
+  hed->hWndParent = cs->hwndParent;
+  hed->style = cs->style;
+  
+  SetWindowLong(hWnd, 0, (LONG)hed);
+  
+  return TRUE;
+}
+
+static LRESULT
+HEXEDIT_WM_NCDESTROY(PHEXEDIT_DATA hed)
+{
+  if(hed->hData)
+  {
+    while(LocalUnlock(hed->hData));
+    LocalFree(hed->hData);
+  }
+  
+  SetWindowLong(hed->hWndSelf, 0, 0);
+  HeapFree(GetProcessHeap(), 0, hed);
+  
+  return 0;
+}
+
+static LRESULT
+HEXEDIT_WM_CREATE(PHEXEDIT_DATA hed)
+{
+  hed->LeftMargin = 2;
+  hed->TopMargin = 2;
+  return 1;
+}
+
+static LRESULT
+HEXEDIT_WM_SETFOCUS(PHEXEDIT_DATA hed)
+{
+  CreateCaret(hed->hWndSelf, 0, 2, hed->LineHeight);
+  HEXEDIT_MoveCaret(hed, 0, 0);
+  ShowCaret(hed->hWndSelf);
+  return 0;
+}
+
+static LRESULT
+HEXEDIT_WM_KILLFOCUS(PHEXEDIT_DATA hed)
+{
+  DestroyCaret();
+  return 0;
+}
+
+static LRESULT
+HEXEDIT_WM_SETFONT(PHEXEDIT_DATA hed, HFONT hFont, BOOL bRedraw)
+{
+  HDC hDC;
+  TEXTMETRIC tm;
+  HFONT hOldFont = 0;
+  
+  hed->hFont = hFont;
+  hDC = GetDC(hed->hWndSelf);
+  if(hFont)
+  {
+    hOldFont = SelectObject(hDC, hFont);
+  }
+  GetTextMetrics(hDC, &tm);
+  hed->LineHeight = tm.tmHeight;
+  hed->CharWidth = tm.tmAveCharWidth;
+  if(hOldFont)
+  {
+    SelectObject(hDC, hOldFont);
+  }
+  ReleaseDC(hed->hWndSelf, hDC);
+  
+  if(bRedraw)
+  {
+    InvalidateRect(hed->hWndSelf, NULL, TRUE);
+  }
+  
+  return 0;
+}
+
+LRESULT
+WINAPI
+HexEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+  PHEXEDIT_DATA hed;
+  
+  hed = (PHEXEDIT_DATA)GetWindowLong(hWnd, 0);
+  switch(uMsg)
+  {
+    case WM_SETFOCUS:
+      return HEXEDIT_WM_SETFOCUS(hed);
+    
+    case WM_KILLFOCUS:
+      return HEXEDIT_WM_KILLFOCUS(hed);
+    
+    case WM_SETFONT:
+      return HEXEDIT_WM_SETFONT(hed, (HFONT)wParam, (BOOL)LOWORD(lParam));
+    
+    case WM_CREATE:
+      return HEXEDIT_WM_CREATE(hed);
+    
+    case WM_NCCREATE:
+      if(!hed)
+      {
+        return HEXEDIT_WM_NCCREATE(hWnd, (CREATESTRUCT*)lParam);
+      }
+      break;
+    
+    case WM_NCDESTROY:
+      if(hed)
+      {
+        return HEXEDIT_WM_NCDESTROY(hed);
+      }
+      break;
+  }
+  
+  return CallWindowProc(DefWindowProc, hWnd, uMsg, wParam, lParam);
+}

reactos/subsys/system/regedit
hexedit.h added at 1.1
diff -N hexedit.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ hexedit.h	20 Jun 2004 12:21:47 -0000	1.1
@@ -0,0 +1,16 @@
+#ifndef __HEXEDIT_H
+#define __HEXEDIT_H
+
+#define HEX_EDIT_CLASS_NAME _T("HexEdit32")
+
+ATOM STDCALL
+RegisterHexEditorClass(HINSTANCE hInstance);
+BOOL STDCALL
+UnregisterHexEditorClass(HINSTANCE hInstance);
+
+/* styles */
+#define HES_READONLY	(0x800)
+#define HES_LOWERCASE	(0x10)
+#define HES_UPPERCASE	(0x8)	
+
+#endif /* __HEXEDIT_H */

reactos/subsys/system/regedit
En.rc 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- En.rc	20 Jun 2004 01:07:26 -0000	1.6
+++ En.rc	20 Jun 2004 12:21:47 -0000	1.7
@@ -156,6 +156,20 @@
     PUSHBUTTON      "Cancel",IDCANCEL,196,154,50,14
 END
 
+IDD_EDIT_BIN_DATA DIALOG  32, 24, 252, 174
+STYLE DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_3DLOOK | DS_CONTEXTHELP | 
+    WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Edit Binary Value"
+FONT 8, "MS Shell Dlg"
+BEGIN
+    LTEXT           "Value &name:",IDC_STATIC,6,6,134,8
+    EDITTEXT        IDC_VALUE_NAME,6,17,240,12,ES_AUTOHSCROLL | ES_READONLY
+    LTEXT           "&Value data:",IDC_STATIC,6,35,161,8
+    CONTROL         "",IDC_VALUE_DATA,"HexEdit32",WS_VSCROLL | WS_BORDER | WS_TABSTOP,6,46,240,102
+    DEFPUSHBUTTON   "OK",IDOK,142,154,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,196,154,50,14
+END
+
 
 IDD_EDIT_DWORD DIALOG  32, 24, 252, 104
 STYLE DS_SETFONT | DS_MODALFRAME | DS_NOIDLEMSG | DS_3DLOOK | DS_CONTEXTHELP | 

reactos/subsys/system/regedit
edit.c 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- edit.c	20 Jun 2004 02:22:44 -0000	1.8
+++ edit.c	20 Jun 2004 12:21:47 -0000	1.9
@@ -260,6 +260,68 @@
     return CallWindowProc(oldwndproc, hwnd, uMsg, wParam, lParam);
 }
 
+INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    TCHAR* valueData;
+    HWND hwndValue;
+    int len;
+
+    switch(uMsg) {
+    case WM_INITDIALOG:
+        if(editValueName && _tcscmp(editValueName, _T("")))
+        {
+          SetDlgItemText(hwndDlg, IDC_VALUE_NAME, editValueName);
+        }
+        else
+        {
+          SetDlgItemText(hwndDlg, IDC_VALUE_NAME, _T("(Default)"));
+        }
+        SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
+        SetFocus(GetDlgItem(hwndDlg, IDC_VALUE_DATA));
+        return FALSE;
+    case WM_COMMAND:
+        switch (LOWORD(wParam))
+        {
+        case IDOK:
+            if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA)))
+            {
+                if ((len = GetWindowTextLength(hwndValue)))
+                {
+                    if (stringValueData)
+                    {
+                        if ((valueData = HeapReAlloc(GetProcessHeap(), 0, stringValueData, (len + 1) * sizeof(TCHAR))))
+                        {
+                            stringValueData = valueData;
+                            if (!GetWindowText(hwndValue, stringValueData, len + 1))
+                                *stringValueData = 0;
+                        }
+                    }
+                    else
+                    {
+                        if ((valueData = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(TCHAR))))
+                        {
+                            stringValueData = valueData;
+                            if (!GetWindowText(hwndValue, stringValueData, len + 1))
+                                *stringValueData = 0;
+                        }
+                    }
+                }
+                else
+                {
+                  if (stringValueData)
+                    *stringValueData = 0;
+                }
+            }
+            EndDialog(hwndDlg, IDOK);
+            break;
+        case IDCANCEL:
+            EndDialog(hwndDlg, IDCANCEL);
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+
 
 INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
@@ -569,6 +631,22 @@
                 result = TRUE;
         }
     }
+    else if (type == REG_NONE || type == REG_BINARY)
+    {
+        lRet = RegQueryValueEx(hKey, valueName, 0, 0, (LPBYTE)&dwordValueData, &valueDataLen);
+        if (lRet != ERROR_SUCCESS)
+        {
+            error(hwnd, IDS_BAD_VALUE, valueName);
+            goto done;
+        }
+
+        if (DialogBox(0, MAKEINTRESOURCE(IDD_EDIT_BIN_DATA), hwnd, modify_binary_dlgproc) == IDOK)
+        {
+            lRet = RegSetValueEx(hKey, valueName, 0, type, (LPBYTE)&dwordValueData, sizeof(DWORD));
+            if (lRet == ERROR_SUCCESS)
+                result = TRUE;
+        }
+    }
     else
     {
         error(hwnd, IDS_UNSUPPORTED_TYPE, type);

reactos/subsys/system/regedit
main.c 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- main.c	3 Jan 2004 15:59:46 -0000	1.5
+++ main.c	20 Jun 2004 12:21:47 -0000	1.6
@@ -28,6 +28,7 @@
 #include <fcntl.h>
 
 #include "main.h"
+#include "hexedit.h"
 
 
 BOOL ProcessCmdLine(LPSTR lpCmdLine);
@@ -102,6 +103,8 @@
                          };
     ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */
     hChildWndClass = hChildWndClass; /* warning eater */
+    
+    RegisterHexEditorClass(hInstance);
 
     hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
     hPopupMenus = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_MENUS));
@@ -138,8 +141,9 @@
 
 /******************************************************************************/
 
-void ExitInstance(void)
+void ExitInstance(HINSTANCE hInstance)
 {
+    UnregisterHexEditorClass(hInstance);
     DestroyMenu(hMenuFrame);
 }
 
@@ -191,6 +195,6 @@
             DispatchMessage(&msg);
         }
     }
-    ExitInstance();
+    ExitInstance(hInstance);
     return msg.wParam;
 }

reactos/subsys/system/regedit
makefile 1.2 -> 1.3
diff -u -r1.2 -r1.3
--- makefile	1 Jan 2004 15:12:11 -0000	1.2
+++ makefile	20 Jun 2004 12:21:47 -0000	1.3
@@ -12,7 +12,7 @@
 
 TARGET_NAME = regedit
 
-TARGET_CFLAGS = -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API 
+TARGET_CFLAGS = -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API
 	
 TARGET_GCCLIBS = msvcrt advapi32 kernel32 comctl32 comdlg32 shell32
 
@@ -20,9 +20,10 @@
 	about.o \
 	childwnd.o \
 	edit.o \
-	main.o \
 	framewnd.o \
+	hexedit.o \
 	listview.o \
+	main.o \
 	regedit.o \
 	regproc.o \
 	treeview.o

reactos/subsys/system/regedit
resource.h 1.5 -> 1.6
diff -u -r1.5 -r1.6
--- resource.h	20 Jun 2004 01:07:26 -0000	1.5
+++ resource.h	20 Jun 2004 12:21:47 -0000	1.6
@@ -121,5 +121,6 @@
 #define IDC_FORMAT_DEC			2005
 
 #define IDD_EDIT_MULTI_STRING		2006
+#define IDD_EDIT_BIN_DATA		2007
 
 #define IDC_STATIC                      -1
CVSspam 0.2.8