Click here to Skip to main content
15,913,610 members
Home / Discussions / C#
   

C#

 
GeneralRe: Drag and Drop Pin
eggie58-Sep-04 2:10
eggie58-Sep-04 2:10 
GeneralCustom Schedule Control Pin
Beringer7-Sep-04 15:57
Beringer7-Sep-04 15:57 
GeneralControl Pin
ImanMahmoud7-Sep-04 15:26
ImanMahmoud7-Sep-04 15:26 
GeneralRe: Control Pin
Charlie Williams7-Sep-04 15:53
Charlie Williams7-Sep-04 15:53 
GeneralRe: Control Pin
WillemM7-Sep-04 20:07
WillemM7-Sep-04 20:07 
GeneralFile association (open) Pin
Arun Bhalla7-Sep-04 14:29
Arun Bhalla7-Sep-04 14:29 
GeneralRe: File association (open) Pin
Sebastian Schneider8-Sep-04 2:07
Sebastian Schneider8-Sep-04 2:07 
GeneralCustom Control stacking (z-order) problem Pin
dotbomb7-Sep-04 11:59
dotbomb7-Sep-04 11:59 
Hello all,

I have a simple custom control I use to draw an ellipse. The code is shown below. The problem is that if one ellipse is drawn INSIDE the area of another, the larger of the two always gets displayed in the foreground despite the z-order of the smaller ellipse. In fact, I can call BringToFront() on the smaller ellipse all day and the larger ellipse still gets displayed in the foreground.

I really don't understand why this is. Could someone more versed in painting custom controls help me out?

Thank you,

-dotbomb

~~~~~~~~~~~~~~~~ BEGIN CUSTOM CONTROL CODE SNIPPET ~~~~~~~~~~~~~~~~~~~~

public class ellipseControl : System.Windows.Forms.UserControl
{
private System.ComponentModel.Container components = null;
public Color backgroundColor;

protected override CreateParams CreateParams
{
get
{
CreateParams cp=base.CreateParams;
cp.ExStyle|=0x00000020; //WS_EX_TRANSPARENT
return cp;
}
}

protected void InvalidateEx()
{
if(Parent==null)
return;

Rectangle rc=new Rectangle(this.Location,this.Size);
Parent.Invalidate(rc,true);
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
//do not allow the background to be painted
}

protected override void OnPaint(PaintEventArgs e)
{
Graphics graphics = e.Graphics;

int penWidth = 1;
Pen pen = new Pen(Color.Black, penWidth);

SolidBrush brush = new SolidBrush(backgroundColor);

graphics.DrawEllipse(pen, 0, 0, (Width - 2), (Height - 2));
graphics.FillEllipse(brush, 1, 1, (Width - 4), (Height - 4));

brush.Dispose();
pen.Dispose();

}

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

~~~~~~~~~~~~~~~~~~~~~ END CUSTOM CONTROL CODE SNIPPET ~~~~~~~~~~~~~~~~~~~~~~~~

GeneralRe: Custom Control stacking (z-order) problem Pin
leppie7-Sep-04 21:04
leppie7-Sep-04 21:04 
GeneralRe: Custom Control stacking (z-order) problem Pin
dotbomb11-Sep-04 16:43
dotbomb11-Sep-04 16:43 
GeneralRe: Custom Control stacking (z-order) problem Pin
dotbomb12-Sep-04 8:02
dotbomb12-Sep-04 8:02 
QuestionHow to use InternetQueryOption from WinInet in C# Pin
JavaWriter20047-Sep-04 10:09
JavaWriter20047-Sep-04 10:09 
AnswerRe: How to use InternetQueryOption from WinInet in C# Pin
David Salter7-Sep-04 11:16
David Salter7-Sep-04 11:16 
GeneralRe: How to use InternetQueryOption from WinInet in C# Pin
Anonymous7-Sep-04 11:48
Anonymous7-Sep-04 11:48 
General2d graphics with Direct3D 9 Pin
arik_a7-Sep-04 8:39
arik_a7-Sep-04 8:39 
GeneralRe: 2d graphics with Direct3D 9 Pin
Christian Graus7-Sep-04 12:13
protectorChristian Graus7-Sep-04 12:13 
GeneralRe: 2d graphics with Direct3D 9 Pin
arik_a7-Sep-04 13:09
arik_a7-Sep-04 13:09 
GeneralRe: 2d graphics with Direct3D 9 Pin
Christian Graus7-Sep-04 13:25
protectorChristian Graus7-Sep-04 13:25 
GeneralRe: 2d graphics with Direct3D 9 Pin
arik_a7-Sep-04 13:42
arik_a7-Sep-04 13:42 
GeneralRe: 2d graphics with Direct3D 9 Pin
Christian Graus7-Sep-04 14:29
protectorChristian Graus7-Sep-04 14:29 
GeneralRe: 2d graphics with Direct3D 9 Pin
Judah Gabriel Himango7-Sep-04 14:34
sponsorJudah Gabriel Himango7-Sep-04 14:34 
GeneralRe: 2d graphics with Direct3D 9 Pin
Christian Graus7-Sep-04 15:20
protectorChristian Graus7-Sep-04 15:20 
GeneralRe: 2d graphics with Direct3D 9 Pin
Judah Gabriel Himango7-Sep-04 15:27
sponsorJudah Gabriel Himango7-Sep-04 15:27 
GeneralRe: 2d graphics with Direct3D 9 Pin
Christian Graus7-Sep-04 15:42
protectorChristian Graus7-Sep-04 15:42 
Generale.g. 4th root of a number Pin
harrior7-Sep-04 6:04
harrior7-Sep-04 6:04 

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.