(Tested on TD15, TD42 and TD6x)
See help on SAM_ContextMenu (excerpt) :
When using a specific multimonitor setup, this message will not give the correct coordinates.wParam X coordinate in screen pixels relative to the upper left corner of the screen.
lParam Y coordinate in screen pixels relative to the upper left corner of the screen.
If the setup has the main monitor at the right, the second monitor will have negative X and Y coordinates.
See screenshot setup:
(by dragging the main (1) monitor and placing them in the order like in the screenshot)
Then, when a window is placed on the second monitor, SAM_ContextMenu does not give the correct x and y coordinates.
In fact, the message gives exactly what WM_CONTEXTMENU gives. Which means here, the Low and High values of lParam.
And this is wrong. The SAM message should convert the values correctly. I suspect that it does no conversion at all !!!
See docs on WM_CONTEXTMENU:
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
But the Low and High values are non-signed packed integers. This means that a negative number will be coded as a positive number using two's complement.
And looking at the docs on WM_CONTEXT menu, the X and Y coordinates are:
Look at the sample testcase:xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);
(the window is placed on the second monitor here, so the coordinates are negative for X positions and positive for Y positions)
As can be seen, the wParam and lParam of SAM_ContextMenu are the same as for the Low and High lParam values of WM_CONTEXTMENU.
So this proves that SAM_ContextMenu is not converting the values to signed numbers but gives the values 1:1.
And that is wrong !!!!
The purpose of this sample is to right-click on the listbox items and show the index of the clicked item in the datafield below.
Just by using the x and y positions SAM_ContextMenu provides, the sample will fail when the window is placed on the second monitor.
The checkbox "Use real pos" will enable the workaround for this issue: it will convert the unsigned two's complement to the real signed values.
And then the issue is fixed.
This defect seems to be in the TD product for ages.
But it needs to be fixed. Unify can do this by adding the GET_X_LPARAM and GET_Y_LPARAM macro's to the internal SAM_ContextMenu code.
Or change the documentation to indicate that the wParam and lParam are NOT the x and y coordinates, but need to be converted to signed numbers first before use.
Testcase is saved as TD15 text format.