Discussion:
onMouseMove() event fired at the opening of a form
(too old to reply)
Jean-Pierre Martel
2004-02-26 04:40:50 UTC
Permalink
I am building a Screen Saver in dBL. I would like the form to close as
soon as the user moves the mouse pointer. Unfortunately, the
onMouseMove() event fires as soon as the form opens, without any role
played by the end user.

Jean-Pierre Martel
=== A new dBASE Conference in Montréal, July 9th and 10th, 2004 ===

// Beginning of the onMouseMove Form

** END HEADER -- do not remove this line
//
// Generated on 25/02/04
//
parameter bModal
local f
f = new OMMForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif

class OMMForm of FORM
with (this)
onMouseMove = {;form.close()}
metric = 6 // Pixels
height = 334.0
left = 371.0
top = 0.0
width = 280.0
windowState = 2 // maximized
text = ""
endwith

this.RECTANGLE1 = new RECTANGLE(this)
with (this.RECTANGLE1)
onMouseMove = {;form.close()}
left = 29.0
top = 33.0
width = 214.0
height = 251.0
text = "Rectangle1"
endwith

endclass

// End of the onMouseMove Form
Marc VdB
2004-02-26 11:26:09 UTC
Permalink
Post by Jean-Pierre Martel
I am building a Screen Saver in dBL.
He again <LOL>, Jean-Pierres next plan is to write a
realtime-tracking-system of all vehicles in Montreal with integrated
traffic-optimizer all in dBL
Post by Jean-Pierre Martel
I would like the form to close as
soon as the user moves the mouse pointer. Unfortunately, the
onMouseMove() event fires as soon as the form opens, without any role
played by the end user.
I let Ken decide if this is WAD, but in fact by enlarging the Windows , you
move it over the cursor...
And since Einstein we know, that everything is relative <bg> - from the
point of view of the form, it looks as if the mousecursor is moving ...

a short workaround would be to place the cursor, somewhere where the form
can't reach him

open=class::workaround

function workaround
extern clogical SetCursorPos(cint,cint) user32
setcursorpos(0,0)
return super::open()

------
www.vdblogic.de/dbl/homee.htm
------
Ken Mayer [dBASE, Inc.]
2004-02-26 15:35:02 UTC
Permalink
Post by Marc VdB
Post by Jean-Pierre Martel
I would like the form to close as
soon as the user moves the mouse pointer. Unfortunately, the
onMouseMove() event fires as soon as the form opens, without any role
played by the end user.
I let Ken decide if this is WAD, but in fact by enlarging the Windows , you
move it over the cursor...
And since Einstein we know, that everything is relative <bg> - from the
point of view of the form, it looks as if the mousecursor is moving ...
I think I agree with Marc here. The form itself is resizing under the
mouse, so it appears that the mouse has moved, to the form. I tried a
couple of workarounds that were different from what Marc suggested and
couldn't get anything to work.

Ken
---
Ken Mayer [dBASE, Inc.]
** Please respond ONLY in the newsgroups **

"Think OOP"

dBASE, Inc. website: http://www.dbase.com
Marc Hamelin
2004-02-26 16:09:33 UTC
Permalink
What's weird is that the onMouseMove event is triggered when you assign
something to it. Here's the same form that Jean-Pierre used, but with a
small modification:

// Beginning of the onMouseMove Form

** END HEADER -- do not remove this line
//
// Generated on 25/02/04
//
parameter bModal
local f
f = new OMMForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif

class OMMForm of FORM
with (this)
open = class::FORM_OPEN
metric = 6 // Pixels
height = 334.0
left = 371.0
top = 0.0
width = 280.0
windowState = 2 // maximized
text = ""
endwith

this.RECTANGLE1 = new RECTANGLE(this)
with (this.RECTANGLE1)
onMouseMove = {;form.close()}
left = 29.0
top = 33.0
width = 214.0
height = 251.0
text = "Rectangle1"
endwith


function FORM_open
super::open()
sleep 1
form.onMouseMove = {;form.close()}
return

endclass

// End of the onMouseMove Form

See what I mean? After the sleep pause, the form disappears even if you
didn't move your mouse (unless the problem comes from my mouse).

Marc Hamelin
Ken Mayer [dBASE, Inc.]
2004-02-26 16:42:08 UTC
Permalink
Post by Marc Hamelin
See what I mean? After the sleep pause, the form disappears even if you
didn't move your mouse (unless the problem comes from my mouse).
Yeah, that's what I was trying ...

Ken
---
Ken Mayer [dBASE, Inc.]
** Please respond ONLY in the newsgroups **

"Think OOP"

