BitBlt: Problem converting vb6 to vb.net
this is the API call:
Code:
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As IntPtr, _
ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hSrcDC As IntPtr, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Const SRCCOPY = &HCC0020
Public Const SRCPAINT = &HEE0086
Public Const SRCAND = &H8800C6
which i need to find an equivelent for vb.net.
Code:
RetVal = BitBlt(Form1.Picture1.hDC, XVal_To, YVal_To, Width, Height, Form1.Picture1.hDC, XVal_From, YVal_From, SRCAND)
as you may have guessed, the is Form1 , with Picture1 as a picture box in it.
the property "hDC" in picture1.hDC is removed !!!!!!!!!!
what can i do ???!
well, i tried to use:
Code:
Dim HDC1 as IntPtr
HDC1=Form1.DefInstance.Picture1.CreatGraphics.GethDC
'bla bla bla
is that way right ??
if it is, y it is not working ???
as i have noticed (although not sure of how accurate this notice is)
the thing draw for a second and is erased immediates (probably after re-painting)
well, that doesnot happen in vb6 !!!!!
anyone can help ????
Sorry, can't help any more
I think I've told you everything I know on the subject.
Maybe someone else can pick up from here?
things are starting to become clearer
thanks nemaroller, your code helped me a lot.
although it was not what i exactly wanted, but it
helped me for a start :)
what i did is similar to:
translating:
Code:
RetVal = BitBlt(PictureBox1.hDC, XVal_To, YVal_To, Width, Height, PictureBox2.hDC, XVal_From, YVal_From, SRCCOPY)
into:
Code:
Dim g as Graphics = PictureBox1.CreateGraphics
Dim srcRect = New Rectangle(XVal_From, YVal_From, Width, Height)
g.DrawImage(PictureBox2.Image, XVal_To, YVal_To, srcRect, GraphicsUnit.Pixel)
i used the overloaded DrawImage so, that it suits the function of BitBlt, as it copies a portion of an image using its orignial size.
(the code you made resizes the whole picture to fit into place)
well, "copies".
BitBlt has three flags, i have solved the first flag "SRCCOPY"
im left helpless translating the flags "SRCAND" , "SRCPAINT"
PLZZZZZZ, help :confused:
at least a hint to the function i should use for these two flags.
PS: i have this visual studio .net only two weeks ago, and im having bad time concerning new features :(