Ask Dr. DePhobia - Questions and Answers about Clarion

by Jim DeFabia

Published 1998-01-01    Printer-friendly version

Download the code here

Q:

I like the new wallpaper feature in Clarion 4, especially the ability to add wallpaper to the client area of an Application Frame. There are times, however, when I don't want an image in the frame's client area but want to specify a color. Can this feature be added in the future?

A:

Why wait for the future? I can help you in the present. You can "colorize" the client area of a frame by merely adding a single color graphic as the Frame's wallpaper and using the STRETCHED attribute to fill the client area with the image.

Q:

I like the new Flat buttons in Clarion 4, but I want to use them for buttons without an icon. Is this possible?

A:

Yes. To utilize the FLAT attribute, you must specify an ICON attribute. This attribute can, however, be a blank icon or use the EQUATE--ICON:None. In other words, you can have a text button which supports the extended features. These features include colorization of fonts and the FLAT attribute.

If you specify No Icon in the Window Formatter, the generated code omits the ICON attribute. To add the ICON:None equate to the ICON attribute, you must edit the WINDOW structure as source using the ellipsis (...) button from the Procedure Properties window. Locate the BUTTON declaration and add ICON(ICON:None) to the declaration.

Speaking of the new FLAT attribute on a BUTTON, there is one other trick you can use to spruce up your applications. If you use a GIF for the ICON, you get an image that is gray-scaled when inactive and in full living color when activated by hovering the mouse over it. In addition, if you use an animated GIF as the ICON for a button, you get animation only when the mouse is over the button. Using this technique, you can make your buttons really come alive when the mouse awakens them!

Q:

I have an application that needs two different ways to update records in a Browse Box. For simple edits, Edit-in-Place will suffice. For adds and more detailed updates, I need an Update Form. Is there an easy way to accomplish this?

A:

Yes, it's as simple as A-B-C, now that we have the ABC templates.

Seriously, this was something that was frequently needed, but wasn't really easy to do -until now! The technique I will explain shows one of the reasons the Application Builder Class Templates are so "kewl."

First, let's examine what a Browse Procedure does when the user calls for an update. It calls a method named something like BRW1.ThisWindow.Run. The method takes a number as a parameter. This number is the value of the BRW1.AskProcedure property.

In other words, if you enable Edit-In-Place and specify an update procedure, you have two-thirds of your work done. Set the BRW1.AskProcedure Property to 0 (zero) and you have Edit-in-Place; Set it to 1 (One) and you call your update procedure.

Let's make this change in a small application. For purposes of this exercise, we'll use the example - People.APP in the Clarion4\Examples\Reports directory. Before we begin, let's rename it to People2.APP. Open the application and follow the steps below.

Let's walk through the steps:

  1. Select the BrowsePeople procedure, and press the Properties button.
  2. In the UpdateButton section of the Procedure Properties window, check the Use Edit in Place box. Notice that an update procedure is already specified. Make sure to leave that procedure named!
  3. Embed the code to set the default update action to call the form. In the Window Manager Method - Init - BYTE() embed point embed the following code. Leave the Priority set to Default (4000).
BRW1:AskProcedure = 1
  1. Embed the code to set the action of a double-click to use edit-in-place. In the Browser Method Executable Code Section- Browse on People using BrowseClass - TakeKey-BYTE() embed point embed the following code:
IF RECORDS(SELF.ListQueue) AND KEYCODE() = MouseLeft2
  BRW1.AskProcedure=0
END
  1. Set the Priority to First. This specifies that it should precede the generated code.

