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.
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.
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?
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)
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.
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
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