Hello.
I am having problems scaling a Visual Basic Picture control from a C++ DLL. Here is the code that I am using:
In Visual Basic, I call the scaling routine in the C++ DLL using the following code:
where:
Then, in the C++ DLL, the function is as follows:
However, when I plot a collection of points in the picture control, it shows that the scale is upside-down and too small (ie. some of the points are drawn off-screen, even though they’re within the width and height specifications used in the SetWindowExtEx function).
Can anyone see why the control is not being scaled properly??? Thank you very much.
Nikolai.
I am having problems scaling a Visual Basic Picture control from a C++ DLL. Here is the code that I am using:
In Visual Basic, I call the scaling routine in the C++ DLL using the following code:
Code:
Call ScalePicture(Picture1.hWnd, Picture1.hDC)
where:
Code:
Declare Sub ScalePicture Lib "C:\ MYDLL.dll" (ByVal inWND As Long, ByVal inDC As Long)
Then, in the C++ DLL, the function is as follows:
Code:
void ScalePicture(HWND inWND, HDC inDC)
{
int xClient, yClient; [COLOR=green]// variables used for picture dimensioning[/color]
int xOrigin, yOrigin; [COLOR=green]// variables used for specifying location of origin[/color]
int width=100, height=200; [COLOR=green]// variables used to define the desired logical[/color]
[COLOR=green]// dimensions of the picture[/color]
RECT Picturecoord={0}; [COLOR=green]//picture coordinates[/color]
SIZE prevsize;
GetClientRect(inWND, &Screencoord);
xClient=abs(Screencoord.right-Screencoord.left);
yClient=abs(Screencoord.bottom-Screencoord.top);
SetMapMode(inDC,MM_ANISOTROPIC);
SetWindowExtEx(inDC,width,height,&prevsize); [COLOR=green]// set screen coordinates[/color]
SetViewportExtEx(inDC,xClient,-yClient,&prevsize); [COLOR=green]// set viewport location[/color]
xOrigin=0;
yOrigin=0;
SetViewportOrgEx(inDC,xOrigin,yOrigin,&prevpoint); [COLOR=green]// set origin[/color]
}
Can anyone see why the control is not being scaled properly??? Thank you very much.
Nikolai.