Solved

How to deal with 02 READ EVENTS ?

Posted on 2011-02-16
26
1,369 Views
Last Modified: 2012-05-11
Hi Experts

I've recently started using
Improved Date and DateTime controls created using the calendar class

http://www.sweetpotatosoftware.com/spsblog/2005/08/20/VisualFoxProGridATipAndACalendarClass.aspx

advised by Olaf

If I run the form examplepickers.scx alone it runs  fine

But I'm facing a problem when I put it inside another screen that was fired under  application READ EVENTS since the class caldatepicker, cmdcalendar => click event has it's own READ EVENTS

this.Parent.PositionCalendar(oCalendar)
oCalendar.visible = .t.
BINDEVENT(thisform, "moved", this.Parent, "PositionCalendar")
READ EVENTS
UNBINDEVENTS(thisform, "moved", this.Parent, "PositionCalendar")

Open in new window


So (I guess) the 02 READ EVENTS conflicts one wich other and the calendar appear and disappear imediatelly. Tht's right ?


Any suggestion/ workaround ?

Thanks in advance
0
Comment
Question by:Eduardo Fuerte
  • 13
  • 11
  • 2
26 Comments
 
LVL 12

Expert Comment

by:jrbbldr
ID: 34911549
Since it is a Sweet Potato Software class, have you attempted to contact Craig Boyd (owner)?

You should be able to reach him at their posted 'contact us' address:   info@sweetpotatosoftware.com

Good Luck
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34912370
This is just a sample form, you don't need the READ EVENTS in there, as you already have your own.

Bye, Olaf.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34912376
Oh, plus I only advised to use this, if you really want to omit and avoid ActiveX, the MS control may not look that fancy, but is in fact a bit easier to use.

Bye, Olaf.
0
 

Author Comment

by:Eduardo Fuerte
ID: 34915192
Hello

I've posted them a mail.
My READ EVENTS is fired just below  menu and maybe couldn't be usable to this class purpose.
I'm considering another strategy too.
 
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34915467
I see now, why there is a read events. Well, it should work anyway, as long as you also copied over the moved method to your form.

Bye, Olaf.
0
 

Author Comment

by:Eduardo Fuerte
ID: 34915967
Hello

I'm not certain but what I need to do is:

1. I have to copy the CaldatePicker class on my form
2. Past the cmdCalendar click event code  (that has the READ EVENTS) to the form - how to do that ?
3.  Make the form's cmdCalendar click event code to be fired instead of the class script - how to do that ?
Could you please better detail this operation ?
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34916429
You have a BINDEVENTS() in that code, that binds the moved() event of the form to the moved() event of the calendar. So when you move the form that has the calender dropped down, the calender will also move. Which it wouldn't, as it's a separate form indeed.

Sorry, I don't have the time to experiment with that class and come up with instructions on how to use it.

Bye, Olaf.
0
 

Author Comment

by:Eduardo Fuerte
ID: 34917669
Ok...
I'm still struggling with this code...(little hope)
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34924151
okay, now I took the time and tested this, so far I can reproduce the problem:

a) make the exampledatepickers form nonmodal
b) put clear events in it's destroy
c) add a start.prg with:
   DO FORM examplepickers
   READ EVENTS

Now the read events within the command button of the picker does not halt execution, as a read events already is present.

I think you need to split that click method and put anything after the readevents to a new method.
then you bind the oCalendar.ReleasE() to that new method and execute the rest of the click there, which processes the picked value after the pick, that is after the release of the calendar form.

Bye, Olaf.
0
 

Author Comment

by:Eduardo Fuerte
ID: 34925303
Hello

I've done what you've suggest putting an auxiliar method at caldatepicker with the code originally just bellow  
 
oCalendar = CREATEOBJECT("calCalendar", dSelectedDate)
this.Parent.PositionCalendar(oCalendar)
oCalendar.visible = .t.

BINDEVENT(thisform, "moved", this.Parent, "PositionCalendar")
READ EVENTS


*!*	UNBINDEVENTS(thisform, "moved", this.Parent, "PositionCalendar")
*!*	*!*	IF dHoldDate != dSelectedDate
*!*		WITH this.parent
*!*			dHoldDate = .txtDate.Value
*!*			.txtDate.Value = dSelectedDate
*!*			.txtDate.refresh()
*!*			IF dHoldDate != dSelectedDate
*!*				this.parent.interactiveChange()
*!*			ENDIF
*!*		ENDWITH
*!*	*!*	ENDIF
*!*	oCalendar = NULL
*!*	RELEASE dSelectedDate, oCalendar

Open in new window

and so the other instructions

Put this code at the form's release method
 
thisform.caldatepicker1.auxiliar()

Open in new window


So the calendar appears OK

 Before [

But the problem is that the CLEAR EVENTS fired when the form is closed simply knocks down  the application

After
Something really cornered...

0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34929981
remove both the READ EVENTS from the click and the CLEAR EVENTS from the calendar form. A READ EVENTS does not halt, if another READ EVENTS is already active, there is no nesting like with transactions, so the CLEAR EVENTS of the calendar does clear the main applications READ EVENTS.

Bye, Olaf.
0
 

Author Comment

by:Eduardo Fuerte
ID: 34944586
Hello

I've just found another clear events in calcCalendar class and eliminated it., another problema arised (the date doesn't appear the first time and then is refreshed)

