I've created a date-combo class as per the instructions in Hetzenwerke's 1001 Things You Wanted to Know About VFP (if you don't have the book, it's pretty basic, a text box, a command button, a calendar control. You can type into the text box, or click the command button to bring up the calendar. double clicking on the calendar fills the text box with the chosen date. I've enhanced it some, but the basis is the same)
The thing is that if you type an invalid date into the text box, I want to avoid the trouble-causing "Invalid date" system message. So I put in a "On ReadError..." and called a procedure to put up a small messagebox and then "keyboard Esc" to revert to the previous value.
Works like a charm.
Now, I've gotten too clever by far and decided that some users will start to type in a date, then try to use the command button to bring up the calendar. This also invokes the messagebox, reverts the textbox, etc. I don't want this to happen.
I've put in a custom property of the class (showmsg) which is set to .t. everywhere except in the MouseMove() event of the command control. So when the user hovers over the button as he's about to click it, showmsg is set to false. I then changed the procedure called by On ReadError to receive showmsg as a paremeter and show the message if true, don't if false. Simple.
However, I can't pass the showmsg property to this procedure
I've tried
On ReadError Do DateError With This.Parent.ShowMsg (in the gotfocus event of the textbox control)
but "This" is only allowed with a method. I also tried putting This.Parent.ShowMsg into a variable and passing that. But that variable's state (.T. or .F.) is only set in the gotfocus event, and so wouldn't be consistent with the ShowMsg property of the class.
At this point, I'm considering a public variable throughout the class, rather than ShowMsg property, which would probably work fine, but I'd like to know for future reference, how would you do this sort of a thing.
[Apologies for the length of this post]
The thing is that if you type an invalid date into the text box, I want to avoid the trouble-causing "Invalid date" system message. So I put in a "On ReadError..." and called a procedure to put up a small messagebox and then "keyboard Esc" to revert to the previous value.
Works like a charm.
Now, I've gotten too clever by far and decided that some users will start to type in a date, then try to use the command button to bring up the calendar. This also invokes the messagebox, reverts the textbox, etc. I don't want this to happen.
I've put in a custom property of the class (showmsg) which is set to .t. everywhere except in the MouseMove() event of the command control. So when the user hovers over the button as he's about to click it, showmsg is set to false. I then changed the procedure called by On ReadError to receive showmsg as a paremeter and show the message if true, don't if false. Simple.
However, I can't pass the showmsg property to this procedure
I've tried
On ReadError Do DateError With This.Parent.ShowMsg (in the gotfocus event of the textbox control)
but "This" is only allowed with a method. I also tried putting This.Parent.ShowMsg into a variable and passing that. But that variable's state (.T. or .F.) is only set in the gotfocus event, and so wouldn't be consistent with the ShowMsg property of the class.
At this point, I'm considering a public variable throughout the class, rather than ShowMsg property, which would probably work fine, but I'd like to know for future reference, how would you do this sort of a thing.
[Apologies for the length of this post]