AppToolbar control from a different thread

Return to Introduction  Previous page  Next page

It is possible to control the AppFrame PowerToolbar from any thread in your application. In this tutorial you will be taken through the steps needed.

 

The finished application for this tutorial can be found at: Clarion6\3rdParty\Examples\PowerToolbar\AppToolbarTutorial.app

 

threadtut_11

threadtut_12

 

 

Part 1 - Populate templates

Onestep Create a new application

 

threadtut_1

 

Onestep Add the global PowerToolbar template

See Adding the templates

 

Onestep Go to the "Advanced" tab

Bullet On the advanced tab of the global template, make sure "Support AppFrame-Toolbar from other threads" is checked.

 

threadtut_2

 

Bullet Notice the Object name (AppToolbar). This is what we will refer to in our code later on.

Bullet Click "Ok" twice to get back to the Application Tree.

 

Onestep Add AppFrame

Bullet Double-click the Main(Todo) procedure to bring up the "Select Procedure Type" dialog.

Bullet Select "Frame - Multiple Document Main Menu"

 

threadtut_3

 

Onestep Create the window

Bullet Click the Window button

Bullet Select "Application Main MDI Frame" and click OK. This will bring up the window formatter.

 

threadtut_4

 

Onestep Delete the menubar (We do not want a menu for this tutorial)

Bullet Select the menu-item "Menu -> Delete Menu"

 

Onestep Create the toolbar

Bullet Select the menu-item "Toolbar -> New Toolbar"

 

Onestep Populate PowerToolbar control

Bullet Click the "Control Template" toolbutton

    tplbutton

 

Bullet Choose the template "POToolbar - Toolbar Control"

   addtpl_c1_75pst

 

Bullet Click somewhere inside the Clarion toolbar or Window to place the PowerToolbar-control.

 

 

Part 2 - Toolbar settings

Onestep Right-click PowerToolbar control, and select "Actions"

 

Onestep Select the "Advanced" tab

Bullet Notice "ID-Filename". All ID's for this toolbar will be exported to this file. You will need to select this file in the MDI Client template later in this tutorial.

Bullet "Object name" must be the same as global template setting.

 

threadtut_4_1

 

Onestep Add a band

Bullet Select the "Bands"-tab

Bullet Click the "Insert"-button

Bullet As "Name", type "Tutorial"

 

threadtut_5

 

Onestep Add a button

Bullet Click the "Insert"-button

Bullet Type "Button 1" in the Name field.

 

threadtut_6

 

Onestep Set button action

Bullet Select the "Actions"-tab

Bullet As "Action" select "Call a Procedure"

Bullet Enter "TestWindow" as procedure name

Bullet Check the "Initiate thread" checkbox

 

threadtut_7

 

Bullet Click OK three times to get back to the window formatter

Bullet Save and exit the window

 

Onestep Compile the application

Bullet You must do this to generate the ID-file (AppToolbarTutorial1.id)

 

 

Part 3 - Set up Test window

Onestep Create the window

Bullet Double-click the "TestWindow (ToDo)"-procedure

Bullet Select "Window - Generic Window Handler"

 

threadtut_8

 

Bullet Click the "Window button"

Bullet Select "MDI Child Window"

 

Onestep Save and exit the window formatter

 

Onestep Add the MDI-template

Bullet Click the "Extensions"-button

Bullet Click "Insert"

Bullet Select "PowerToolbarMDIClient - PowerToolbar MDI Client"

threadtut_8_1

 

Onestep Set up the template

Bullet Click the "..." button next to the ID-file prompt.

Bullet Select the "AppToolbarTutorial1.id"-file. This is the file generated by the toolbar-control i the AppFrame.

 

threadtut_8_2

 

Onestep Click the "Advanced"-tab

Bullet Notice "AppFame Toolbar". This is the object name that we saw in both the global template, and the AppFrame toolbar-control.

 

threadtut_8_3

 

Onestep Click OK to get back to the Procedure Properties window.

 

Onestep Click the "Window" button to get to the window formatter.

 

Onestep Place a button on the window

Bullet Make sure "Use" is ?Button1

 

Onestep Code some actions for the toolbar

Bullet Select the "Actions"-tab

Bullet Click the embed button

Bullet Double click "Control Events -> ?Button1 -> Accepted -> Generated Code"

 

threadtut_10

Bullet Select "Source" as Embed type

 

Onestep Enter code to manipulate the toolbar

Bullet AppToolbar is a global object which you can use to control the appframe-toolbar

Bullet The various AppToolbar methods is described here

 

Bullet Enter the following code into the source editor

 

!Manipulate AppFrame toolbar button

 

!Enable/Disable

If AppToolbar.GetEnabled(ID1_Button1)               !Check if button is enabled

   AppToolbar.SetEnabled(ID1_Button1, False)       !Disable button

Else

   AppToolbar.SetEnabled(ID1_Button1, True)        !Enable button

End

 

!Change text

If AppToolbar.GetText(ID1_Button1) = 'Button 1'     !Get button text

   AppToolbar.SetText(ID1_Button1, 'Hello world!') !Set new text

Else

   AppToolbar.SetText(ID1_Button1, 'Button 1')     !Set back to default text

End

 

Bullet Save and exit the source editor

 

 

Part 4 - Test the application

Onestep Compile and run the application.

Bullet Click "Button 1" in the toolbar to open our test-window.

Bullet Click "Button 1" in the test-window and observe what happens to the toolbar button.

 

threadtut_11

threadtut_12

 



Direct link to this page on our website: http://www.icetips.com/manuals/powertoolbar/toolbarcontrolfromseveralt.htm