Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Force one form to deactivate/lose focus
Message
From
22/03/2024 06:34:29
 
 
To
21/03/2024 14:32:53
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01687751
Message ID:
01687764
Views:
36
>>>I have a pair of forms that are related (in a parent/child kind of way). There's code in my framework so that if I move the record pointer in the parent form, the child form moves to the corresponding record. That's all working.
>>>
>>>This application allows only one form to be in edit mode at a time, so there's framework code in the main data entry form class's Deactivate method that checks whether the form being deactivated is in edit mode and if so, prompts the user to either cancel the edit or stay on the current form.
>>>
>>>What I'm working on now is having a textbox on each form where the user can scan a barcode and it will position the parent form on the record indicated by the barcode and then open or position the child form on the corresponding record in edit mode. That is, if the child form is not open, open it; otherwise, just reposition. But in either case, switch to edit mode.
>>>
>>>The scan textbox on the parent form is working as I need it to, but the one on the child form is resulting in that message about having to either cancel the edit or stay put. What's happening is that to do what we need, we have to refresh the parent form (which then allows us to update the child form using a custom method).
>>>
>>>The problem is that having done so, the parent form has focus, and I can't find a way to force it to deactivate and hand focus over to the child form before I switch the child form into edit mode. I've tried using ACTIVATE WINDOW and setting focus to a control on the child form and doing both, and I still see that the parent form's Deactivate method doesn't fire until after the code that changes the child form's mode.
>>>
>>>So I'm looking for a surefire way to have the parent form's deactivate run when I want it to (other than closing the parent form). Any ideas?
>>>
>>>Tamar
>>
>>
>>How about to set focus on some control in Child form?
>
>As I said, I tried that and the parent form is still the active form afterward.
>
>Also, one clarification. Turns out my code fails when the child form is already open whether we're doing it in the parent form or the child form. (That actually makes more sense to me. DOing the form gives it focus, so when the form isn't open, it all works.)
>
>Thanks,
>Tamar
>
>Hi Tamar,
>
>I kinda had the same problem with two mutually exclusive forms and their respective toolbar buttons. I couldn't get the opposing form's button to stay disabled while the other form was open, so I used a background timer that constantly sets the unopened form's button.enabled to .f. while the other form is open.
>

Thanks. I'm not sure how that would help in this case.

Tamar
Previous
Reply
Map
View

Click here to load this message in the networking platform