Does anyone know hoe to detect peypress events when you have a picture box, or do you know ho to keep the image box from flickering(without bitblt)?
Printable View
Does anyone know hoe to detect peypress events when you have a picture box, or do you know ho to keep the image box from flickering(without bitblt)?
To detect keypresses in a picturebox, use the picturebox's KeyPress event. However, I bet this doesn't work for you because the picturebox usually isn't in focus. In this case, set the form's KeyPreview to true, which will allow the form itself to retrieve keypresses before any other object. So, just have the form carry out keypresses for your picturebox.
What's wrong with using BitBlt? It's much faster and cleaner, I bet you're just afraid of how to use it.
Paste this into your general declarations of your form:
This simply copies the source bitmap to the destination. Make sure the scalemodes of your two pictureboxes are in pixels.Code:Private Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
'-----------
'Usage
BitBlt Picture1.Hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, Picture2.hdc, 0, 0, SRCCOPY
I put the code in a command button, and it all seems to work without errors, but I have no clue where the image went. both picture boxes are in pixel mode.
Maybe your destination box have the property autoredraw=true, if so you can either put it to false or use the refresh command after the bitblt