Ok thanks to venna I now have a timer working on my login form which when I go to another form the counter still ticks over.
Now I've been working on a way of detecting when the mouse has been moved so that I can set a value, say to 1 when it is moved and then the timer gets to 60x5 (5 mins) it sets a value to 1 and then if they're both one then log off / unload / close db etc.
Here's what I got: -
-
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
-
Private Type POINTAPI
-
X As Long
-
Y As Long
-
End Type
-
Dim DeltaX As Integer
-
Dim DeltaY As Integer
-
Dim StartPos As POINTAPI
-
Dim logintime As Variant
-
On form_load - ' these should be set when the screen saver is in setup mode
-
DeltaX = 100 ' adjust this for x sensitivity level
-
DeltaY = 100 ' adjust this for y sensitivity level
-
Call GetCursorPos(StartPos)
Then in each frame or tab - Private Sub SSTab1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Dim NewPos As POINTAPI
-
Call GetCursorPos(NewPos)
-
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
-
MouseMove = 1
-
End If
This is really annoying having to put it in each frame and form etc
Is there a way of just dragging a frame all over your form ... making it see-though and then putting that code in for just that frame?
11 2318
anyone out there ? i come in peace :)
anyone out there ? i come in peace :)
Is there another approach you could take? For instance, since you're doing an API call to check the cursor position, I guess it really isn't dependent on any particular control, or even your form. So what if you had a timer which checks it... oh, say ten times a second, and just sets a flag when it changes or something?
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
If this is what you want to do : If your Application is running but Idle for few mins, then you want to come out..
Then do this :
Keep a project-level variable (add a .Bas module ) and declare this Public MyCount As Integer
And in MouseMove event and KeyPress event of all the Forms give : MyCount = 0
In Main form's Timer1_Timer Event: MyCount = MyCount + 1
If MyCount >= 300 Then
End
End If
Sorry if I have not understood properly.
Regards
Veena
the problem with what i have atm is that i have to have that code in every frame.
I have a form with a sstab on it consisisting of 8 tabs ( 8th isnt used atm but will) in each tab ther is a number of frames generally 2-4
so would i have to put that code in each tab and each frame on each tab or can i just put it under the whole forms mouse event ?
------------------------------------------
I see what u meen veena
if that works then it would be much much simpler, ill give it a go now :D
thx both for your replies.
Instead of using a mouseMove event, it would be easier to check if the user is actually using the form. You will already have the code in place for what each control is supposed to do, just reset the timer inside each of those subroutines.
Better yet, write one function/subroutine that resets anything to do with the timer and re-use it that way. That's one aspect of programming: code reuse. :>
Instead of using a mouseMove event, it would be easier to check if the user is actually using the form. You will already have the code in place for what each control is supposed to do, just reset the timer inside each of those subroutines.
Better yet, write one function/subroutine that resets anything to do with the timer and re-use it that way. That's one aspect of programming: code reuse. :>
so in every text box, command button, etc i would have to do something like
call mousemoved
Private Sub mousemoved()
mousetimer = 0
or just "mousetimer = 0"
------------------------
I tried out
MouseMove event and KeyPress event of all the Forms give : mousetimer = 0
this didnt work for the sstabs so i put it in the sstabs mousemove event but if the mouse is over a frame or picture etc it doesnt work.
So ill have to put it in every frame, picture, etc? ( like i said above? )
ther must be a simpler way than this long winded putting code in every frame, picture and that cant it be done in a module or something ?
Perhaps there's some way you could intercept the mouse-move messages that Windows sends to your application? I know Windows works by sending a constant stream of message around, and you can send them with the SendMessage API function. Maybe you can detect them as well.
Otherwise, have you considered the timer/API solution I mentioned? Do you just need to know whether the user is doing anything? Or does it need to be specific to your application?
i dont care what the user is doing :D just that s/hes there, which is generally known when they move their mouse.
Well, there you go then. Just check the actual mousepointer position every however-often, and if it changes, the user is active. Don't know how you'll tell when they use the keyboard, though, unless they are definitely using your application. In that case, turn on KeyPreview property of each form, so it gets to see the keys first.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tim Mulholland |
last post by:
i posted this a while ago and never got a response, but i'm still having
problems, so i thought i'd see if anyone had any sudden realizations this
time
Thanks in advance!
Tim
I have written some code that causes mouseover effects on a picture box.
The code works fine most of the time and creates some really nice effects.
|
by: Sam Sungshik Kong |
last post by:
Hello!
If I understand correctly, MouseMove event is triggered when the mouse moves
(ie when point changes).
I, however, found out that it's triggered even if the mouse is not moving.
What I did was:
In an empty form, I set the Form1.Text to "0" and added the following code
for Form1.MouseMove event.
|
by: Crucifix |
last post by:
Hello,
I'm writing a small C# app, and part of what I'm trying to do
involves the dragging of PictureBox controls on a form. Unfortunately,
MouseMove seems to be behaving very oddly, causing spurious MouseMove
events when the cursor doesn't actually move. I've looked for a
solution in the groups, and although I've come close, I haven't found a
proper explanation or fix. Here is a rundown, followed by a very
simple test app that...
|
by: TyBreaker |
last post by:
I'm writing a screen saver using Visual Studio 2005 (Basic) and I have a
Form which contains a PictureBox. I have two events, Click and
MouseMove that I'd like to cause the program to end (see below) as one
would expect from a screen saver. Well my Click event fires but for
some reason my MouseMove event does not. Both the Form and the
PictureBox are enabled.
In my Form_Load routine, I tried placing "Me.Capture = true" which...
|
by: Rob |
last post by:
This is a curious problem. It seems like it should be quite easy. Of course
a timer is used to determine when form should be closed, but how do you
consistently reset the timer when the mouse is moved over the form.
Normally I would use the MouseMove event to know when the mouse moves over
the form and use that to reset the timer. However, this fails on a form that
has a large number of controls of the form. The Form.MouseMove event...
| |
by: Jakub Łukomski |
last post by:
hi. i've got a problem as follows, to which i can't find a solution to:
i've got two divs, which are completely independent of each other
(neither is a parent of child of another).
they're positioned (either absolutely or relatively) in a way that they
overlap each other. when i assign an onmousemove event to them, only one
of them catches it.
any capturing and/or bubbling is beeing performed by parents of the div
that caught the...
|
by: info |
last post by:
Hello everybody,
I hope you can help me with my problem. I want to add the mousemove
event to a class that doesn't have it (specifically it is the
nationalinstruments.ui.xycursor from measurement studio but I can't
find nothing about the possibility to do it.
Can anybody help me? I'm using VB.net 2003
Thank you very very much
Maurizio
|
by: since |
last post by:
How do I in IE prevent the onclick action from being fired when I am done dragging?
have tried "window.event.cancelBubble = true", for onmouseup , onmousedown, and onmousemove handlers. The onclick sort action always seems to get fired. Any help would be greatly appeciated.
The following demo is sortable and resizable. I basically don't want the onclick action to be fired if I am resizing a column.
Steve
<HTML>
<HEAD>
<style>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |