Results 1 to 4 of 4

Thread: picture box and keypress

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Location
    Davis, CA
    Posts
    23
    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)?


  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263
    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:
    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
    This simply copies the source bitmap to the destination. Make sure the scalemodes of your two pictureboxes are in pixels.


  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Location
    Davis, CA
    Posts
    23

    Where Does Image Go

    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.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width