Components won't show up

israel

Newcomer
Joined
Aug 5, 2004
Messages
17
I’m starting to learn Managed Direct X and I’m having a little problem.
I’m using a pictureBox as the device and I have other components in my window as well. When I run my application none of the other components show up; instead, I have empty rectangles and I can see whatever is behind my form(i.e. the Visual Studio window)

Does anybody know why this happen? I’m overriding the OnPaint method like this:

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
device.Clear(ClearFlags.Target, System.Drawing.Color.CornflowerBlue, 1.0f, 0);

SetupCamera();

// some code to draw something

device.BeginScene();
device.VertexFormat = CustomVertex.PositionColored.Format;
device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, verts);
device.EndScene();

device.Present();

this.Invalidate();
}
 
israel said:
I’m using a pictureBox as the device and I have other components in my window as well.
You're using the picturebox as the device, or did you mean the target ;).
Hmm, this is weird. You can see what's behind the form??

I'm going to go mess around with drawing to pictureboxes (rather than the drawing to the form lol) and tell you what's up.

Showing us more of your code might help.

Here's a possible problem: did you set your Transparency Key of the form to <whatever color>?

Oh also, when you said:

// some code to draw something

Were you drawing there? becuase you're supposed to draw after begin scene. Or did you mean "the following code draws something".. along those lines...

-The Pentium Guy
 
Thanks

Thanx everybody, I just stopped overriding the OnPaint method and created a Render method and now everything works perfectly.
 
Back
Top