Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to caculate the dw zoom ratio to fit for the dw control?

12 views
Skip to first unread message

Feng Zhu

unread,
May 19, 1999, 3:00:00 AM5/19/99
to
Hi, all.

I want to caculate a datawindow zoom ratio to fit for a certain datawindow
control, ie, make the preview image of the whole page as big as possible in
the range of dw control, not showing scrollbar?

Feng


Gregory R. George

unread,
May 20, 1999, 3:00:00 AM5/20/99
to

Feng,

Here are a couple of functions that will do that by changing the zoom until
it fits... it's slow and eats up alot of CPU, but it will work for all paper
sizes and platforms:

////////////////////////////////////////////////////////////////////////////
//
//
// Function: of_GetMaxZoomWidth
//
// Access: Public
//
// Arguments: adw_requestor - the DataWindow to compute (Default =
Requestor)
//
// Returns: Integer
// >0 if it succeeds (the maximum zoom width)
// 0 if no action was taken
// -1 if an error occurs
//
// Description: Calculates the maximum zoom percentage that will completely
// show all of the horizontal data in the DataWindow.
//
////////////////////////////////////////////////////////////////////////////
//
//
// Revision History
//
// Version
// 1.0 Initial version
//
////////////////////////////////////////////////////////////////////////////
//

Long ll_OriginalZoom, ll_zoom

adw_requestor.SetRedraw(False)
IF adw_requestor.Object.DataWindow.Print.Preview = 'yes' THEN
// We are in print preview mode

// Store the original zoom
ll_OriginalZoom = Long(adw_requestor.Object.DataWindow.Print.Preview.Zoom)
ll_zoom = ll_OriginalZoom

IF Integer(adw_requestor.Object.DataWindow.HorizontalScrollMaximum) > 0
THEN
// We must shrink the DataWindow
DO
ll_zoom --
adw_requestor.Object.DataWindow.Print.Preview.Zoom = String(ll_zoom)
LOOP UNTIL
Integer(adw_requestor.Object.DataWindow.HorizontalScrollMaximum) = 0 OR
ll_zoom < 2
ELSE
// We must grow the DataWindow
DO
ll_zoom ++
adw_requestor.Object.DataWindow.Print.Preview.Zoom = String(ll_zoom)
LOOP UNTIL
Integer(adw_requestor.Object.DataWindow.HorizontalScrollMaximum) > 0 OR
ll_zoom > 1000
ll_zoom --
END IF
adw_requestor.Object.DataWindow.Print.Preview.Zoom =
String(ll_OriginalZoom)
ELSE
// We are not in print preview mode

// Store the original zoom
ll_OriginalZoom = Long(adw_requestor.Object.DataWindow.Zoom)
ll_zoom = ll_OriginalZoom

IF Integer(adw_requestor.Object.DataWindow.HorizontalScrollMaximum) > 0
THEN
// We must shrink the DataWindow
DO
ll_zoom --
adw_requestor.Object.DataWindow.Zoom = String(ll_zoom)
LOOP UNTIL
Integer(adw_requestor.Object.DataWindow.HorizontalScrollMaximum) = 0 OR
ll_zoom < 2
ELSE
// We must grow the DataWindow
DO
ll_zoom ++
adw_requestor.Object.DataWindow.Zoom = String(ll_zoom)
LOOP UNTIL
Integer(adw_requestor.Object.DataWindow.HorizontalScrollMaximum) > 0 OR
ll_zoom > 1000
ll_zoom --
END IF
adw_requestor.Object.DataWindow.Zoom = String(ll_OriginalZoom)
END IF
adw_requestor.SetRedraw(True)

RETURN ll_zoom

////////////////////////////////////////////////////////////////////////////
//
//
// Function: of_GetMaxZoomHeight
//
// Access: Public
//
// Arguments: adw_requestor - the DataWindow to compute (Default =
Requestor)
//
// Returns: Integer
// >0 if it succeeds (the maximum zoom height)
// 0 if no action was taken
// -1 if an error occurs
//
// Description: Calculates the maximum zoom percentage that will completely
// show all of the vertical data in the DataWindow.
//
////////////////////////////////////////////////////////////////////////////
//
//
// Revision History
//
// Version
// 1.0 Initial version
//
////////////////////////////////////////////////////////////////////////////
//

Long ll_OriginalZoom, ll_zoom

adw_requestor.SetRedraw(False)
IF adw_requestor.Object.DataWindow.Print.Preview = 'yes' THEN
// We are in print preview mode

// Store the original zoom
ll_OriginalZoom = Long(adw_requestor.Object.DataWindow.Print.Preview.Zoom)
ll_zoom = ll_OriginalZoom

IF Integer(adw_requestor.Object.DataWindow.VerticalScrollMaximum) > 0 THEN
// We must shrink the DataWindow
DO
ll_zoom --
adw_requestor.Object.DataWindow.Print.Preview.Zoom = String(ll_zoom)
LOOP UNTIL Integer(adw_requestor.Object.DataWindow.VerticalScrollMaximum)
= 0 OR ll_zoom < 2
ELSE
// We must grow the DataWindow
DO
ll_zoom ++
adw_requestor.Object.DataWindow.Print.Preview.Zoom = String(ll_zoom)
LOOP UNTIL Integer(adw_requestor.Object.DataWindow.VerticalScrollMaximum)
> 0 OR ll_zoom > 1000
ll_zoom --
END IF
adw_requestor.Object.DataWindow.Print.Preview.Zoom =
String(ll_OriginalZoom)
ELSE
// We are not in print preview mode

// Store the original zoom
ll_OriginalZoom = Long(adw_requestor.Object.DataWindow.Zoom)
ll_zoom = ll_OriginalZoom

IF Integer(adw_requestor.Object.DataWindow.VerticalScrollMaximum) > 0 THEN
// We must shrink the DataWindow
DO
ll_zoom --
adw_requestor.Object.DataWindow.Zoom = String(ll_zoom)
LOOP UNTIL Integer(adw_requestor.Object.DataWindow.VerticalScrollMaximum)
= 0 OR ll_zoom < 2
ELSE
// We must grow the DataWindow
DO
ll_zoom ++
adw_requestor.Object.DataWindow.Zoom = String(ll_zoom)
LOOP UNTIL Integer(adw_requestor.Object.DataWindow.VerticalScrollMaximum)
> 0 OR ll_zoom > 1000
ll_zoom --
END IF
adw_requestor.Object.DataWindow.Zoom = String(ll_OriginalZoom)
END IF
adw_requestor.SetRedraw(True)

RETURN ll_zoom

HTH,
Greg

--
________________________________________
Gregory R. George
Greg_...@AscensionLabs.com
Ascension Labs, LLC
Visit www.AscensionLabs.com for PB Tips,
Tricks, Tools, and Free Objects.

Feng Zhu wrote in message ...

0 new messages