Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What embed fires after a pop-up calendar is closed? 1

Status
Not open for further replies.

rleiman

Programmer
May 3, 2006
258
US
Hi Everyone,

I set up a pop-up calendar through the calender button template on one of my forms.

Can you tell me what embed fires after the user clicks ok or cancel on the pop-up calendar.

Thanks.

Emad
 
Hi rleiman,

I opened an example app and added a calender control for you.

I found the following code
!=====================================================
CASE ACCEPTED()
!..... <many lines here, for other controls>
OF ?Calendar
ThisWindow.Update
! Start of "Control Event Handling"
Calendar6.SelectOnClose = True
Calendar6.Ask('Select a Date')
!<embed point>
IF Calendar6.Response = RequestCompleted THEN
END
ThisWindow.Reset(True)
!<embed point>
!=====================================================
So you can use either of the two !<embed point>s
Or you could derive Calendar6.Ask, and check the SELF.Response AFTER the parent call

HTH,
Mark Goldberg

 
Hi Mark,

Thanks for the help!

I will look for the code and points you found in my source code.

I was woundering since I never did any deriving. How does it work and how would I use it with the SELF.Response statement?

Truly,
Emad
 
Hi Emad,

You're welcome, my pleasure.

You can derive a couple of ways.
a) The simplest way is to use the embed points to add content within the Calender6.Ask method. If you look at the generated code. You'll see that Calender6 is itself derived from a CalenderClass
Calendar6 CLASS(CalendarClass)

When you add code to one (or more) of the embed points inside of a method, the generated code will add the derived method to your procedure, when it's not present then it's implied that it's JUST the Parent version of the method.

Looking at the embeditor it's apparent to me that the Calender Button Template is not as written as it should be (I had similar feelings when I looked at the source code for CalendarClass found in %cwroot%\libsrc\abutil.clw). The template does not genearte a call to the parent for you, so you will want to add the call to the parent:

ReturnValue = PARENT.Ask(pTitle, pDate)
IF SELF.Response = RequestCompleted
!OK was pressed
ELSE
!Cancel or ESC etc. occurred
END



b) If you know you're going to need the same changes a number of times, then you should consider writting an .INC / .CLW for the class (which is NOT as hard as you might guess -- I write them ALL the time, let me know if you'd like to learn how to write one) Then once you have this new version of the class, you will want to put it the %cwroot%\LIBSRC folder, and press the "Refresh Application Builder Class Information" button in the the IDE, once that's done you will want to replace the CalenderClass as the Base Class.

OK, step by step.
a) get to the window formatter
b) Add your calendar button template control
c) Open the properties for the control
d) Classes Tab
e) Uncheck "Use Default ABC: CalendarClass
f) Notice the the Base Class Drop Down is now enabled
g) Pick your new class from the Base Class drop down
(that's why you had to refresh, to get your class added to this list)
h) If you new class isn't in the Base Class drop down list, then press, Refresh Application Builder Class Information. And look again.
i) Hit OK a few times.

Note: If you want to use your version of the class throughout your APP, then you should instead to go to the application's global properties, and select you new Class from via the Classes tab. This will alter you the class that a given object is derived from throughout the APP.

For instance, if you wished to replace WindowManager with MyNewAndImproved_WindowManager then you could make the change once at the global level.

Then the generated code would show:
ThisWindow CLASS(MyNewAndImproved_WindowManager) !etc.

Instead of the familiar:
ThisWindow CLASS(WindowManager) !etc.

Replacing the default class at the APP global level is one of the most powerful and CLEAN ways to alter an application. It has the absolute minimal bloat, and gives you the greatest consistency for the least effort.

Getting back to the CalendarClass, you can set the DEFAULT class on Global Properties -> Classes Tab -> General Button -> see "Calendar Class" at the bottom of that window


HTH,
Mark
 
Hi Mark,

Thank you for the lesson.

I will try that sometime in the future.

It is greatly appreciated.

Truly,
Emad
 
Hi Mark,

Located the embeds and use the last one of them listed and it works great. I was able to use the date returned.

Thanks!

Truly,
Emad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top