Hello,
Is there a way to draw a pixel or a graphic out side of my form
so maybe even though my form (200px by 200px in size) is placed on 400,400 on the screen...
But maybe I would like to draw a pixel on 10,10 on the screen, NOT the form...
so that the pixel will be OUT of the form..
If any answers are available, it would be very appriciated!
Thank You
Keehun Nam

Draw on the screen itself
Deuce Loosely
does it stay even after the program finishes
does it slow down my computer, or is it just not
a good way to draw pixels out of my form
If it isn't, is there a "better" way
Thank You for your replie though!
elargento
Yes there is, but I would discourage you to use it.
Use a p/invoke to GetDC with NULL as parameter. Like this
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace DrawScreen
{
public partial class Form1 : Form
{
[DllImport( "User32.dll" )]
public extern static IntPtr GetDC( IntPtr hWnd );
public Form1()
{
InitializeComponent();
}
private void Form1_Paint( object sender, PaintEventArgs e )
{
IntPtr hDC = GetDC( new IntPtr( 0 ) );
if( hDC != IntPtr.Zero )
{
using( Graphics g = Graphics.FromHdc( hDC ) )
{
g.DrawLine( Pens.Black, 0, 0, 500, 500 );
}
}
}
}
}
but really... I mean... this is not really good practise.
fariborz
It is C# code. Convert it to VB by pasting using this code, it contains a converter:
http://www.carlosag.net/Tools/CodeTranslator/Default.aspx
nitinbourai
May I ask you what you are trying to accomplish
p.s.: please try to start new threads instead of replying to old 'answered' threads.
QXUE
This is what I'm trying to do; I'd like to paint a rotatable Direct3D mesh on a transparent form and see the user's desktop behind it. Each time through the render loop, I'm calling the Device.Clear method, which repaints the background to a solid color. The linked article above demonstrates how to make a control on a form transparent, but not how to make the form itself transparent and render objects on top of it. Is there a relatively easy way to do this
Matt
shadow_woman
Well, I have one more question to make....
Will the bmp be "click-proof" because if I was to
put the bmp on the screen on the icon of the start button,
will the user be able to click through the bmp that I placed on the start
button
Thank You!
Keehun Nam
vikrant
Ok, here are some reasons why not to paint on the screen itself:
The Windows operating system manages the windows and their visibility. It also manages invalidation of rectangles, so that only those portions get updated that need to be updated. The OS hands canvases to the applications that need them. You can paint on them and the OS will take care of managing them. When painting on the screen canvas, you are sabotaging the system. For instance, top-level windows will suddenly be painted over. Another example is that the taskbar with the start button could be painted over. Now that's not really good practise, is it
I'm also not quite sure whether you can get it to work glitch-free.
Here are my suggestions (in addition to eligazit's):
1. If you need a real fullscreen surface to paint on, use DirectX.
2. If you need to paint over other windows, make your own form transparent. An article on how to do this can be found here.
3. If you just need a very large, almost fullscreen canvas, just maximize your form without borders...
Don't forget to mark correct replies as answers!
bill_csharper
I am close to editing and making it work though..
But it would be better if you like translate it...
I don't have a clue of what this code is from...
C C# C++ J
Thank You!
Keehun Nam
Anthony at Beckman
I have a form with multiple panels. I'd like to draw a line across different panels. How can I get the mousedown/mousemove/mouseover event hooked up
Thanks.
Alan
GapToN
I just have one question...
Lets predend that I have resolution of 1280X800
then my client has resolution of 800X600 or 2400X1800
then if I tell the program to pain on 0,1280
then it will be on MY left-bottom corner...
But for my clients, 800X600, will it be out of their screen
and also for the client 2400X1800 will the pixel be like
in 3/4th down the screen, or does the program make the
dot relative to my screen
Thank You anyway!
Keehun Nam
Brent McCulloch
Maybe you can use a new form that is region is set to a bitmap. that way you can create your outsize-of-form drawing at runtime by customizing the Bmp.
There are a lot of examples for this manner on the code project.