Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

BitBlt Not Working When Showing A Form (SOLVED)


Kimimaru
 Share

Recommended Posts

Hey, everyone! I'm just blitting out graphics in a picturebox, and it works fine whenever I change the ListIndex on my listbox in the form, but it doesn't work when the ListIndex is specified before the form is shown. Here's an example of what I'm doing:

```
Dim ItemNum As Long

frmEditor.lstListBox1.ListIndex = EditorIndex

    ItemNum = EditorIndex + 1

    Call BitBlt(frmEditor.picItems1.hDC, 0, 0, PIC_X, PIC_Y, frmMirage.picItems.hDC, (Item(ItemNum).Pic - Int(Item(ItemNum).Pic / 6) * 6) * PIC_X, Int(Item(ItemNum).Pic / 6) * PIC_Y, SRCCOPY)

    frmEditor.Show vbModal
```
That part is not working. However, whenever I change the ListIndex, it blits out the graphic perfectly fine. Here's an example of what I'm doing:

```
Private Sub lstListBox1_Click()
    Dim ItemNum As Long

    ItemNum = lstListBox1.ListIndex + 1

    Call BitBlt(picItems1.hDC, 0, 0, PIC_X, PIC_Y, frmMirage.picItems.hDC, (Item(ItemNum).Pic - Int(Item(ItemNum).Pic / 6) * 6) * PIC_X, Int(Item(ItemNum).Pic / 6) * PIC_Y, SRCCOPY)
End Sub
```
The strange thing is that this part works, while the other part doesn't draw out the graphics. Can someone please explain why this is happening?
Link to comment
Share on other sites

@Robin:

> You need to set BitBlt _after_ the form is loaded up.
>
> BitBlt is a horrible system to use anyway. It doubles your memory usage.
>
> Switch to BltToDC.

Okay, I see, but the **Form_Load** Sub doesn't seem to be executing. I'll give it another shot with **BltToDC**. Thanks!
Link to comment
Share on other sites

For some reason, it's still not working. I've looked at the item editor, and it shows the form as vbModal yet displays the item graphics using the **Form_Load** sub. Mine won't do this for some odd reason.

EDIT: I just set the **AutoRedraw** property for the Picturebox and the Form to **True**, so now it works! Thanks for the help, Robin!

EDIT #2: It still doesn't work. If I make the AutoRedraw property True, it draws out the graphics when I start up the form, but it won't change them when I want it to.

EDIT #3: Okay, I've finally got it! I set the **AutoRedraw** property for both the Picturebox and the Form to **True** so that it draws out the graphics when I load the form. Then, whenever I make a change in the graphics, I make it refresh the Picturebox so that it records the change. Thanks again!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...