Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Commandbutton Click Doesn't Fire After Textbox Validatio
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00786042
Message ID:
00787157
Views:
22
Try what I provided in a plain empty form with just a command button with the code. It worked for me in VFP6/SP5 just fine, first and everytime, no exceptions. Sounds like you've got some other code preventing it from working in one of your classes.


>Thanks. But for some reason (probably some code I have somewhere in my base classes) I couldn't your code to work. I tried moving the Click code you suggested to the GotFocus method and calling the Click event if MouseUse=.t.. This works but not the first time you are in the form. After you try it once (and it fails) it works every time after. (I am using VFP6 SP5).
>
>I was able to add code to the form's Activate event:
>
> IF TYPE('thisform.ActiveControl.Name')='C' AND ;
> thisform.ActiveControl=thisform.cmd1
> thisform.cmd1.Click()
> ENDIF
>
>Since the form was losing focus, when the user left the MESSAGEBGOX() the form's Activate event fired and I just had to check for the focus being on the commandbutton.
>
>This isn't ideal but I cant think of any situation in my form for which I would not want this to happen.
>
>I would rather use your method, but I can't get it to work the first time I click on the commandbutton.
>
>I created a new form using the default VFP classes for the form and objects. I added a textbox and a commandbutton and put a MESSAGEBOX() command in the textbox Valid and the following code in the commandbutton.
>
>Here's the code I ended up using. It works except the first time I start the form.
>
>*Init
> this.AddProperty("MouseUsed")
> this.MouseUsed = .f.
>
>*MouseDown
> LPARAMETERS nButton, nShift, nXCoord, nYCoord
> IF nButton=1
> this.MouseUsed = .T.
> ENDIF
>
>*GotFocus
> IF this.MouseUsed
> this.MouseUsed = .f.
> this.Click()
> ENDIF
>
>*Click
> MESSAGEBOX("in commandbutton.click")
> this.MouseUsed = .f.
>
>
>>
>>Here's the code I just tried and it worked (all in the command button):
>>
>>*Init
>>this.AddProperty("MouseUsed")
>>
>>*MouseDown
>>LPARAMETERS nButton, nShift, nXCoord, nYCoord
>>IF nButton=1
>>  this.MouseUsed = .T.
>>ENDIF
>>
>>*Click
>>IF this.MouseUsed
>>  this.MouseUsed = .f.
>>  WAIT WINDOW "mouse Clicked"
>>ELSE
>>  WAIT WINDOW "keyboard Clicked"
>>ENDIF
>>
>>
>>The MDOWN() wouldn't work because a "Click" doesn't happen until the mouse is released. Sorry about that.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform