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
Printable View
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
Moved From The CodeBank (which is for posting code to share rather than asking questions :) )
thank you for moving my thread mr hack, i have mistakenly posted my thread in wrong section...it wont happen next time.
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)
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.
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.
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
You got me right but i don't want it to cover the pointer and just wanna maintain some distance from the pointer.
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
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)
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
Something like this?
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
Boing
Sorry for my "shorthand"
PB1 = name for PictureBox1
PB2 = name for PictureBox2
Spoo
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
thats working!!!
but how to give it a sliding effect because house flies don't teleport...lol
Use a Timer. You should be able to figure it out.
hey i have tried it but it looks like that it has become unstoppable....
going off limits