Thread View: borland.public.cppbuilder.nativeapi
8 messages
8 total messages
Started by JD
Sun, 23 Apr 2006 13:24
WM_MOUSEMOVE and OnMouseMove
Author: JD
Date: Sun, 23 Apr 2006 13:24
Date: Sun, 23 Apr 2006 13:24
19 lines
1444 bytes
1444 bytes
I was getting some strange behavior when processing WM_MOUSEMOVE
and traced it back to how I was interpreting X,Y. The points
are passed in the message as words:
if( Message.Msg == WM_MOUSEMOVE )
{
HeaderMouseMove( KeysToShiftState(Message.WParam), LOWORD(Message.LParam), HIWORD(Message.LParam) );
}
and then interpreted as ints in the handler:
void __fastcall TMyListView::HeaderMouseMove( TShiftState Shift, int X, int Y );
The problem was that negative numbers in a WORD just become
large number in the ints and I'm looking for an eligant way
of not loosing the sign.
~ JD
Re: WM_MOUSEMOVE and OnMouseMove
Author: Bob Gonder
Date: Sun, 23 Apr 2006 16:49
Date: Sun, 23 Apr 2006 16:49
19 lines
1629 bytes
1629 bytes
JD wrote: >I was getting some strange behavior when processing WM_MOUSEMOVE >and traced it back to how I was interpreting X,Y. The points >are passed in the message as words: > > HeaderMouseMove( KeysToShiftState(Message.WParam), LOWORD(Message.LParam), HIWORD(Message.LParam) ); > >and then interpreted as ints in the handler: > > void __fastcall TMyListView::HeaderMouseMove( TShiftState Shift, int X, int Y ); > >The problem was that negative numbers in a WORD just become >large number in the ints and I'm looking for an eligant way >of not loosing the sign. Convert to shorts: MAKEPOINTS( Message.LParam ).x MAKEPOINTS( Message.LParam ).y
Re: WM_MOUSEMOVE and OnMouseMove
Author: Bob Gonder
Date: Sun, 23 Apr 2006 17:05
Date: Sun, 23 Apr 2006 17:05
9 lines
1213 bytes
1213 bytes
Bob Gonder wrote: >Convert to shorts: > MAKEPOINTS( Message.LParam ).x > MAKEPOINTS( Message.LParam ).y Wait, that makes pointers, better use MAKEPOINTS( Message.LParam )->x
Re: WM_MOUSEMOVE and OnMouseMove
Author: JD
Date: Mon, 24 Apr 2006 05:07
Date: Mon, 24 Apr 2006 05:07
20 lines
1542 bytes
1542 bytes
Bob Gonder <notbg@notmindspring.invalid> wrote: > >>Convert to shorts: That's what I did to solve the problem but I did it a bit differently. >>> HeaderMouseMove( KeysToShiftState(Message.WParam), LOWORD(Message.LParam), HIWORD(Message.LParam) ); I left that the same .... >>> void __fastcall TMyListView::HeaderMouseMove( TShiftState Shift, int X, int Y ); and Changed that to ...( ... short X, short Y ); but I was wondering how the VCL does it because it gets X,Y just like I'm getting them and they're passed to the event as ints just like I was doing it. ~ JD
Re: WM_MOUSEMOVE and OnMouseMove
Author: Bob Gonder
Date: Mon, 24 Apr 2006 06:34
Date: Mon, 24 Apr 2006 06:34
20 lines
1811 bytes
1811 bytes
JD wrote: > >and Changed that to ...( ... short X, short Y ); but I was >wondering how the VCL does it because it gets X,Y just like >I'm getting them and they're passed to the event as ints >just like I was doing it. Maybe they don't process negative values (mouse outside the client window) ? MSDN: "The WM_MOUSEMOVE message is posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse." Since most windows likely don't capture the mouse, they would only get positive values, and the LOWORD to int conversion would be correct. (or perhaps you are looking at 16 bit code examples?)
Re: WM_MOUSEMOVE and OnMouseMove
Author: JD
Date: Mon, 24 Apr 2006 08:47
Date: Mon, 24 Apr 2006 08:47
12 lines
1323 bytes
1323 bytes
Bob Gonder <notbg@notmindspring.invalid> wrote: > > [...] they would only get positive values, and the LOWORD to > int conversion would be correct. Ok ... you got me. I failed to say that the mouse was captured because a mouse button was down. The event with ints worked fine untill I moved out of the control up and/or to the left and then the fun began. ~ JD
Re: WM_MOUSEMOVE and OnMouseMove
Author: Remy Lebeau (TeamB)
Date: Mon, 24 Apr 2006 19:01
Date: Mon, 24 Apr 2006 19:01
14 lines
1369 bytes
1369 bytes
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message news:vrcn42l1hnspdob90kmpqeei06cssbokme@4ax.com... > Wait, that makes pointers, better use > > MAKEPOINTS( Message.LParam )->x No it doesn't. MAKEPOINTS returns a POINTS structure by value, not a pointer to one. Your original use of the '.' operator instead of the '->' operator was correct. Gambit
Re: WM_MOUSEMOVE and OnMouseMove
Author: Remy Lebeau (TeamB)
Date: Mon, 24 Apr 2006 19:04
Date: Mon, 24 Apr 2006 19:04
22 lines
1726 bytes
1726 bytes
"JD" <nospam@nospam.com> wrote in message news:444c5cfe$1@newsgroups.borland.com... > I was wondering how the VCL does it I guess you didn't try looking at the VCL source code yet. > it gets X,Y just like I'm getting them No, it is not. You are using the LO/HIWORD macros. The VCL does not do that. > they're passed to the event as ints just like I was doing it. The VCL is retrieving the values as signed shorts to begin with, but your code is retreiving them as unsigned shorts instead. A signed short passed to a signed int parameter will preserve the sign. Passing an unsigned short to a signed int parameter will not preserve the sign for negative values. Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads