|
-
May 3rd, 2001, 07:38 PM
#1
Thread Starter
Lively Member
VB Direct Draw question/problem
Hi!
Have a few problems here maybe someone can figure out. I am learning Direct Draw. I have a basic application going that changes the mode to 800x600x16bit, that works fine, I can load bitmaps into surfaces fine, but what I need/want to do is load in a bitmap and cut it up on the fly.
Currently I have all my buttons in one bitmap file (each one is 30x20 seperated by 1px). I want to pull out the button at 0,0 and put it into a surface DDButton1, then the one at 31,0 and put it into DDButton2. I have tried Set DDButton1.GetSurfaceFromDC(thehdc) and get an error Automation Error -200532417 (887600ff).
How can I do this correctly?
I know I am getting a good hdc with the bitmap because if I bitblt it to the forms hdc it shows up.
My other problem is setting up hotspots on the screen so if the if the mouse goes over somthing it catches it.
Currently I have in the Form_MouseMove this code
If X > 100 and X < 200 and Y > 100 and Y < 200 then
'do the code here
ElseIf.......etc
My concern is there are so many mouse move events triggered that every time you go through this sub it will slow the program down. (I have a good amount of hotspots)
Is there a better way to do this?
Any help is appreciated
-
May 3rd, 2001, 08:05 PM
#2
If you set up your hotspots as an array of RECT structures, you can loop through that each time, and use the PtInRect API call to check each one.
Z.
-
May 3rd, 2001, 10:06 PM
#3
Good Ol' Platypus
Or you can search around for my function that tells you if the mouse is in an hWnd.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 3rd, 2001, 10:11 PM
#4
Good Ol' Platypus
Code:
Option Explicit
Public Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
Type PointAPI
X As Long
Y As Long
End Type
Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Function IsOver(hWnd As Long) As Boolean
Dim A As RECT
Dim G As PointAPI
GetWindowRect hWnd, A
GetCursorPos G
'MsgBox G.X & " " & G.Y & " " & A.Left & " " & A.Top & " " & A.Bottom & " " & A.Right
If G.X > A.Left - 1 And G.X < A.Right + 1 And G.Y > A.Top - 1 And G.Y < A.Bottom + 1 Then
IsOver = True
End If
End Function
The famous (or not so famous) IsOver function!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 3rd, 2001, 10:11 PM
#5
Good Ol' Platypus
PS> Use imageboxes for the hWnds, they start out w/no background

Just a tip!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|