Results 1 to 5 of 5

Thread: VB Direct Draw question/problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    Garden Grove, CA
    Posts
    72

    Question 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
    Chris Wilson

  2. #2
    Zaei
    Guest
    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.

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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
  •  



Click Here to Expand Forum to Full Width