0198ss1.gif

  1. Finally, we will embed the code to set the action back after an edit (either from a form or from an edit-in-place. In the Browser Method Executable Code Section- Browse on People using BrowseClass - ASK-BYTE(request), BYTE embed point embed the following code:
BRW1.AskProcedure = 1

This is important. It ensures the value is the same as when you started. I like to think of this type of code as "If you turn the light on when you enter a room, be sure to turn it off when you leave."

  1. Set the Priority to Last. This specifies that it should follow the generated code.
  2. Compile and run the application. Call the browse procedure and notice the behavior-a double-click gets you edit-in-place and any other method of calling an update gets you the form.

More fun with the AskProcedure property

That gives us two alternatives. However, the ABC templates allow us to add more possibilities easily. We know that the AskProcedure property can have a value of 0 or 1. What if we want more possibilities?

Let's look at the second ThisWindow.Run PROCEDURE (the one with two parameters). Notice it takes a USHORT parameter named Number and a BYTE named Request). The number parameter it receives is the value of the AskProcedure. With this knowledge, we can add a third "update" procedure-this one a record viewer instead of a record update procedure.

  1. First create a procedure using the Window Template, define the WINDOW as an MDI child, and populate all the fields as STRING controls. Let's call the procedure-ViewPeople.
  2. Select the BrowsePeople procedure and Press Properties.
  3. Press the Procedures button and select the ViewPeople procedure. This adds the procedure to the local MAP.
  4. Next, we will add a few buttons the window. Press the Window Button to call the Window Formatter.
  5. Populate a button with the following properties:
  6. Text: 'View'
    USE: ?ViewButton
  7. Double-click on the button (&View) and embed the following code in the Accepted Embed point. Leave the Priority set to Default (4000).
  8. BRW1.AskProcedure = 2 POST(Event:Accepted,?Change:2)
  9. Now to get the multiple procedures to work, we are going to modify the ThisWindow.Run method. Let's use the Embeditor for this one.
  10. Close the Window Formatter and the Procedure Properties window, right-click on the BrowsePeople procedure and select Source.
  11. Locate the second ThisWindow.Run PROCEDURE. This is the one with the parameters.

Let's examine the code:

ThisWindow.Run  PROCEDURE(USHORT Number,BYTE Request)
ReturnValue     BYTE,AUTO
! Start of "WindowManager Method Data Section"
! [Priority 5000]
! End of "WindowManager Method Data Section"
  CODE
! Start of "WindowManager Method Executable Code Section"
! [Priority 2500]
  ReturnValue = PARENT.Run(Number,Request)
! [Priority 6000]
  GlobalRequest = Request
  Updatepeople
  ReturnValue = GlobalResponse
! [Priority 8500]
! End of "WindowManager Method Executable Code Section"
  RETURN ReturnValue

Now let's modify it so it looks like this:

ThisWindow.Run  PROCEDURE(USHORT Number,BYTE Request)
ReturnValue     BYTE,AUTO
! Start of "WindowManager Method Data Section"
! [Priority 5000]
! End of "WindowManager Method Data Section"
  CODE
! Start of "WindowManager Method Executable Code Section"
! [Priority 2500]
  ReturnValue = PARENT.Run(Number,Request)
! [Priority 6000]
 GlobalRequest = Request
  EXECUTE Number
    Updatepeople
    Viewpeople
  END
  ReturnValue = GlobalResponse
  RETURN ReturnValue
  !next 4 lines of code never execute
  GlobalRequest = Request
  Updatepeople
  ReturnValue = GlobalResponse
! [Priority 8500]
! End of "WindowManager Method Executable Code Section"
  RETURN ReturnValue

This now allows us to have an alternate update procedure! Using this technique, you can have as many possible update procedures as you want. You can imagine the possibilities:

  • different procedures for different users
  • different procedures for different security levels
  • different procedures based on whether an application is running locally or over the Internet using Clarion Internet Connect
  • the possibilities are endless!

This completed application is available for download. The application shows some additional buttons.

Printer-friendly version

 
 

Search

 

Advanced Search
Topical Index

Related Articles

Subscribe to
ClarionMag

One year: $189

(includes all back issues since '99)

Renewals from $139

Two years: $289

Renewals from $239

More Info

Subscribe Now!

ClarionMag Blog

RSS Feeds

Updates via Email

Enter your Email


Powered by FeedBlitz

Quick Links