dBASE, Inc. website: http://www.dbase.com
Marc VdB
2004-02-26 17:22:42 UTC
Permalink
"Marc Hamelin" <***@nospam-rasakti.com> schrieb im Newsbeitrag

Hi Marc,
Post by Marc Hamelin
What's weird is that the onMouseMove event is triggered when you assign
something to it. Here's the same form that Jean-Pierre used, but with a
<snip>
Post by Marc Hamelin
See what I mean? After the sleep pause, the form disappears even if you
didn't move your mouse (unless the problem comes from my mouse).
It is the same effect as in Jean Pierres first post. The windows-message
(generated by the maximizing of the form) is still pending (don't know if
this is correct, but if not, it is definitely an OS thing)
It is not the fact that you assign the eventhandler, but the fact that in
the message-queue there is still this message, that the mouse moved (even if
it was the form that moved).
You can see it, if you delete the line with : windowstate=2 (all works as
expected)

cu, Marc
--
------
www.vdblogic.de/dbl/homee.htm
------
Marc Hamelin
2004-02-26 18:23:13 UTC
Permalink
Even weirder... The first time I ran the form without windowstate=2, the
problem appears, but the second time everything is fine. I ran it a third
time and I got the problem again. I ran it a fourth time, and everything
was fine again. I then tried it with windowstate=2 and got the exact same
results!

For me the problem is ON, then OFF, then ON again, then OFF again, then ON,
then OFF, etc. Anybody else get that? I run the form the source editor
(dBase Plus 2.01), so that may be what causes this strange behavior, but
still...

Marc Hamelin
Marc Hamelin
2004-02-26 18:11:20 UTC
Permalink
Post by Marc VdB
You can see it, if you delete the line with : windowstate=2 (all works as
expected)
No... I tried it without windowState=2 and I got the very same thing. It
closed the form after the delay. My guess would be your mouse wasn't over
the form as it opened. Place the mouse pointer where the form will appear
and don't touch it anymore. Now run the form. What do you get?

Marc Hamelin
Marc VdB
2004-02-26 22:26:09 UTC
Permalink
Post by Marc Hamelin
Post by Marc VdB
You can see it, if you delete the line with : windowstate=2 (all works as
expected)
No... I tried it without windowState=2 and I got the very same thing. It
closed the form after the delay. My guess would be your mouse wasn't over
the form as it opened. Place the mouse pointer where the form will appear
and don't touch it anymore. Now run the form. What do you get?
I see what i expected <g>. If the cursor is not affected by the form, that
means if the form opens at a place where the cursor is not, then the
onmousemove doesn't fire
If it opens at the same place as the cursor, the onmousemove fires.

I guess it is some kind of logic of the OS. On creation of the window (form)
the mousecursor is not in the client area (because this area has size (0,0))
After the window is created, the mousecursor is inside of the clientarea (if
the form opens at the position of the cursor). First it was not there,
suddenly it is there, so it must have moved <g>

This said, the strange behaviour in your other thread (which i can
reproduce) is not to explain.

Just my humble attempt to understand what causes this behaviour

CU, Marc
------
www.vdblogic.de/dbl/homee.htm
------
Marc Hamelin
2004-02-27 13:17:55 UTC
Permalink
Okay, I get it now. The event is not simply triggered by the assignation of
code, but also by the fact that the mouse pointer is over the form. I see
what you mean. If it was simply caused by the assignation, it would close
the form regardless of whether the mouse pointer is over the form or not.

So I guess this particularity should be added to QAID: 4729. That and the
strange behavior that I mentioned in my other post - that is, if it's not
already solved in dBase Plus 2.2 or the upcoming 2.21.

Marc Hamelin

Jean-Pierre Martel
2004-02-26 17:46:11 UTC
Permalink
Post by Jean-Pierre Martel
I am building a Screen Saver in dBL.
He again <LOL>, Jean-Pierre next plan is to write a
realtime-tracking-system of all vehicles in Montreal
with integrated traffic-optimizer all in dBL
LOL.

With dBL, about anything is possible. To build a Screen saver is not that
complicated (as you will see in the next issue of the dBulletin). ;-)
a short workaround would be to place the cursor, somewhere
where the form can't reach him
Your solution works perfectly!

Thanks a lot Marc.

