Hi again,
1)
In your opinion, have we also to
ReleaseHdc
or
DeleteDC
or
Dispose
the two hdc we used?
If Yes, how to do that?
Of course, you have to release all DC's you get. You can see I call
ReleaseDC in the sample.
It's not recommended to call DeleteDC on this kind of DC's, so don't.
You can't Dispose DC since it's unmanaged.
If you want to animate using BitBlt then you obviously shouldn't
create/release DC each time. Create one at the beginning and release it
after animation is done.
2)
If I put only your five rows of code
Dim hDC1 As IntPtr = GetDC(PictureBox1.Handle)
Dim hDC2 As IntPtr = GetDC(PictureBox2.Handle)
BitBlt(hDC2, 0, 0, PictureBox1.Width, PictureBox1.Height, hDC1, 0, 0,
SRCCOPY)
ReleaseDC(PictureBox1.Handle, hDC1)
ReleaseDC(PictureBox2.Handle, hDC2)
(not the whole Protected Overrides Sub OnLoad...)
It's OnClick actually 8=]
in the load event, they don't work,
While if I put them (in example) in Command1_Click event,
they work.
Do you know why?
It's probably because Load event occurs before Paint event, so every
painting you got is lost because Picturebox paints itself again with
it's background color.
3)
I knew that when declaring an API
we have to transform the Long value in Integer value,
you also transformed the Device parameter into a IntPtr parameter.
Where did you learn it (MSDN guide?) ?
Have you an API Viewer (I have Visual Studio 2005 and I didn't find
any API Viewer and I need it) ?
Funny, but I can't remember when and where I learned about IntPtr's 8=]
I just recall that at some point I said to myself: "Now, give up these
Int32's & move on to IntPtr, dude!".
I can show you benefits of IntPtr though:
1. It's platform-dependent, so when you move on to 64-bit, you'll
probably have less work to do, since IntPtr's will be 64-bit already.
2. All .NET framework methods that give you (take from you) a handle,
pointer or something like this, they take IntPtr's (Control.Handle,
Marshal.* etc), so you wouldn't have to use .ToInt32 and New IntPtr(...)
stuff.
AFAIK VS'es don't have built-in API viewer. You can try ApiViewer 2004
(
http://www.activevb.de/rubriken/apiviewer/index-apiviewereng.html),
however I prefer to make API declarations myself.
Roman