Metallicraft
New member
- Joined
- Nov 3, 2003
- Messages
- 1
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a referenced, custom dll. I call a PrintImage routine in the dll and pass it only the the Picturebox.hdc from the main form. The dlls print routine draws to the hdc and it shows up in the picturebox perfectly.
I would like to do a similar thing with an asp.net page using my same vb6 custom printing dll. Where Display.aspx has and IMG tag with src="Image.aspx". Now, in the Image.aspx.vb code, I make the necessary calls to my dll to preload some data, then I call the PrintImage routine. What I get back is a black box. Since its an asp.net page I dont have a picturebox to draw to (even if I did, Im not sure the pictureboxs Handle would be the same as vb6s hdc). So Im trying to create a bitmap in .net where i can eventually get an hdc that I can send to my printing routine in the vb6 dll. Below is the code I use to do this:
Dim bm As Bitmap = New Bitmap(728, 312)
Dim gfx As Graphics = Graphics.FromImage(bm)
gfx.Clear(Color.White)
Dim hDC As IntPtr = gfx.GetHdc()
prt.hdc = hDC.ToInt32 prt.hdc is the property in my vb6 dll that receives the hdc to print to
The code runs without error, I save the bitmap to a file, read it into a bytearray, and do a Response.Binarywrite...I get a black box (well, now I get a white box since I added the gfx.Clear line above).
Why cant my vb6 printing dll draw to a .net hdc?
PS. I eventually dont want to have to save the bitmap to a file. If I can get the correct drawing on a device context, Id like to be able to stream that directly to a byte array and do a Response.Binarywrite.
If an expert can help with my main issue and my PS. I would greatly appreciate it.
I would like to do a similar thing with an asp.net page using my same vb6 custom printing dll. Where Display.aspx has and IMG tag with src="Image.aspx". Now, in the Image.aspx.vb code, I make the necessary calls to my dll to preload some data, then I call the PrintImage routine. What I get back is a black box. Since its an asp.net page I dont have a picturebox to draw to (even if I did, Im not sure the pictureboxs Handle would be the same as vb6s hdc). So Im trying to create a bitmap in .net where i can eventually get an hdc that I can send to my printing routine in the vb6 dll. Below is the code I use to do this:
Dim bm As Bitmap = New Bitmap(728, 312)
Dim gfx As Graphics = Graphics.FromImage(bm)
gfx.Clear(Color.White)
Dim hDC As IntPtr = gfx.GetHdc()
prt.hdc = hDC.ToInt32 prt.hdc is the property in my vb6 dll that receives the hdc to print to
The code runs without error, I save the bitmap to a file, read it into a bytearray, and do a Response.Binarywrite...I get a black box (well, now I get a white box since I added the gfx.Clear line above).
Why cant my vb6 printing dll draw to a .net hdc?
PS. I eventually dont want to have to save the bitmap to a file. If I can get the correct drawing on a device context, Id like to be able to stream that directly to a byte array and do a Response.Binarywrite.
If an expert can help with my main issue and my PS. I would greatly appreciate it.