for reflecting the changes after re-sizing the window, how to get handle to the window in C#
// this is the code for opening a file and display in hexadecimal format public void open() { string chosen_file = ""; ofd.Title = "Open a file"; ofd.FileName = ""; ofd.Filter = "Text Files(*.txt)|*.txt|Rich Text Box(*.rtb)|*.rtb|Word Document(*.doc)|*.doc|HTML Pages(*.htm)|*.html|Cascading Style Sheet(*.css)|*.css|JAVA(*.java)|*.java|video file(*.wmv)|*.wmv|All Files(*.*)|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { chosen_file = ofd.FileName; // richTextBox2.LoadFile(chosen_file, RichTextBoxStreamType.PlainText); var fileInfo = new FileInfo(ofd.FileName); fileInfo.Length.ToString(); // MessageBox.Show(new FileInfo(ofd.FileName).Length.ToString()); byte[] buffer = new byte[fileInfo.Length]; { int length = (int)fileInfo.Length; FileStream fileStream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read); fileStream.Read(buffer, 0, length); string bb = ""; int i = 0; //int numBytesToRead = buffer.Length; ; while (i < buffer.Length) { if ((i % 16) == 0) { bb = bb + "\n"; bb = bb + i.ToString("X8"); bb = bb + "\t"; } else if ((i % 4) == 0) { bb = bb + "\t"; } bb = bb + buffer[i].ToString("X2"); // modified on 30june2014 // if ((i % 4) == 0) // { // // } i = i + 1; } richTextBox2.Text = bb; }
// this is the code for resizing but it has some problems //1. how to fetch the data and how to convert the data private void PaintForm_Resize(object sender, System.EventArgs e) { //Width = 580; //Height = 487; //string []buffer =new byte[ richTextBox2.Text]; //byte[] buffer2 = Encoding.Default.GetBytes(richTextBox2.Text); //int scaleX = this.Width / 100; //int scaleY = this.Height / 100; //paintImage.SetBounds(5 * scaleX, 5 * scaleY, 70 * scaleX, 75 * scaleY); //controlPanel.SetBounds(80 * scaleX, 5 * scaleY, 15 * scaleX, 75 * scaleY); byte[] buffer = new byte[richTextBox2.Text.Length]; // int length = (int)richTextBox2.TextLength; // int length = (int)buffer.Length; //filestream filestream = new filestream(ofd.filename, filemode.open, fileaccess.read); //filestream.read(buffer, 0, length); //From byte array to string string bb =""; int i = 0; //int numBytesToRead = buffer.Length; while (i < buffer.Length) { if ((i % 8) == 0) { bb = bb + "\n"; bb = bb + i.ToString("X8"); bb = bb + "\t"; } else if ((i % 4) == 0) { bb = bb + "\t"; } bb = bb + buffer[i].ToString("X2"); // bb = bb + richTextBox2.Text[i].ToString("X2"); i = i + 1; } richTextBox2.Text = bb; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)