Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Adding a dialog: Part II

Basic Functions : FIXED | Paste Special II - Removing formulae | Secret StarWars games | Using Names as constants | Listing Cell Notes | Checkerboard shading | Using Pop Up Notes in Cells | Macros: Text Utilities Part I | Filling a multiplication chart | Spelling out numbers |


Читайте также:
  1. Adding a background graphic
  2. Adding a dialog: Part I

September 9th, 2005

In the first part of this series of articles, we developed some macros for basic string manipulation on a selected range of cells. We also created a new menu item for easy invocation of these macros.

 

In the second part, we developed a dialog to allow the user to select from a list of functions.

We will now integrate the enhanced menu, the new dialog and our new functions.

Each radio button in our dialog was given a name. They were UpperCButton, LowerCButton and ProperCButton.
Another key property associated with radio buttons is the State property which has a value of 1 if the button is checked, 0 otherwise. The default state value is 0. In our dialog, we would like to have the ProperC button selected on startup - so we set the state value as shown below..

There are no Events associated with the radio buttons. The other components/controls of the dialog will be able to query the state of each button as we shall see in the code. The subroutines listed below - RunTextUtilsDlg and ExitTextUtilsDlg will be associated with the Run and Exit command buttons. We link the macros and command buttons via the events dialog of each component as shown below. Be careful to choose the correct event type when doing the mapping.

In the dialog editor, select the button to which we wish to assign a macro. Select the Events tab. For a button control, we want to map the macro to the Mouse button pressed event. Invoke the Assign Macro dialog as shown below.

Making sure the corrct event is selected, invoke the Macro Selector as shown below.

With the macro selected,click OK to complete the macro assignment/mapping.

Here is the additonal macro code required to complete the integration. Note the mechanism by which we query the state of each radio button.

Dim oTextUtilsDlg

Sub RunTextUtilsDlg
Dim oLib
Dim oLibDlg

DialogLibraries.loadLibrary(”Standard”)

oLib = DialogLibraries.getByName(”Standard”)

oLibDlg = oLib.getByName(”TextUtils”)

oTextUtilsDlg = CreateUnoDialog(oLibDlg)

oTextUtilsDlg.execute

End Sub

Sub ExitTextUtilsDlg
oTextUtilsDlg.endExecute()
End Sub

Sub TextUtils
‘Print oTextUtilsDlg.getModel().getByName(”UpperCButton”).State
If oTextUtilsDlg.getModel().getByName(”UpperCButton”).State = 1 Then
Call UpperC
ElseIf oTextUtilsDlg.getModel().getByName(”LowerCButton”).State = 1 Then
Call LowerC
ElseIf oTextUtilsDlg.getModel().getByName(”ProperCButton”).State = 1 Then
Call ProperC
End If
End Sub

Asa final step, we customize our menu to provide a single point of entry to the TextUtils dialog via the RunTextUtilsDlg macro.

Please note that this is just one possible way of implementing the new Calc functionality we have introduced in this series of tips.

Here is the example we have just worked through for you to
download.

Posted in OpenOffice Basic | No Comments»


Дата добавления: 2015-08-03; просмотров: 58 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Adding a dialog: Part I| Formatting ratios

mybiblioteka.su - 2015-2024 год. (0.006 сек.)