Click here to Skip to main content
15,889,909 members
Home / Discussions / C#
   

C#

 
GeneralRe: Printing from a webservice Pin
Heath Stewart17-Feb-04 3:26
protectorHeath Stewart17-Feb-04 3:26 
GeneralRe: Printing from a webservice Pin
nathanreynolds17-Feb-04 10:55
nathanreynolds17-Feb-04 10:55 
GeneralRe: Printing from a webservice Pin
Heath Stewart17-Feb-04 13:13
protectorHeath Stewart17-Feb-04 13:13 
GeneralRe: Printing from a webservice Pin
nathanreynolds17-Feb-04 16:27
nathanreynolds17-Feb-04 16:27 
GeneralRe: Printing from a webservice Pin
Heath Stewart17-Feb-04 19:32
protectorHeath Stewart17-Feb-04 19:32 
GeneralRe: Printing from a webservice Pin
nathanreynolds18-Feb-04 2:27
nathanreynolds18-Feb-04 2:27 
GeneralRe: Printing from a webservice Pin
Heath Stewart18-Feb-04 4:11
protectorHeath Stewart18-Feb-04 4:11 
GeneralA GDI+ newbie problem Pin
cemlouis16-Feb-04 11:28
cemlouis16-Feb-04 11:28 
Hi,

I have a problem in GDI+, I put a code snippet (draws a rectangle with a text inside) in the onpaint event handler of my simple form but when I resize the form, the handler redraws my rectangle? Is there a way to determine if there is a rectangle or some other thing on the form's drawing area to not to redraw the rectangle? How can I solve this problem? (my code is below...)

Thanks in advance...
Cem Louis

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace GDI_Test01
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

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

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

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Form1";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.form1_Paint);

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void form1_Paint(object sender, PaintEventArgs e)
{

// Obtain the Graphics object
Graphics g = this.CreateGraphics();

int rect_width = 110; int rect_height = 20;
Rectangle rect = new Rectangle((this.Width-rect_width)/2,20,rect_width,rect_height);
FontFamily verdanaFamily = new FontFamily("Verdana");
Font verdanaFont = new Font(verdanaFamily, 12, FontStyle.Bold);
StringFormat strFormat1 = new StringFormat();
strFormat1.Alignment = StringAlignment.Center;
strFormat1.LineAlignment = StringAlignment.Center;
strFormat1.Trimming = StringTrimming.Character;


// Draw text using DrawString
g.DrawRectangle(new Pen(Color.Black), rect);
g.DrawString("GDI+", verdanaFont, new SolidBrush(Color.Red), rect, strFormat1);

verdanaFont.Dispose();
g.Dispose();
}

}
}
GeneralRe: A GDI+ newbie problem Pin
Charlie Williams16-Feb-04 16:14
Charlie Williams16-Feb-04 16:14 
GeneralRe: A GDI+ newbie problem Pin
cemlouis17-Feb-04 3:50
cemlouis17-Feb-04 3:50 
GeneralFill 50% of a drawing with a color Pin
r916-Feb-04 9:32
r916-Feb-04 9:32 
GeneralRe: Fill 50% of a drawing with a color Pin
Heath Stewart16-Feb-04 9:45
protectorHeath Stewart16-Feb-04 9:45 
GeneralRe: Fill 50% of a drawing with a color Pin
r916-Feb-04 9:48
r916-Feb-04 9:48 
GeneralRe: Fill 50% of a drawing with a color Pin
Heath Stewart16-Feb-04 10:25
protectorHeath Stewart16-Feb-04 10:25 
GeneralRe: Fill 50% of a drawing with a color Pin
je_gonzalez16-Feb-04 12:54
je_gonzalez16-Feb-04 12:54 
QuestionHow to referenc functions in other code file Pin
klufy16-Feb-04 8:28
klufy16-Feb-04 8:28 
AnswerRe: How to referenc functions in other code file Pin
Colin Angus Mackay16-Feb-04 8:57
Colin Angus Mackay16-Feb-04 8:57 
GeneralRe: How to referenc functions in other code file Pin
klufy16-Feb-04 9:29
klufy16-Feb-04 9:29 
GeneralRe: How to referenc functions in other code file Pin
Colin Angus Mackay16-Feb-04 9:42
Colin Angus Mackay16-Feb-04 9:42 
GeneralRe: How to referenc functions in other code file Pin
Heath Stewart16-Feb-04 9:43
protectorHeath Stewart16-Feb-04 9:43 
GeneralRe: How to referenc functions in other code file Pin
klufy16-Feb-04 10:50
klufy16-Feb-04 10:50 
GeneralRe: How to referenc functions in other code file Pin
obelisk2916-Feb-04 11:23
obelisk2916-Feb-04 11:23 
GeneralRe: How to referenc functions in other code file Pin
klufy16-Feb-04 11:28
klufy16-Feb-04 11:28 
GeneralRe: How to referenc functions in other code file Pin
Heath Stewart17-Feb-04 2:58
protectorHeath Stewart17-Feb-04 2:58 
Generalcreating an app to track user input Pin
kym34516-Feb-04 8:06
kym34516-Feb-04 8:06 

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.