I tried to use PictureBox1.Invalidate() but It's not working.
Even if I use Picturebox.CreateGraphics(
This method requests 32 bit integer. I had examples written in VB6, so I just automaticaly re-typed 'long' without realising they're not the same in C#.
I have changed it to int now, but there's no difference in application behaviour.
I didn't write this DLL. It's used for generating 2D barcodes and I downloaded it from here:
http://www.brothersoft.com
It has few more similar functions, like
- 'DMSaveAsBMP' but I'd like to avoid having to save the image to disk, just to reopen it in Picturebox.
- 'DMCopyToClipboard' but it copies it in 'MetafilePict' format which is not directly supported in .NET.
Main Topics
Browse All Topics





by: tcullerPosted on 2009-06-19 at 16:21:48ID: 24670940
You may have to invalidate the PictureBox after you update the underlying image, because the Control is not aware of its image being tampered with. The method Invalidate forces the control to re-draw itself. To keep the Control constantly up to date, you could subscribe to your picture box' Paint event, and just use the PaintEventArgs.Graphics property to re-draw the image in the method. This will have a performance impact if you do a lot of drawing, however.
There may be something else, but I guess we'll see. Just try calling pictureBox1.Invalidate() at the end of your button1_Click method, and uncomment the line in which you get the Graphics object from the image.
Also, does this method request a 64-bit integer HDC? A long in C++ is not the same as a long in C#; it varies depended on your system, but a long long is usually equivaent to C#'s long (System.Int64, in other words).
If you built the DLL, I would encourage you to enable the passing of 32-bit integers for the x-y coordinates, and a 32-bit HDC (unless you're developing for a 64-bit OS). The coordinates, however, shouldn't ever pass the 2.1~ billion mark, so I don't see a reason to move it up to a long.
Hope that helps, let me know if not,
Nate