Results 1 to 18 of 18

Thread: Pointer Image

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Exclamation Pointer Image

    hello vbforums
    i want to build a program in which a image always is sticked (like a flag) to mouse cursor pointer with some displacement from the pointer and does not go beyond the borders of the screen.

    Thank you
    Boing

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Pointer Image

    Moved From The CodeBank (which is for posting code to share rather than asking questions )

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Re: Pointer Image

    thank you for moving my thread mr hack, i have mistakenly posted my thread in wrong section...it wont happen next time.

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Pointer Image

    You mean like the little sand clock tha appears near the Windows default pointer (bottom-right from the pointer) when its working in background? (Although thats just a different pointer animation, but I just wanted to be sure what you meant)

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Re: Pointer Image

    no i don't want to create any cursor(cur or ani), i just want to display a square image with cursor maintain some distance and with a condition:
    it hould not go beyond the borders of the screen, ie i t should bounce off the borders.

  6. #6
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Pointer Image

    I assumed you dont want to make a new cursor (and I mentioned it in parentheses), I just wanted to get the idea what you are trying to do.

    So basically you want an image to follow the mouse movement acorss the the screen 'sticking' to it?

    Regarding the bouncing/not leaving screen, if that happens it will cover the mose pointer.

  7. #7
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Pointer Image

    Boing

    Are you talking about something like a "tool-tip" -- ie, a little textbox
    that is typically at lower right of mouse arrow, but
    - when you get to right edge of screen, it goes to lower left of arrow, or
    - when you get to bottom of screen, it goes to upper left of arrow?


    If so, would this desired action only apply to your VB6 app's form, or
    for any other app (and/or desktop)?

    EDIT: oops -- you want square image, not a textbox. So, perhaps a PictureBox
    that moves in conjunction with the mouse arrow?

    Spoo

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Re: Pointer Image

    You got me right but i don't want it to cover the pointer and just wanna maintain some distance from the pointer.

  9. #9
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Pointer Image

    Boing

    OK, that's a start.

    But, I still need some clarification:

    What object will the mouse arrow movement be "restricted" to?
    -- 1. a VB6 form
    -- 2. a PictureBox on a VB6 form
    -- 3. something else entirely


    This is important to know so we'll know whether a MouseMove event
    is appropriate or whether a more generic GetCursorPos function will
    be appropriate.

    Spoo

  10. #10

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Re: Pointer Image

    ok here's the thing:

    1) we can use picturebox /image OR Instead of using picture box we can do it like this, we can use form itself.
    2) Now i want my picture box to move away whenever the mouse comes near to that picture box.
    3) In addition i dont want picturebox to move beyond the screen borders.
    its just a screen mate type game in which we have to catch fly (which is impossible...lol)
    Last edited by Boing; Apr 3rd, 2010 at 11:29 AM.

  11. #11
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Pointer Image

    Boing

    I think I get what you are describing, but just to be sure...

    PB1 is "that picture box" -- ie, the game playing surface
    PB2 is " my picture box" -- ie, the one that hugs the mouse pointer

    If my hypothetical is correct, then life should be pretty easy for you...
    you'll simply need to create a PB1_MouseMove sub.

    -- your code can determine the PB1 dimensions
    -- the X and Y coords are parameters returned by the sub
    -- then by comparing X,Y of the pointer vs PB1 perimeter, you can
    "flip" PB2 as required so that it is always visible.


    Can you take it from there?
    If you need actual code, holler.

    Spoo

  12. #12
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Pointer Image

    Something like this?
    Attached Files Attached Files

  13. #13

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Re: Pointer Image

    baja_yu@ your code works but it is always sticked with the cursor, i want to make it repel from specific dist. and image to only move when the mouse pointer comes near it by some dist.

    spoo@ sorry but didn't get PB1 and PB2...can u explain it

    lol im bit noob with VB

  14. #14
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Pointer Image

    Boing

    Sorry for my "shorthand"

    PB1 = name for PictureBox1
    PB2 = name for PictureBox2

    Spoo

  15. #15
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Pointer Image

    That's a very old joke by the way.

    Create a new form, put a button on it (called Command1) and put this code in:

    Code:
    Option Explicit
    
    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
       Command1.Left = Int(Rnd * (Me.Width - Command1.Width - 360))
       Command1.Top = Int(Rnd * (Me.Height - Command1.Height - 720))
    End Sub
    
    Private Sub Form_Load()
       Randomize
    End Sub

  16. #16

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Re: Pointer Image

    thats working!!!
    but how to give it a sliding effect because house flies don't teleport...lol

  17. #17
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Pointer Image

    Use a Timer. You should be able to figure it out.

  18. #18

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Re: Pointer Image

    hey i have tried it but it looks like that it has become unstoppable....
    going off limits

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