Click here to Skip to main content
15,881,173 members
Home / Discussions / C#
   

C#

 
GeneralRe: Marshalling from C# string directly to an MFC CString Pin
Heath Stewart14-Jan-04 3:43
protectorHeath Stewart14-Jan-04 3:43 
GeneralAnimating True Type Fonts Pin
mrhicks13-Jan-04 12:01
mrhicks13-Jan-04 12:01 
GeneralRe: Animating True Type Fonts Pin
Heath Stewart13-Jan-04 13:00
protectorHeath Stewart13-Jan-04 13:00 
GeneralRe: Animating True Type Fonts Pin
leppie13-Jan-04 13:45
leppie13-Jan-04 13:45 
GeneralGDI+ missing functionality in PocketPC Pin
Gizz13-Jan-04 7:52
Gizz13-Jan-04 7:52 
GeneralRe: GDI+ missing functionality in PocketPC Pin
Heath Stewart13-Jan-04 8:21
protectorHeath Stewart13-Jan-04 8:21 
GeneralRe: GDI+ missing functionality in PocketPC Pin
leppie13-Jan-04 13:54
leppie13-Jan-04 13:54 
GeneralUnexpected (buggy?) behavior of RichTextBox when ZoomFactor is 2.0 Pin
Roman R.13-Jan-04 7:20
Roman R.13-Jan-04 7:20 
Hi, all,

I've stumbled upon a behavior of the .NET RichTextBox that I think is a bug, and I wanted somebody to do a sanity check before I report this to MS.

Below is a code listing. It displays a form with a RichTextBox control in it. Ctrl++ and Ctrl+- increase/decrease zoom. Space and Backspace keys change content of the text box.

Currently, zoom step is 0.5. Notice that when zoom factor is 2.0 (you can make it that by pressing Ctrl++ twice), the text box doesn't retain the zoom factor when its content changes. When you uncomment MessageBox statement in DisplayText (uses Clear() method of the text box class) method, you can more glimpse of the weird behavior. It is actually different with the MessageBox there. Increase zoom to 2.0 by pressing Ctrl++ twice and then press Space or Backspace repeatedly and notice zoom factor change from 2.0 to 1.0 to 2.0 to 1.0, …

After that, change the zoom step to, say, 0.3 (zoom factor doesn't become 2.0 with this step), and notice that the box behaves as expected (the zoom factor remains as set).

Is this a bug or reflection of my wrong expectations?

Thanks

----------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace BugInZoomFactor
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class BugInZoomFactorForm : System.Windows.Forms.Form
{
private System.Windows.Forms.RichTextBox richTextBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

private float zoomFactor = 1.0f;
private float zoomStep = 0.5f;

public BugInZoomFactorForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

this.KeyPreview = true;
DisplayText("Initial text");
}


private void DisplayText(string text)
{
richTextBox1.Clear();
richTextBox1.ZoomFactor = zoomFactor;
//MessageBox.Show("control's zoom factor is " + richTextBox1.

ZoomFactor.ToString());
richTextBox1.AppendText(text);
}




/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)

((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.richTextBox1.Location = new System.Drawing.Point(16, 154);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ReadOnly = true;
this.richTextBox1.Size = new System.Drawing.Size(672, 382);
this.richTextBox1.TabIndex = 4;
this.richTextBox1.Text = "";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(704, 541);
this.Controls.Add(this.richTextBox1);
this.Name = "BugInZoomFactorForm";
// this.Text = "Form2";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.

OnKeyDown);
this.ResumeLayout(false);

}
#endregion


private void OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Oemplus && e.Control)
{
if(zoomFactor < 64.0)
{
zoomFactor += zoomStep;
richTextBox1.ZoomFactor = zoomFactor;
}
}
else if(e.KeyCode == Keys.OemMinus && e.Control)
{
if(zoomFactor > 1.0)
{
zoomFactor -= zoomStep;
richTextBox1.ZoomFactor = zoomFactor;
}
}
else if(e.KeyCode == Keys.Space)
{
DisplayText("Subsequent text");
}
else if(e.KeyCode == Keys.Back)
{
DisplayText("Initial text");
}
}


[STAThread]
static void Main()
{
BugInZoomFactorForm form = new BugInZoomFactorForm();
Application.Run(form);
}
}
}
GeneralRe: Unexpected (buggy?) behavior of RichTextBox when ZoomFactor is 2.0 Pin
Heath Stewart13-Jan-04 8:40
protectorHeath Stewart13-Jan-04 8:40 
GeneralComboBox events Pin
elena1234513-Jan-04 6:15
elena1234513-Jan-04 6:15 
GeneralRe: ComboBox events Pin
Nick Parker13-Jan-04 6:50
protectorNick Parker13-Jan-04 6:50 
GeneralRe: ComboBox events Pin
elena1234513-Jan-04 8:09
elena1234513-Jan-04 8:09 
GeneralRe: ComboBox events Pin
Heath Stewart13-Jan-04 8:49
protectorHeath Stewart13-Jan-04 8:49 
GeneralRe: ComboBox events Pin
elena1234513-Jan-04 10:14
elena1234513-Jan-04 10:14 
Generalunzip zip file Pin
murali_utr13-Jan-04 6:00
murali_utr13-Jan-04 6:00 
GeneralRe: unzip zip file Pin
Judah Gabriel Himango13-Jan-04 6:14
sponsorJudah Gabriel Himango13-Jan-04 6:14 
GeneralRe: unzip zip file Pin
murali_utr13-Jan-04 9:20
murali_utr13-Jan-04 9:20 
QuestionLicensing solution per SQL Database? Pin
Alex Korchemniy13-Jan-04 4:56
Alex Korchemniy13-Jan-04 4:56 
AnswerRe: Licensing solution per SQL Database? Pin
Heath Stewart13-Jan-04 5:39
protectorHeath Stewart13-Jan-04 5:39 
GeneralRe: Licensing solution per SQL Database? Pin
Alex Korchemniy13-Jan-04 5:49
Alex Korchemniy13-Jan-04 5:49 
GeneralRe: Licensing solution per SQL Database? Pin
Heath Stewart13-Jan-04 5:52
protectorHeath Stewart13-Jan-04 5:52 
GeneralConvert HTML to PDF Stream into DB Pin
Regardt13-Jan-04 2:54
Regardt13-Jan-04 2:54 
GeneralRe: Convert HTML to PDF Stream into DB Pin
Alex Korchemniy13-Jan-04 4:48
Alex Korchemniy13-Jan-04 4:48 
GeneralRe: Convert HTML to PDF Stream into DB Pin
Heath Stewart13-Jan-04 5:32
protectorHeath Stewart13-Jan-04 5:32 
GeneralCustom permissions Pin
Hans Ruck13-Jan-04 1:43
Hans Ruck13-Jan-04 1:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.