I've just started trying to learn how to implement Windows API calls in VB, as the graphics in VB themselves seem to respond rather slowly no matter what computer I run them on, but ran into a couple problems. The graphics at first wouldn't appear until I went over each line individually in debug mode. Now I have the problem that whenever a VB graphic (I've only implemented very few thus far with the GDI) moves over a GDI one, the GDI one partially disappears. I thought the GDI graphics would stay there until told to do otherwise? Or is there some special implementation that makes GDI graphics that are disappear-resistant?

By comparison the VB graphics (I used Shapes) stayed there after something else was on top of them after the thing that had been on top went away. With the GDI, if I put something on top of the GDI graphic, the GDI graphic disappears. This is a problem.

Here's where I draw the GDI graphics. Until I went over each line in debug mode they disappeared as soon as the next x in the for loop was reached (this no longer happens but I'm still not sure exactly why it did).

'draw the enemies using the Windows API
        Form1.FillStyle = 0
        Form1.FillColor = vbBlue
        For x = 1 To 10
            'MsgBox ("Loading from API")
            Call Rectangle(Form1.hdc, 32 * x - 8, 16, 32 * x + 17, 41)
         Next x

Here's my GDI declarations:

Public Declare Function Rectangle Lib "GDI32.dll" (ByVal hdc As Long, ByVal Lef As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long) As Long
Public Declare Function Ellipse Lib "GDI32.dll" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

And the entire project is attached in a .zip. At least running it will probably help understand the problem. Press spacebar or enter to fire your weapon; once the bullet hits the enemies you'll see the problem. It's in VB5.

And finally, here's a screenshot of the problem: [IMG]http://i152.photobucket.com/albums/s193/Quintillus/fps_prob.png[/IMG]

edit: Screenshot doesn't seem to display. I guess you'll have to follow the link.

10 Years
Discussion Span
Last Post by Quintillus

Anyone have any ideas/experience with API graphics? I know this isn't the simplest thing ever, but I didn't think it was quite as difficult as rocket science.

Thanks in advance.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.