On Mon, Dec 12, 2011 at 8:14 AM, Oliver Sims <
oliver.s...@simsassociates.co.uk> wrote:
> **
> Many thanks, Mark. This would do fine - but having run the program, it
> occured to me that I'd also need an event when the mouse leaves my dialog.
> So I looked up MSDN and tried adding the following to appropriate places in
> your program:
>
>
> ::constant WM_MOUSELEAVE 0x02A3 -- from MSDN
>
> ...
>
> self~addUserMsg(onLeave, self~WM_MOUSELEAVE, 0xffffffff, 0, 0, 0, 0)
>
> ...
>
> ::method onLeave unguarded
> say "Mouse Left!"
>
>
> No error, but the method onLeave was never invoked, no matter how often I
> had the mouse pointer leave the dialog. Btw I also tried it with addUserMsg
> statement of:
> self~addUserMsg(onLeave, self~WM_MOUSELEAVE, 0x00000000, 0, 0, 0, 0)
> based on something I read in MSDN about values of wParam and LParam.
>
> Any thoughts?
>
>
Yeah, my thoughts are that it won't work. I already tested it. <grin>
By default, the mouse leave event is not generated in Windows. It has to
be specially requested. There is no support in ooDialog to request it.
What really needs to be done, is to add a Mouse class in ooDialog and then
implement the needed functionality in that class.
But, I don't want to even start thinking about it now, when I can finally
see the light in the tunnel in my documentation work. I would much rather
spend my free time implementing ooDialog functionality then in writing
documentation. Which is why I ended up with so much new functionality
implmented, but not documented. The menu classes I implemented over 2
years ago, but they still aren't documented. ;-(
It is just going to be difficult for you to do what you want with the
current ooDialog implementation Now, the normal way to do drag and drop is
to respond to the left mouse button down event.
There is a Windows API, DetectDrag() that allows you to check if the user
has started a drag operation, or if they just clicked the button. (There
is also a Windows API, TrackMouseEvent() that allows you to request the
mouse leave event.) There is no access in ooDialog to these APIs. Part of
implementing a Mouse class in ooDialog would be to allow access to all the
Windows mouse API functions.
You might want to take a look at adding a user message for WM_LBUTTONDOWN,
and looking at the code for ::method defTreeDragHandler in ooDialog.cls.
You could used defTreeDragHandler as a basis for the method to connect to
LBUTTONDOWN. Although, again, my gut feeling is that you are not going to
get this to work. Still, you could try.
The idea would be to check that the left mouse button is held down for a
couple of milliseconds and that the mouse position is changing, which would
indicate that the user is dragging. If so, then use the defTreeDragHandler
as a basis to do your implementation.
A big problem with this is going to be that the mouse messages go to the
window the mouse is over, so if the user starts the drag operation over a
dialog control, you are not going to get any notification of it. The
reason defTreeDragHandler works is that the tree control has an explicit
notification to tell the parent dialog that the user has initiated a drag
operation.
One idea might be to use connectKeyPress() or connectFKeyPress() and say
that F9 means initiate drag and drop. So, when the user has the mouse over
a dialog control and they want to drag and drop something, they would press
the left mouse button down and hit F9.
In your F9 handler, you would, in pseudo Rexx code:
get mouse position and translate to dialog control it is over
translate position in dialog control to the item to be dragged
capture mouse with dialog hwnd
do revised defTreeDragHandler
handle drop or abort drag operation
release mouse captue
Without some extra user notice, like hitting the F9 key, I don't see how
this can work in ooDialog if you want to drag something from a dialog
control. There is just no way to know that the user has started a drag
operation when the mouse is over a dialog control, in ooDialog. (There are
ways to do it in C / C++ code of course.) As far as I know, the tree
control is the only control that notifies the parent dialog of a drag
operation. You could support dragging from a tree control to somewhere
else in the dialog, with some work.
--
Mark Miesfeld
P.S. This won't work:
self~addUserMsg(onLeave, self~WM_MOUSELEAVE, 0x00000000, 0, 0, 0, 0)
The third parameter in addUserMsg is a value to AND with the windows
message (arg 2.) Arg 3 is a filter, that works like this:
if (arg2 & arg3 == arg2) then this is a message I want.
WM_MOUSELEAVE == 0x02a3
0x02a3 & 0x000 == 0x0 -> fails test
0x02a3 & 0xFFFFFFFF == 0x02a3 -> passes test.
--
Mark Miesfeld
> ------------------------------
> *From:* Mark Miesfeld [mailto:miesf...@gmail.com]
> *Sent:* 12 December 2011 15:06
> *To:* Open Object Rexx Users
> *Subject:* Re: [Oorexx-users] ooDialog - Detect mouse moving over a
> dialog?
>
> On Mon, Dec 12, 2011 at 5:00 AM, Oliver Sims <
> oliver.s...@simsassociates.co.uk> wrote:
>
>> **
>> I've looked through build 7382 of ooDialog Reference, and have found the
>> change cursor shape methods.
>> What I hoped to find was a way to change the mouse pointer to an image of
>> my own, but it seems that is not possible (??).
>>
>>
>
> This could be possible, but ooDialog currently doesn't have anything that
> would support it. So, practically speaking it is not possible at this
> point in time.
>
>
>
>
>>
>>
>> So next question: can I detect when the mouse moves over my dialog? I've
>> looked at all the standard event-handling methods, but cannot find one
>> that tells me when the mouse "enters" or "leaves" my dialog as the user
>> drags the mouse over it. Does such a thing exist?
>>
>>
>
> The current mouse support in ooDialog was poorly thought out, in my
> opinion. But mouse support is not something that lends itself easily to
> ooDialog. What is there, is tied to the dialog object. It would be better
> to have a mouse class and add features to that class.
>
> Be sure to look at captureMouse(), getMouseCapture(), and
> releaseMouseCapture(). Although I haven't ever tried them and my gut
> feeling is that they won't give you much.
>
> That said, here is a sample program that shows how to connect the mouse
> move event. Problems are going to be: you won't get the notification if
> the mouse is over any dialog control in the dialog, there is no way to tell
> when the mouse leaves the dialog, and probably other problems. <grin>
>
> This is probably the best you can do at this point:
>
> /* Simple User Dialog template */
>
> dlg = .SimpleDialog~new( , "simple.h")
> dlg~execute("SHOWTOP", IDI_DLG_OOREXX)
>
> ::requires "ooDialog.cls"
>
> ::class 'SimpleDialog' subclass UserDialog
>
> ::constant WM_MOUSEMOVE 0x0200
> ::constant MK_LBUTTON 0x0001
> ::constant MK_RBUTTON 0x0002
> ::constant MK_SHIFT 0x0004
> ::constant MK_CONTROL 0x0008
> ::constant MK_MBUTTON 0x0010
> ::constant MK_XBUTTON1 0x0020
> ::constant MK_XBUTTON2 0x0040
>
> ::method init
> forward class (super) continue
>
> self~create(30, 30, 257, 123, "Simple Dialog", "CENTER")
> self~addUserMsg(onMove, self~WM_MOUSEMOVE, 0xffffffff, 0, 0, 0, 0)
>
> ::method defineDialog
>
> self~createPushButton(IDOK, 142, 99, 50, 14, "DEFAULT", "Ok")
> self~createPushButton(IDCANCEL, 197, 99, 50, 14, , "Cancel")
>
> ::method onMove unguarded
> use arg wParam, lParam
>
> pos = .Point~new(.DlgUtil~sLoWord(lParam), .DlgUtil~sHiWord(lParam))
> keys = ''
> if .DlgUtil~and(wParam, self~Mk_CONTROL) <> 0 then keys ||= 'Ctrl'
> if .DlgUtil~and(wParam, self~Mk_SHIFT) <> 0 then keys ||= ' Shift'
> if .DlgUtil~and(wParam, self~Mk_LBUTTON) <> 0 then keys ||= ' LButton'
> if .DlgUtil~and(wParam, self~Mk_RBUTTON) <> 0 then keys ||= ' RButton'
> if .DlgUtil~and(wParam, self~Mk_MBUTTON) <> 0 then keys ||= ' MButton'
> if .DlgUtil~and(wParam, self~Mk_XBUTTON1) <> 0 then keys ||= ' XButton1'
> if .DlgUtil~and(wParam, self~Mk_XBUTTON2) <> 0 then keys ||= ' XButton2'
>
> say 'The mouse is at ('pos~x',' pos~y') with these qualifiers:' keys
>
> return 0
> You will get output like this:
>
> The mouse is at (95, 78) with these qualifiers:
> The mouse is at (93, 76) with these qualifiers:
> The mouse is at (87, 72) with these qualifiers:
> The mouse is at (47, 119) with these qualifiers: LButton
> The mouse is at (72, 79) with these qualifiers:
> The mouse is at (45, 148) with these qualifiers: LButton
> The mouse is at (57, 164) with these qualifiers: LButton
>
>
> --
> Mark Miesfeld
>
>
> ------------------------------------------------------------------------------
> Learn Windows Azure Live! Tuesday, Dec 13, 2011
> Microsoft is holding a special Learn Windows Azure training event for
> developers. It will provide a great way to learn Windows Azure and what it
> provides. You can attend the event by watching it streamed LIVE online.
> Learn more at http://p.sf.net/sfu/ms-windowsazure
> _______________________________________________
> Oorexx-users mailing list
> Oorexx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-users
>
>
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users