| Home | Previous Lesson: Printing the Report Next Lesson: Setting up the Printer |
If a DataWindow doesn't fit on the screen, either horizontally or vertically, it may be a good idea to allow the user to see a print preview before it is actually sent to the printer.
// Object: cb_Print_Preview in w_product_master
// Event: Clicked
if dw_product.Describe("datawindow.Print.Preview") = "yes" then
dw_product.Modify("datawindow.Print.Preview = no")
else
dw_product.Modify("datawindow.Print.Preview = yes")
dw_product.Modify("datawindow.Print.Preview.Rulers = yes")
end if
The Describe() function returns the state of the control and we use a Modify() function to change it. Describe() and Modify() are some of the special functions. They are important because, they give control on DataWindows. As the name says, Describe() gives status of the specified parameter, where as Modify() changes the value of the specified parameter.
For example, if you want to hide a DataWindow control, what you do? You call dw_product.Hide(). The Hide() function acts on the DataWindow control. If you want to act on the object that is in the DataWindow control, i.e., the DataWindow object, you need to use the Modify() function.
There are two types of things that you can modify in a DataWindow object; they are either the DataWindow object itself or a field within the DataWindow object.
Take the example of printing a DataWindow. Here, you won't be printing a field, instead you will be printing the DataWindow object itself. That means, you are acting on the whole DataWindow.
In another example, say you want to display the product_balance in red color if the balance is less than the product_reorder_level. That means, you want to change the foreground color of one field, product_balance.
In the above code, we were trying to find if the DataWindow was in the print preview mode. To act on the DataWindow object itself, you need to send "DataWindow" as the parameter literally, followed by the properties.
dw_product.Describe("DataWindow.print.preview") returns either "yes" or a "no".
If it is not in the print preview mode, we are turning on the print preview mode by calling the Modify() function.
dw_product.Modify("datawindow.print.preview.rulers=yes") turns on the print preview rulers.
You will be learning in depth about Describe() and Modify() in later sessions. Till then if you need some more help, look for "describe" PowerScript function. Once you are in that help topic, go to DataWindow Object properties from the "See Also" button. Make a bookmark, because, you will be referring to it in your real world projects many times.
| Home | Previous Lesson: Printing the Report Next Lesson: Setting up the Printer |