|Not to be a jerk, but those suggestions are really bad. Not only do they add to the complexity of the problem, they are not sound programming practices.|
Anyone here who knows me, knows that I am a VB advocate (except when the job is clearly too complicated for VB...ie pointers etc)
So I like to educate VB programmers (i don't mean this in a bad way) how to be better software engineers and not just vb hacks.
So...to that end, here is the proper way to handle this issue:
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
Dim DeltaX As Integer
Dim DeltaY As Integer
Dim StartPos As POINTAPI
Private Sub Form_Load()
' these should be set when the screen saver is in setup mode
DeltaX = 120 ' adjust this for x sensitivity level
DeltaY = 120 ' adjust this for y sensitivity level
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim NewPos As POINTAPI
Dim CheckX As Integer
Dim CheckY As Integer
CheckX = Abs(NewPos.X - StartPos.X)
CheckY = Abs(NewPos.Y - StartPos.Y)
If CheckX > DeltaX Or CheckY > DeltaY Then
Here is the explanation of this code:
1) GetCursorPos is a Win32 API function that returns a point (x and y coord) of the current mouse position on the screen (regarless of which form has focus)
2) when the form loads (in screensaver mode) you capture the cursor position and load (or in this example's case set) the sensitivity by using to delta variables. (in case you don't know, delta is a mathematical term meaning "change in")
3) then on mousemove event, you capture the mouse's position again using the getcursorpos win32 api function (so that you are not using vb's screwy coord system) and compare it to your deltas. If they exceed the sensitivity, unload the screensaver.
now, there are several things that you should take care of in your screensaver app.
1) You should display a tiny version of it in the screensaver's preview pane.
2) you should allow the user to set some values (such as the sensitivity) by responding to the setup request from the screensaver preview screen
3) you should make certain that the program only loads one time EVER, meaning that it only allows for one instance of itself
4) you should allow it to work with the password protection system (win9x/me as well as the 2k/xp style)
I have a very nice screensaver system written in C++ that you are welcome to, VB can do all this too (there is a handle issue with #1 above, but it is pretty easy to overcome using Win32 API calls)
If you need anymore help, please contact me email@example.com
PS. Sorry if I made you mad hijinx...but i gotta educate the masses.
They mostly come at night...mostly