简体   繁体   English

在VS 2010 C#.NET Windows窗体中重现Microsoft注册表编辑器“编辑二进制值”窗口

[英]Reproduce the Microsoft Registry Editor “Edit Binary Value” Window in VS 2010 C# .NET Windows Forms

I am trying to reproduce a window from the Microsoft built-in Registry Editor. 我试图从Microsoft内置的注册表编辑器重现一个窗口。 The window is the one which is opened when you select "Modify Binary Data..." from the context-menu when a value is clicked. 窗口是在单击值时从上下文菜单中选择“修改二进制数据...”时打开的窗口。

The goal is to make an identical(!) window in my .NET C# application using Windows Forms. 目标是使用Windows Forms在我的.NET C#应用程序中创建一个相同的(!)窗口。

The problem is the textBox displayed in the window which contains the binary data. 问题是窗口中显示的textBox包含二进制数据。 I have tried using a RichTextBox, but it isn't as simple as it seems to be especially when it comes to editing data and the behaviour of this textBox. 我已经尝试过使用RichTextBox,但它并不像看起来那么简单,特别是在编辑数据和这个textBox的行为时。

So I have 2 questions: 所以我有两个问题:

  1. How to achieve an identical textBox in C# using Windows Forms? 如何使用Windows窗体在C#中实现相同的文本框? Maybe you know some other ways to reproduce this textBox? 也许你知道一些其他方法来重现这个文本框?
  2. I also need the font name used in this textBox, I couldn't find it :) 我还需要在这个textBox中使用的字体名称,我找不到它:)

Thanks! 谢谢!

I can think of two ways you can approach this. 我可以想到两种方法可以解决这个问题。 The first is a DataGrid, painstakingly styled to have transparent grid lines and exact margins between columns, with filters to enforce hex digits only. 第一个是DataGrid,经过精心设计,具有透明网格线和列之间的精确边距,过滤器仅强制执行十六进制数字。 All this, set alongside a richtextbox for the ASCII display, with your code synchronizing the selection between them. 所有这些,与ASCII显示的richtextbox一起设置,您的代码同步它们之间的选择。

Alternately, you can replace the DataGrid with a collection of TextBoxes, again styled for invisible borders, automatically adding new textboxes to the collection when the user adds more data. 或者,您可以将DataGrid替换为TextBoxes集合,再次为不可见边框设置样式,在用户添加更多数据时自动将新文本框添加到集合中。

All in all, it seems like an awful lot of work, especially in WinForms - WPF might make this a bit easier, especially the styling, but still a lot of work. 总而言之,它似乎是一项非常多的工作,特别是在WinForms中 - WPF可能会让这更容易,尤其是样式,但仍然需要做很多工作。

Regarding the name of that control - I tried using Spy++ to sniff it out, and it seems it's registered as a Window Class named "HEX", but I'm not sure that will really get you somewhere: 关于该控件的名称 - 我尝试使用Spy ++来嗅出它,并且它似乎被注册为名为“HEX”的Window类,但我不确定它是否会真正让你到达某个地方:

在此输入图像描述

Here is an open source project containing a hex editor control for Winforms, looking at least very similar: 这是一个包含Winforms的十六进制编辑器控件的开源项目,看起来至少非常相似:

http://sourceforge.net/projects/hexbox/ http://sourceforge.net/projects/hexbox/

I guess you can modify it accordingly to your requirements. 我想你可以根据你的要求修改它。 But beware, the source code for the control is ~6000 lines of code (including more than a dozen utility classes). 但要注意,控件的源代码是~6000行代码(包括十几个实用程序类)。 It inherits directly from "Control" and does all the text display using GDI+ (so no modified DataGrid or RichTextBox). 它直接从“Control”继承,并使用GDI +显示所有文本(因此没有修改过的DataGrid或RichTextBox)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM