• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1401
  • Last Modified:

How to deal with 02 READ EVENTS ?

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
Eduardo Fuerte
Asked:
Eduardo Fuerte
  • 13
  • 11
  • 2
1 Solution
 
jrbbldrCommented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
This is just a sample form, you don't need the READ EVENTS in there, as you already have your own.

Bye, Olaf.
0
 
Olaf DoschkeSoftware DeveloperCommented:
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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Eduardo FuerteAuthor Commented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Eduardo FuerteAuthor Commented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Eduardo FuerteAuthor Commented:
Ok...
I'm still struggling with this code...(little hope)
0
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Eduardo FuerteAuthor Commented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Eduardo FuerteAuthor Commented:
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
 
Eduardo FuerteAuthor Commented:
Hello

Since I've found another good solution...

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

I'm giving up of this...
0
 
jrbbldrCommented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
..."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
 
Eduardo FuerteAuthor Commented:
Hello

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

But, I do not think it's worth continuing with this class....
0
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Eduardo FuerteAuthor Commented:
Hello

So I'm returning to correct the code.... and I'm going to return here later with a position.
0
 
Eduardo FuerteAuthor Commented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Eduardo FuerteAuthor Commented:
Hello

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

Destroy
 clickimg-04-ee-230211.JPG
0
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
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
 
Eduardo FuerteAuthor Commented:
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
 
Olaf DoschkeSoftware DeveloperCommented:
Thanks!

Bye, Olaf.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 13
  • 11
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now