Results 1 to 3 of 3

Thread: Creating new objects via code

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80

    Creating new objects via code

    How do you create objects (I want shapes) from code?(while running, that is. Not by putting it in a form)

    Also another question - Whats the equivalent of GetKeyState for mouse clicking? I need to get the X and Y coords of the pointer whenever I click. This would work with MouseDown event, but I'm using it in a loop.
    Last edited by Drakon; Jun 3rd, 2002 at 07:39 PM.
    Do you know if you will answer no to this question?
    If we've never seen something happen, we can't know if its impossible.
    If the soles of a shoe make faces at the floor when we don't look and isn't being watched via mirror or video tape, will we ever know?
    If someone orders you to disobey all of their orders, do you obey or disobey?

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    You could probably use a hook for proper mouse clicks, but you can just use these consts with the GetKeyState API:

    VB Code:
    1. VK_LBUTTON = &H1
    2.     VK_RBUTTON = &H2
    3.     VK_CANCEL = &H3
    4.     VK_MBUTTON = &H4             '  NOT contiguous with L RBUTTON

    And you can use this for the Cursor Pos:

    VB Code:
    1. Private Type POINTAPI
    2.     x As Long
    3.     y As Long
    4. End Type
    5. Private Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
    6.  
    7. 'Holds the cursor co-ordinates
    8. Dim CursorPosition As POINTAPI
    9.  
    10. 'Get the co-ords
    11. Call GetCursorPos(CursorPosition)
    12.  
    13. MsgBox CursorPosition.x & ":" & CursorPosition.y

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80
    Thanks, they both work. However, I have two problems.

    When I click at the right side of my screen on my form, which is 12000 twips wide, ... Hehe... it suddenly struck me as I write. I fixed that one...

    Now, problem 2. When I click a mouse button, the computer thinks I'm still clicking it until it clicks again. I have a block that moves to the pointer (not instantly, it "walks") when I click. But if I move the pointer around, it continues to follow the pointer. I want it to just walk where I clicked, then wait for me to click again. How do I fix that?
    Do you know if you will answer no to this question?
    If we've never seen something happen, we can't know if its impossible.
    If the soles of a shoe make faces at the floor when we don't look and isn't being watched via mirror or video tape, will we ever know?
    If someone orders you to disobey all of their orders, do you obey or disobey?

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