Thread: How to put a pixel on the Form ?

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    20

    How to put a pixel on the Form ?

    Hi all, is there a function in C# that is equivalent to the PutPixel function in VC++ 6.0 ? Please help !!

  2. #2
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    For as far as i know ( which is not much ) i dont think you have anything like that .... although a reasonable solution would be to have a PictureBox object and there you would be able to change every pixel , Ive seen examples where they edit a whole bitmap etc so drawing a single pixel on a picturebox wont be to difficult i think....

    Since its something im interested in finding out as well ill take a look do some searches ( which of course you can do yourself as well ) and who knows i might come back with a working solution .


    ::edit::

    After two times feeling lucky with google i found this
    http://blogs.msdn.com/johnkenn/archi.../04/67465.aspx

    It shows you didnt even tried to search for the answer yourself...
    Oh and in case you didnt know the link above describes exactly what you want to do ( you would know if you checked it out ), it just needs some modification and then you can easily write your own Putpixel and getPixel method.

    PS: sorry if im kinda rude but ive seen enough stupid questions all day long and im kinda tired of ppl who post a one liner and expect to get a working piece of code that does exactly what they asked for. Nex time show us you´ve tried and you´ve searched then come and ask if you dont understand any of the things you read.


    Greetings,

    Ganglylamb.
    Last edited by GanglyLamb; 04-16-2005 at 06:37 PM.

  3. #3
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    If you create a standard windows form, you use GDI+ to do the drawing in the Paint event handler of the form. The PaintEventArgs has a Graphics property you can use for drawing, have a look at that.

  4. #4
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    You can also create a Graphics object for the form by passing it the handle of the form:

    Code:
    Graphics g = Graphics.FromHwnd( formname.Handle )
    That way you don't have to mess with the Paint event and have to invalidate the form to make it call Paint again.

    On a side note this is something I learned today from my .NET game development book.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calling datas from another form?
    By Aga^^ in forum C# Programming
    Replies: 2
    Last Post: 02-06-2009, 02:17 AM
  2. c++builder6 change form names problem
    By Leite33 in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2008, 08:20 AM
  3. Form
    By Coding in forum C++ Programming
    Replies: 1
    Last Post: 01-25-2008, 04:13 PM
  4. Form problems
    By SuperNewbie in forum C# Programming
    Replies: 4
    Last Post: 07-21-2002, 11:31 PM
  5. long form of year to short form?
    By bc120 in forum C Programming
    Replies: 2
    Last Post: 12-31-2001, 05:34 PM