Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scaling using SetWindowExtEx

Status
Not open for further replies.

nhungr

Programmer
Jan 31, 2005
26
CA
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:

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]
}
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top