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)
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.
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)
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.
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.
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
Teaudirenopossum.Musasapientumfixaestinaure. (I can't hear you. There's a banana in my ear)
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.