home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 January
/
pcwk_01_1999.iso
/
Wtestowe
/
Vistdstd
/
Install
/
Data.Z
/
Helper.BAS
< prev
next >
Wrap
BASIC Source File
|
1996-09-04
|
6KB
|
200 lines
Attribute VB_Name = "helper"
' -----------------------------------------------------------------------------
' Copyright (C) 1993-1996 Visio Corporation. All rights reserved.
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Visio has no warranty,
' obligations or liability for any Sample Application Files.
' -----------------------------------------------------------------------------
Option Explicit
'--
'-- SetHourGlass action constants
'--
Global Const MP_WAIT = 1
Global Const MP_NORMAL = 2
Global Const MP_RESTORE = 3
'--
'-- Type & Global Declarations
'--
Global Const SIDE_TOP = 1
Global Const SIDE_BOTTOM = 2
Global Const SIDE_LEFT = 3
Global Const SIDE_RIGHT = 4
Type VisPoint
X As Variant
Y As Variant
End Type
Sub SetMousePointer(iType As Integer)
'----------------------------------------
'--- SetMousePointer --------------------
'--
'-- Manages multiple requests for the hour glass pointer. Passing MP_WAIT
'-- not only changes the pointer to an hourglass, it increments the count of
'-- requests for it. MP_NORMAL will decrement it and only when it returns
'-- to zero does the cursor change back to it's default pointer. Multiple
'-- procedures can ask for an hourglass this way without overrunning each other.
'--
'-- Parameters : iType - MP_WAIT Changes mouse pointer to hourglass if not
'-- already.
'-- MP_NORMAL Decrements the hourglass count and, if 0,
'-- restores the pointer to it's default.
'-- MP_RESTORE Clears the hourglass count and restores
'-- the pointer to it's default.
'--
Static iWaitCount As Integer
Select Case iType
Case MP_WAIT
iWaitCount = iWaitCount + 1
Screen.MousePointer = 11
Case MP_NORMAL
If iWaitCount > 0 Then
iWaitCount = iWaitCount - 1
If iWaitCount = 0 Then Screen.MousePointer = 0
End If
Case MP_RESTORE
iWaitCount = 0
Screen.MousePointer = 0
End Select
End Sub
Sub BeginWaitPointer()
'----------------------------------------
'--- BeginWaitPointer -------------------
'--
'-- Use this procedure in conjunction with EndWaitPointer to toggle the mouse
'-- pointer between an hourglass, wait mode, and a regular pointer.
'--
Screen.MousePointer = 11 '-- Set To Hourglass Pointer
End Sub
Function BestExportPoint(shp As Object, iSide As Integer) As Integer
'-----------------------------------
'--- BestExportPoint ---------------
'--
'-- Finds the best connection(export) point on a shape for any given side.
'--
'-- Return Value : 1 based index of best export point.
'--
Dim dMax As Double, dResult As Double, cell As Object
Dim iBest As Integer, iRow As Integer, iCol As Integer
Dim iRows As Integer
iBest = 1
dMax = 0
iRows = shp.RowCount(visSectionExport)
Select Case iSide
Case SIDE_LEFT, SIDE_RIGHT: iCol = 0
Case SIDE_TOP, SIDE_BOTTOM: iCol = 1
End Select
For iRow = 0 To iRows
Set cell = shp.CellsSRC(visSectionExport, iRow, iCol)
dResult = cell.ResultIU
Select Case iSide
Case SIDE_LEFT, SIDE_BOTTOM
If dResult < dMax Then
dMax = dResult
iBest = iRow
End If
Case SIDE_RIGHT, SIDE_TOP
If dResult > dMax Then
dMax = dResult
iBest = iRow
End If
End Select
Next iRow
BestExportPoint = (iBest + 1)
End Function
Sub EndWaitPointer()
'----------------------------------------
'--- EndWaitPointer ---------------------
'--
'-- Use this procedure in conjunction with BeginWaitPointer to toggle the mouse
'-- pointer between an hourglass, wait mode, and a regular pointer.
'--
Screen.MousePointer = 0 '-- Set To Default Mouse Pointer
End Sub
Sub GetCtrlHandlePt(shp As Object, iPos As Integer, Pnt As VisPoint)
'-----------------------------------
'--- GetCtrlHandle -----------------
'--
'-- Retrieves a control handle X,Y point structure from a shape.
'--
'-- Parameters : shp - Shape sheet to get handle from.
'-- iPos - 1 based index of handle to retrieve. Do NOT use
'-- row constants.
'-- Pnt - Structure to receive control handle's X,Y point.
'--
Dim iRowIndex As Integer
'If Not IsShape(shp) Then Exit Sub 'Called By TotalCtrlPts!
If Not (iPos >= 1 And iPos <= HandleCount(shp)) Then Exit Sub
iRowIndex = visRowFirst + (iPos - 1) '-- Convert Index
Pnt.X = shp.CellsSRC(visSectionControls, iRowIndex, 0).Formula
Pnt.Y = shp.CellsSRC(visSectionControls, iRowIndex, 1).Formula
End Sub
Function HandleCount(shp As Object) As Integer
'-----------------------------------
'--- HandleCount -------------------
'--
'-- Returns the total number of control handles in a shape sheet. Zero is
'-- returned even if shape is invalid.
'--
HandleCount = shp.RowCount(visSectionControls)
End Function
Sub SetCtrlHandlePt(shp As Object, iPos As Integer, NewPoint As VisPoint)
'-----------------------------------
'--- SetCtrlHandlePt ---------------
'--
'-- Sets a control handles X,Y point only using a VisPoint structure. No
'-- changes are made unless the point exists.
'--
'-- Parameters : shp - Shape sheet to get cell from.
'-- iPos - 1 based index of control point to replace. Do not
'-- use row constants.
'-- NewPoint - Contains new control handle X,Y point.
'--
Dim iRowIndex As Integer
'If Not IsShape(shp) Then Exit Sub 'Called By TotalCtrlPts
If Not (iPos >= 1 And iPos <= HandleCount(shp)) Then Exit Sub
iRowIndex = visRowFirst + (iPos - 1)
shp.CellsSRC(visSectionControls, iRowIndex, 0).Formula = NewPoint.X
shp.CellsSRC(visSectionControls, iRowIndex, 1).Formula = NewPoint.Y
End Sub