-
May 10th, 2017, 10:25 AM
#1
What does mean: lParam | 0x80000000 in a WM_LBUTTONDOWN
Hello everyone,
as the title, what does lParam | 0x80000000 mean in a WM_LBUTTONDOWN?
I know that HI e LO lparam words specifies cursor coordinates, but what does it mean if I use an OR bitwise operator with 0x80000000?
Thank you
-
May 10th, 2017, 11:00 AM
#2
Re: What does mean: lParam | 0x80000000 in a WM_LBUTTONDOWN
Are you using multiple monitors? The lo-order word specifies the x co-ord and the hi-order word specifies the y co-ord. These are signed values so LOWORD and HIWORD shouldn't be used to extract them as these treat the extraction as unsigned - use GET_X_LPARAM() and GET_Y_LPARAM(). The extracted hi-word and lo-word need to be treated as signed short - as systems with multiple monitors can have negative x and y co-ords. See https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
May 10th, 2017, 12:25 PM
#3
Re: What does mean: lParam | 0x80000000 in a WM_LBUTTONDOWN
Originally Posted by 2kaud
Are you using multiple monitors? The lo-order word specifies the x co-ord and the hi-order word specifies the y co-ord. These are signed values so LOWORD and HIWORD shouldn't be used to extract them as these treat the extraction as unsigned - use GET_X_LPARAM() and GET_Y_LPARAM(). The extracted hi-word and lo-word need to be treated as signed short - as systems with multiple monitors can have negative x and y co-ords. See https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
Thank you for your answer,
the problem is that I don't understand the use of bitwise operator "or" (| 0x80000000)
-
May 10th, 2017, 12:29 PM
#4
Re: What does mean: lParam | 0x80000000 in a WM_LBUTTONDOWN
Why do you want to use the bitwise operator with lparam? You extract the x and y co-ords as
Code:
short xPos = GET_X_LPARAM(lParam);
short yPos = GET_Y_LPARAM(lParam);
You don't need to directly manipulate lparam.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
May 10th, 2017, 12:42 PM
#5
Re: What does mean: lParam | 0x80000000 in a WM_LBUTTONDOWN
I think that too, but I found this operation in an example without any comment, and so I would like to know what does it mean
-
May 10th, 2017, 01:24 PM
#6
Re: What does mean: lParam | 0x80000000 in a WM_LBUTTONDOWN
Technically this sets the leftmost bit. But what use the code makes of it totally depends on the code. The code is at your disposal, so read it and see the use. Or show the code here and let us comment on it.
Best regards,
Igor
-
May 10th, 2017, 01:39 PM
#7
Re: What does mean: lParam | 0x80000000 in a WM_LBUTTONDOWN
It means its setting the MSB of lParam (bit 32). For a signed number, the MSB is the sign bit so it is creating a negative number. As a negative number is stored as 2's complement, what this number actually is depends upon what is in the other bit positions - and whether it is being treated as a 32 bit or 2 16 bit numbers. Alternatively, it might have nothing to do with being a negative number but is some special flag that is used by the program. How is lParam used elsewhere in the program?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
May 11th, 2017, 04:29 AM
#8
Re: What does mean: lParam | 0x80000000 in a WM_LBUTTONDOWN
Originally Posted by 2kaud
it might have nothing to do with being a negative number but is some special flag that is used by the program.
That exactly was my thought.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|