Click here to Skip to main content
15,559,567 members
Home / Discussions / C#
   

C#

 
GeneralRe: Marshalling from C# string directly to an MFC CString Pin
Heath Stewart14-Jan-04 4:43
protectorHeath Stewart14-Jan-04 4:43 
GeneralAnimating True Type Fonts Pin
mrhicks13-Jan-04 13:01
mrhicks13-Jan-04 13:01 
GeneralRe: Animating True Type Fonts Pin
Heath Stewart13-Jan-04 14:00
protectorHeath Stewart13-Jan-04 14:00 
GeneralRe: Animating True Type Fonts Pin
leppie13-Jan-04 14:45
leppie13-Jan-04 14:45 
GeneralGDI+ missing functionality in PocketPC Pin
Gizz13-Jan-04 8:52
Gizz13-Jan-04 8:52 
GeneralRe: GDI+ missing functionality in PocketPC Pin
Heath Stewart13-Jan-04 9:21
protectorHeath Stewart13-Jan-04 9:21 
GeneralRe: GDI+ missing functionality in PocketPC Pin
leppie13-Jan-04 14:54
leppie13-Jan-04 14:54 
GeneralUnexpected (buggy?) behavior of RichTextBox when ZoomFactor is 2.0 Pin
Roman R.13-Jan-04 8:20
Roman R.13-Jan-04 8: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 9:40
protectorHeath Stewart13-Jan-04 9:40 
GeneralComboBox events Pin
elena1234513-Jan-04 7:15
elena1234513-Jan-04 7:15 
GeneralRe: ComboBox events Pin
Nick Parker13-Jan-04 7:50
protectorNick Parker13-Jan-04 7:50 
GeneralRe: ComboBox events Pin
elena1234513-Jan-04 9:09
elena1234513-Jan-04 9:09 
GeneralRe: ComboBox events Pin
Heath Stewart13-Jan-04 9:49
protectorHeath Stewart13-Jan-04 9:49 
GeneralRe: ComboBox events Pin
elena1234513-Jan-04 11:14
elena1234513-Jan-04 11:14 
Generalunzip zip file Pin
murali_utr13-Jan-04 7:00
murali_utr13-Jan-04 7:00 
GeneralRe: unzip zip file Pin
Judah Gabriel Himango13-Jan-04 7:14
sponsorJudah Gabriel Himango13-Jan-04 7:14 
GeneralRe: unzip zip file Pin
murali_utr13-Jan-04 10:20
murali_utr13-Jan-04 10:20 
QuestionLicensing solution per SQL Database? Pin
Alex Korchemniy13-Jan-04 5:56
Alex Korchemniy13-Jan-04 5:56 
AnswerRe: Licensing solution per SQL Database? Pin
Heath Stewart13-Jan-04 6:39
protectorHeath Stewart13-Jan-04 6:39 
GeneralRe: Licensing solution per SQL Database? Pin
Alex Korchemniy13-Jan-04 6:49
Alex Korchemniy13-Jan-04 6:49 
GeneralRe: Licensing solution per SQL Database? Pin
Heath Stewart13-Jan-04 6:52
protectorHeath Stewart13-Jan-04 6:52 
GeneralConvert HTML to PDF Stream into DB Pin
Regardt13-Jan-04 3:54
Regardt13-Jan-04 3:54 
GeneralRe: Convert HTML to PDF Stream into DB Pin
Alex Korchemniy13-Jan-04 5:48
Alex Korchemniy13-Jan-04 5:48 
GeneralRe: Convert HTML to PDF Stream into DB Pin
Heath Stewart13-Jan-04 6:32
protectorHeath Stewart13-Jan-04 6:32 
GeneralCustom permissions Pin
Hans Ruck13-Jan-04 2:43
Hans Ruck13-Jan-04 2: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.