Drawing in a Pocket PC Picture Box

Hi! I have a Picture Box in a Pocket PC application and I don't know how to draw images in it since there isn't any Picture Box Paint event. How should I do it Thanks!

Answer this question

Drawing in a Pocket PC Picture Box

  • MMV2007

    Thanks Manav but that's not the problem. The problem is that while in a windows application I can do something like this:

    private pictureBox_Paint (object sender, PaintEventArgs e)

    {

    e.Graphics.DrawImage(...);

    }

    I can't do the same thing in a Pocket PC application because the picture box doesn't have a Paint event. I should also say that my application involves image transformations and that's why I prefere DrawImage to pictureBox1.Image=bitMap. Thanks!


  • Wil Burton

    I can't. I need the Picture Box. I've created a custom picture box which has a paint event and that can be associated to CreateGraphics. The problem now is that I have a terrible flickering whenever I try to draw a line or a rectangle over the image (because of the Refresh in the Mouse Move event).
  • AWOLMAN

    PictureBox is used to display a picture - you can either associate one at the design time or set one at runtime using PictureBox.Image property. e.g. below

    byte[] buffer = {}; // read bytes

    System.IO.MemoryStream stream = new System.IO.MemoryStream(buffer);

    Bitmap bitMap = new Bitmap(stream);

    pictureBox1.Image = bitMap;

    Manav



  • albidochon

    PictureBox has Paint event in NETCF V2; you just can't see it in designers due to a bug. Hook it up manually and it would work.

    Alternatively get rid of picture box and do DrawImage on a form instead.



  • RizwanSharp

    You should also check this MSDN article http://msdn.microsoft.com/library/en-us/mobilesdk5/html/mob5samInk2.asp

    Manav



  • Robert3234

    Thanks Ilya. It really appears that the Paint event can be added manually although I'm getting the following warning: Members not supported by the device platform should not be called: System.Windows.Forms.PictureBox.add_Paint is not a supported method in this platform. And I'm using the NETCF 2.0. Anyway, I have other problem. How to associate a Graphics object to the Picture Box

    In a windows application I could make:

    Graphics g = pictureBox1.CreateGraphics; // this isn't possible in NETCF

    PaintEventArgs e = new PaintEventArgs (g, new Rectagle(..));

    pictureBox1_Paint = (sender, e); //here I just call the Paint event

    Do you have any idea Thanks!


  • MartinHowe

    This warning is produced due to the very same bug and could be ignored.

    There's no CreateGraphics on PB in NETCF so you can not. As I suggested before, consider getting rid of PB and draw on the form directly.



  • Chris Honcoop

    Moving to Smart Device General forum where it has got better chance of being answered.

    -Thanks,

    Mohit


  • Drawing in a Pocket PC Picture Box