I'm stiil struggling to make things happing ....

0
 

Author Comment

by:Eduardo Fuerte
ID: 34945346
Hello

Since I've found another good solution...

http://www.abri.com/foxpro.html#cal

I'm giving up of this...
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 12

Expert Comment

by:jrbbldr
ID: 34946161
I am not familiar with the Abri Calendar that you reference, but by looking at the screen image shown at the link you provided, it doesn't look like it offers much more that the Microsoft DateTime Picker.

If it does offer more - then fine.
However if it does not offer more, then why not just go with the Microsoft object?  
It is readily available and it is easy to implement.

Good Luck
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34947148
Where did you found the other clear events? This should be replaced by calling your auxiliar method and then thisform.release().

A CLEAR EVENTS in any other position as Destroy() of the form would have caused the code after the READ EVENTS to run, indirectly closing the calendar form, so this is what you need to mimic.

Bye, Olaf.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34947188
..."A CLEAR EVENTS in any other position"...

Well, really in any position it causes continuation after READ EVENTS.

The destroy() only is special in that it only runs when the form.release() was already called and so the auxiliary method already ran.

Bye, Olaf.
0
 

Author Comment

by:Eduardo Fuerte
ID: 34950783
Hello

The other CLEAR READS was at:
oCalendar = CREATEOBJECT("calCalendar", dSelectedDate)

But, I do not think it's worth continuing with this class....
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34954604
Well, I got it to work with my recommendations. I dont find a second CLEAR EVENTS in the whole project than in calcalendar.Destroy(). If you found any other occurrence, that must have been done by you in your efforts to make it work.

starting from scratch, this is what I did:

calcalendar.Destroy()
comment out (or delete) the CLEAR EVENTS

calDatePicker.cmdCalendar.Click()
Local dHoldDate
Public dSelectedDate, oCalendar
oCalendar = Createobject("calCalendar", dSelectedDate)
This.Parent.PositionCalendar(oCalendar)
oCalendar.Visible = .T.
Bindevent(Thisform, "moved", This.Parent, "PositionCalendar")
Bindevent(oCalendar,"Release",This.Parent, "DatePicked")

Open in new window


Added a method DatePicked to the calCalendar class, code:
Unbindevents(Thisform, "moved", This, "PositionCalendar")
Unbindevents(oCalendar,"Release",This,"DatePicked")

With This
   dHoldDate = .txtDate.Value
   .txtDate.Value = dSelectedDate
   .txtDate.Refresh()
   If dHoldDate != dSelectedDate
      This.InteractiveChange()
   Endif
Endwith

oCalendar = Null
Release dSelectedDate, oCalendar

Open in new window


Of course the calDateTimePicker has the same design flaw and it's cmdCalendar must be amended the same way.

One more thing I did is set the examplepickers.scx form nonmodal, as you can't choose a date on the calendar as long as any other form is modal hindering the use of the calendar form.

Bye, Olaf.
0
 

Author Comment

by:Eduardo Fuerte
ID: 34954862
Hello

So I'm returning to correct the code.... and I'm going to return here later with a position.
0
 

Author Comment

by:Eduardo Fuerte
ID: 34955248
Hello

I've tryed your code from scratch code
Strange but the calCalendar.DatePicked I've added is never fired.
The calendar appears but the chosen day doesn't go to the textbox after choose.
Maybe something else is needed.
Thanks.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34959082
Have you done the Bindevent() in my code?
Bindevent(oCalendar,"Release",This.Parent, "DatePicked")

Open in new window

Where did you add the DatePicked Method?

Bye, Olaf.
0
 

Author Comment

by:Eduardo Fuerte
ID: 34960063
Hello

Please see the pictures to check if I've done the changes correctly.
 datepicked

Destroy
 clickimg-04-ee-230211.JPG
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34973133
Sorry,

DatePicked must be added to the calDatepicker class.

Bindevent(oCalendar,"Release",This.Parent, "DatePicked") tells you , that DatePIcked must go into "This.Parent" from the point of view of the calDatePicker.cmdCalendar button. And that is the calDatePicker, not the calCalender form.

Bye, Olaf.
0
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 34977842
Efuerte,

overall I'm sorry for pointing you in that direction. I just did take a look into the comments section of Craig's blog article. http://www.sweetpotatosoftware.com/spsblog/CommentView,guid,878c1b11-1770-405c-92ea-cdbe2c838dfa.aspx#commentstart

Others already had the same problem with the read events/clear events and he has amended the class in a comment on 1. October 2005. Wonder why Craig didn't also simply did change the download.

So maybe if it still not works for you now you start over again from scrach and use Craig's changes from that comment or choose something else as your calendar.

I'd suggest you close this thread with a refund closing request.

Bye, Olaf.
0
 

Author Closing Comment

by:Eduardo Fuerte
ID: 34978293
Hello Olaf

You've done a remakable assistance here and deserve the points.

I don't thing worthwile to still strugle with this class since I've found another very simple and good.....

Thanks for your efforts and honesty !
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 34984833
Thanks!

Bye, Olaf.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now