Results 1 to 13 of 13

Thread: PictureBox question...

  1. #1

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    I've created a UserControl which displays some nice graphics which can be set by the user trough a Picture property. To store the picture I used a picturebox.

    The problem is that I don't want the UserControl to get the focus, which is normally done using the CanGetFocus property, but I can't change that property to False, because of the PictureBox, it shows: "Can't have child controls capable of receiving focus on a control that cannot receive focus".

    I want the user to be able to set a picture property exactly like a normal picturebox has, but I don't want to use a picturebox to hold the picture. The bitmap has to be saved in the .frx file (and in the EXE when compiled), so having a Filename property and loading the bitmap at runtime is not an option. The bitmap will also be used for BitBlt operations, so using the UserControl's picture property isn't an option either.

    Thanks,
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    you could use a stdpicture instead of a picturebox
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    The picture can be loaded correctly, I can save it as a property too, but I'm having trouble with BitBlt.

    This works fine:

    Code:
    Private pTest As New StdPicture
    
    Private Sub Form_Load()
        Set pTest = LoadPicture("D:\Projects\Setup.bmp")
        Set Picture1.Picture = pTest
    End Sub
    But I can't get this to work (yes, AutoRedraw is True):

    Code:
    Private Declare Function BitBlt Lib "gdi32" (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 pTest As New StdPicture
    
    Private Sub Form_Load()
        Set pTest = LoadPicture("D:\Projects\Setup.bmp")
        Call BitBlt(Picture1.hDC, 0, 0, 100, 100, pTest.Handle, 0, 0, vbSrcCopy)
        Picture1.Refresh
    End Sub
    I guess pTest.Handle doesn't give me the correct handle to use with BitBlt, but what does?

    Thanks
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    nah you can't blit from a bitmap directly, you need to create a offscreen DC and selectobject the bitmap
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Megatron
    Guest
    You can use the functions CreateCompatibleDC and SelectObject to do this.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    hehe too lazy to post any code?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Hehe, well, anyways, I didn't try it yet, but it must be something like this, right?: http://orion.spaceports.com/~mccloud...orial/3.3.html

    Thanks!
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  8. #8

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Worked perfectly! Thanks for the help!


    If anyone's interested, I created a Class Module which has both a DC and a picture property, which was what I needed, you can use it like this:

    Code:
    Dim cTest As New clsDC
    
    cTest.CreateDC Me.hdc
    Set cTest.Picture = LoadPicture("D:\Projects\Setup.bmp")
    cTest.BltAll Me.hdc, 0, 0, vbSrcCopy
    Me.Refresh
    cTest.DestroyDC Me.hWnd
    Set cTest = Nothing
    Attached Files Attached Files
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    oh yeah we totally forgot to mention Fox's famous homepage
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Fox's Famous ....
    We need something with an F


    Anyways, I used the code from his site, so I've added it to the Credits in the Class Module...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  11. #11
    Megatron
    Guest
    Originally posted by kedaman
    hehe too lazy to post any code?
    lol, yeah

  12. #12
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Oh thanks

    So you like my private (personal) programming page?

  13. #13

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Mwah, more like:

    Fox's Famous Futuristic-looking Flash Files on a Fast Fileserver.......

    Wow, sometimes I even amaze myself
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

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