Drawing a simple pixel to the foreground

C

Carsten Schmitt

Hello,

I want to draw a simple pixel (i.e. a red pixel in the center of the
screen), which is always in the foreground - even when running a fullscreen
application like a DirectX game.

I need this as an easy entry for programming later a HUD, which shows
several informations, like date, time, company logo, etc.

Any help or just a simple code example would be appreciated.

Thank you.

Carsten
 
D

Daniel

If your dx scene is attached and rendered to the winform, you will need to
use a panel wih transparency, place that over the form and then draw using
the Graphics object in gdi of the panel.

However off the top of my head i cannot remeber if a transparent panel ends
up showing the forms background rather than the dxscene through it. i know i
had issues with a dx scene going through a winform control.

Placing controls and so forth that dont require transparency over the
dxscene is easy tho. Use them as usual. So if your buttons are simple shapes
you'll have no issues.

Why are you not making your interface in dx?

D
 
C

Carsten

Daniel, thank you. I have no experience programming dx. I'm only searching
for a simple way, placing a red pixel in the foreground of the screen. That
should be easy for me to understand for my further learning. That I want to
create (later, when I have the knowledge) a HUD should be uninteressting at
this point.

Carsten
 
D

Daniel

Ah i see.

Ok well for very basic graphics requirements, use GDI, its very simple.
Their are good tutorials on the web, its how all forms are drawn. You can do
things such as overriding the pain fucntion of controls to make them look
how you want and so on by accessing the Graphics object.

OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics; //access graphics object in a control
}

That shoul dget you started. When you draw onto the graphics object that is
what appears on the screen. There is a lot of scope to this so tutorials and
practice is best.

For directx search for chads tutorials Cunit i believe its called. Quite a
good starting tutorial for dx, but it does teach you how to make his
framework and then use that which i found a little restricting. But basic
rendering is covered.

Hope that doesn't all scare you too much.

D
 
B

Bob Powell [MVP]

Because you think it _should_ be simple doesn't mean it is.

To do this you will neeed to create a shaped form or a toplevel window using
the LayeredWindow API. This can be set to be always on top and click events
in the window, red dot, other icon etc, will be directed to your code.

You can change this window out for the read HUD or draw on the window
directly to change it's shape. This will work with the LayeredWindow API's
and a per-pixel alpha window but not so well on the simple shaped form using
a region.


--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top