Jean-Pierre Martel
=== A new dBASE Conference in Montréal, July 9th and 10th, 2004 ===
Marc VdB
2004-02-26 22:45:22 UTC
Permalink
Post by Jean-Pierre Martel
With dBL, about anything is possible. To build a Screen saver is not that
complicated (as you will see in the next issue of the dBulletin). ;-)
ahh, a teaser <g>
Post by Jean-Pierre Martel
Post by Marc VdB
a short workaround would be to place the cursor, somewhere
where the form can't reach him
Your solution works perfectly!
Normally i would avoid to displace the cursor programmatically. It will at
least surprise the user <g>, but as you want to do it in a screen-saver,
(where the cursor-position has no essential meaning), i think it is not that
impolite ...
Post by Jean-Pierre Martel
Thanks a lot Marc.
you are welcome

KR, Marc
--
------
www.vdblogic.de/dbl/homee.htm
------
mark.i
2004-02-26 08:57:36 UTC
Permalink
Post by Jean-Pierre Martel
I am building a Screen Saver in dBL. I would like the form
to close as
Post by Jean-Pierre Martel
soon as the user moves the mouse pointer. Unfortunately,
the
Post by Jean-Pierre Martel
onMouseMove() event fires as soon as the form opens,
without any role
Post by Jean-Pierre Martel
played by the end user.
It also maximises the Navigator window when your sample is
launched from the navigator.

Mar.I
Glenn Fausel
2004-02-26 16:02:16 UTC
Permalink
Try this. Seems to work for me.

Glenn Fausel

* END HEADER -- do not remove this line
//
// Generated on 02/26/04
//
parameter bModal
local f
f = new mousemoveForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif

class mousemoveForm of FORM
with (this)
onMouseMove = class::FORM_ONMOUSEMOVE
height = 23.3636
left = 37.0
top = 0.0
width = 115.4286
text = ""
windowState = 2 // Maximized
endwith


function form_onMouseMove(flags, col, row)
if type("form.mouseflag") = "U"
form.mouseflag = true
return
else
form.close()
endif
return
endclass
Jean-Pierre Martel
2004-02-26 18:10:45 UTC
Permalink
Post by Glenn Fausel
Try this. Seems to work for me.
Thanks. Your solution works fine. However... ;-)

The present behavior of dBASE is to close the form as soon as it is open
and also as soon as a new image has to be displayed by the screen saver
(probably because that new image has to be centered with some API calls
and that probably moves the mouse pointer a fraction of second).

Right now, I am still undecided if I should use Marc Van den Berghen's
code (that places the mouse cursor at the upper left corner of the
screen) or the dBL code that I had written before reading his MSG (which
doesn't move the mouse pointer).

The latter takes advantage of the Timer used by the screen saver. When
the screen saver opens, it has no onMouseMove() function. The Timer has
its Interval property set to one second and a custom property called
"counter" set to zero. The onTimer() code allows the image to be changed
every three intervals but makes the onMouseMove() function effective only
during the intervals during which the image is still.

Function onTimer
if this.counter = 0
this.oForm.onMouseMove = {;form.close()}
this.oForm.Image1.onMouseMove = {;form.close()}
this.counter++
elseif this.counter = 3
this.oForm.onMouseMove = null
this.oForm.Image1.onMouseMove = null
this.oForm.Show_a_New_Image()
this.counter = 0
else
this.counter++
endif
return

Jean-Pierre Martel
=== A new dBASE Conference in Montréal, July 9th and 10th, 2004 ===
Ken Mayer [dBASE, Inc.]
2004-02-26 16:45:37 UTC
Permalink
Post by Jean-Pierre Martel
I am building a Screen Saver in dBL. I would like the form to close as
soon as the user moves the mouse pointer. Unfortunately, the
onMouseMove() event fires as soon as the form opens, without any role
played by the end user.
I've entered a bug report about the onMouseMove event firing when code
is assigned to it, QAID: 4729.

Ken
---
Ken Mayer [dBASE, Inc.]
** Please respond ONLY in the newsgroups **

"Think OOP"

dBASE, Inc. website: http://www.dbase.com
Jean-Pierre Martel
2004-02-26 17:15:32 UTC
Permalink
In article <***@4ax.com>, ***@dbase.com
says...
Post by Ken Mayer [dBASE, Inc.]
I've entered a bug report about the onMouseMove event
firing when code is assigned to it, QAID: 4729.
Thanks.

Jean-Pierre Martel
=== A new dBASE Conference in Montréal, July 9th and 10th, 2004 ===
Marc VdB
2004-02-26 17:25:39 UTC
Permalink
"Ken Mayer [dBASE, Inc.]" <***@dbase.com> schrieb

Ken, i am not sure that there is a bug, please see my reply to Marc Hamelin
Post by Ken Mayer [dBASE, Inc.]
I've entered a bug report about the onMouseMove event firing when code
is assigned to it, QAID: 4729.
------
www.vdblogic.de/dbl/homee.htm
------
Loading...