PerfectScript Journal

August 1998: How to get named regions for WP Dialogs

After reading the title for this month's feature, you are probably
asking yourself, "Why would I ever want a named region from a
WP dialog, and what is a named region anyway?" If you make your
own dialogs, you are familiar with the Dialog ID and Control ID
that make up the region names for the user-defined dialogs. Well,
WP dialogs have region names also.

Frankly, most people probably will never need to use a named region
from a WP dialog, but once in a while you need may need to get
a setting from a dialog that you can't get otherwise.

For example, you may want to find out how many paragraphs are in a
document. But there isn't a system variable that will return that
information to you. Your macro could move through the document and
count the paragraphs for you, or you can get this information from
the Document Information dialog.

You'll see the paragraph count if you click File > Document > Properties,
then click the Information tab (in WPWin 7) or File > Properties,
then click the Information tab (in WPWin 8). But how can you get that
information into a macro variable? The answer is you can't unless you know
the region name of the control that contains the value.

Before you can get the region name, you must make an adjustment in your
Registry. Close WPWin before making the change. In Windows, click
Start > Run, then type regedit and (Enter).

If you use WPWin 7, in the Registry, select HKEY_CURRENT_USER,
then Software, then PerfectOffice, then PerfectFit. Below this folder there
should be a folder named Help. If not, right-click on PerfectFit and select
New > Key. Type Help and press (Enter).

Right-click on Help and select New > DWORD Value. Type
Help Information and press (Enter). Double-click Help Information,
type 1, then click OK.

For WPWin 8, there are two settings you must add. One allows help
information for dialog boxes and the other allows help for menu items. To set
help information for dialogs, select HKEY_CURRENT_USER, then
Software, then Corel, then PerfectFit, then 8, then Settings. Right-click this
folder and select New > DWORD Value. Type Show Help Information and
press (Enter). Double-click Show Help Information, type 1, then click OK.

For menu help information, select HKEY_CURRENT_USER, then Software,
then Corel, then PerfectFit. Below this folder there should be a folder named Help.
If not, right-click PerfectFit and select New > Key. Type Help and press (Enter).
Right-click on Help and select New > DWORD Value. Type Help Information
and press (Enter). Double-click Help Information, type 1, then click OK.

Now restart WPWin. Go to the dialog that has the control you want the named
region for. Press (Shift+F1). A question mark icon will appear. Click the
control you want the region name for. A Help Information dialog will
appear. This dialog has the named region of the item you clicked on. In the
case of the number of paragraphs control, the region name is
"WordPerfect.SummaryInfoPS.DocumentInformation.ParagraphNumStatic".

In this example, you'll also need the name of the Information tab. Press (Shift+F1),
and click on the tab to get the name.

The following WPWin macro uses the named regions to get the number of paragraphs
in the current document:


Application(A1; "WordPerfect"; default; "US")
InhibitInput(off!)
Display(off!)
InvokeDialog(DocInfoSummaryDlg)
CoachAnimate(Mouse!; "click on 
  WordPerfect.SummaryInfoPS.DocumentInfoTab")
Wait(5)   // increase this number if document is large
vParagraph:= RegionGetWindowText 
("WordPerfect.SummaryInfoPS.DocumentInformation.ParagraphNumStatic")
CoachAnimate(Keyboard!; "{Alt+C}")
MessageBox(status; "PSJournal"; 
"The number of paragraphs in the current document is "+vParagraph)
                   

Region names can come in handy in a pinch. You can find a printed list of
region names in the appendix of my book.

Next month: How to get multiple list items from a list

For more information on this topic, get a copy of my book.

For information on ordering my book see my web page.

Copyright Notice: The information included in the PerfectScript Journal is protected by US Copyright. The author grants you the right to use the routines in your own macros as needed. You may not sell, distribute, or publish them in any form.
If you choose to use the information here, you do so entirely at your own risk. No representations are made regarding the fitness of this information for your   particular purpose, or for your ability or inability to use the information. You   are advised to make backups of all relevant files before implementing any suggestion  or technique.
© Copyright 1998 by J. Jeppson.