BUG: Incorrect Coordinates Passed to OLEDragDrop/OLEDragOver (200491)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 6.0
This article was previously published under Q200491 SYMPTOMS
When you use an ActiveX control, such as Microsoft TreeView control and Microsoft ListView control, from the COMCTL32.ocx file, (located in Visual C++ version 5.x), or the MSCOMCTL.ocx file (located in Visual C++ version 6.0) in a Microsoft Foundation Classes (MFC) application, then the x- and y-coordinates that are passed to the OLEDragDrop() and OLEDragOver() event handlers are incorrect. The passing of these incorrect handlers causes the control's HitTest() method to return a wrong value.
CAUSE
The control's HitTest() method needs and takes a Twips units and a positive y-coordinate value. However, the y-coordinate is a negative value when it is passed in to the MFC container's OLEDragDrop() and OLEDragOver() event handlers. In addition, the values passed in are measured in pixel units instead of Twips units.
RESOLUTION
Use the following code to perform the conversion from pixel units to Twips units in the OLEDragDrop/OLEDragOver event handlers:
void ConvertXYtoTwips(float FAR* x, float FAR* y)
{
// Get a device context.
HDC hdc = GetDC(NULL);
// Determine how many Twips are in one pixel.
CPoint pOne(1, 1);
SetMapMode(hdc, MM_TWIPS);
DPtoLP(hdc, &pOne, 1);
// Convert *x and *y to Twips units.
float xx = *x * pOne.x;
float yy = *y * pOne.y;//NOTE: both *y and pOne.y are negative values.
// Release the device context.
ReleaseDC(NULL, hdc);
// X and y are in Twips pixel units.
*x = xx;
*y = yy;
}
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 10/24/2003 |
---|
Keywords: | kbbug kbCmnCtrls kbDragDrop kbpending KB200491 |
---|
|