ComponentOne VSView 8.0
ReadyState Property

Returns the current state of the control.

Syntax

val% = [form!]VSPrinter.ReadyState

Remarks

The values returned by the ReadyState property are described below:

 

Constant

Value

Description

vpstEmpty

0

The control is empty (there is no preview document).

vpstLoading

1

The control is loading a document from a disk file or URL.

vpstReady

2

The control has a preview document that can be saved or printed.

vpstOpen

3

The control is generating a document (StartDoc has been called, EndDoc has not).

vpstSaving

4

The control is saving a document to a disk file.

vpstPrinting

5

The control is printing a document.

 

When control state changes, the control sets the ReadyState property and fires the ReadyStateChange event.

There are many instances where an application may need to know the state of the control. For example, a Print button should be enabled only when the control has a document available for printing (vpstReady), and an Abort button should be enabled only while the control is generating a document (vpstOpen).

This property is especially useful for applications that create or load documents asynchronously. For example:

1.   When generating long documents, you may want to add DoEvents statements to your document generation function to keep the application responsive while the document is generated. In this case, you should make sure the document generation function is not called recursively. The following code illustrates this technique:

Private Function GenerateDocument() As Boolean

 

  ' ** avoid recursive calls

  If vp.ReadyState <> vpstReady Then Exit Function

 

  ' ** control is ready, so create document

  vp.StartDoc

  Dim i%

  For i = 0 To 1000

    GeneratePage i

    DoEvents ' ** keep application responsive

    If vp.Error <> 0 Then Exit For ' ** bail on errors

  Next

  vp.EndDoc

 

  ' ** done

  GenerateDocument = True

Exit Function

2.   When the control is used on a Web page and a document is loaded using the URL property, the ReadyState property will be set to vpstLoading while the document is downloaded from the server and loaded into the control, and it will be set to vpstReady when the document is ready to be displayed. You can trap the ReadyStateChange event and enable some page elements (such as a Print button) when the document is ready.  The following code illustrates this technique:

<html>

<head>

<title>VSPrinter8 ReadyState</title>

</head>

 

<script language="vbscript">

Sub vp_ReadyStateChange(ReadyState)

  sStates = Split("Empty Loading Ready Open Saving Printing", " ")

  document.all.ReadyDiv.innerText = "The VSPrinter is " & sStates(ReadyState)

End Sub

</script>

 

<body>

<p><div id=ReadyDiv>The VSPrinter control is Empty</div><p>

<object classid="clsid:A8561647-E93C-11D3-AC3B-CE6078F7B616" id=vp width=497 height=609>

  <param name=PageBorder value=7><param name=NavBar value=3>

  <param name=URL value="http://localhost/default.html">

</object>

</p>

</body>

</html>

Data Type

ReadyStateSettings (Enumeration)

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback