Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Force one form to deactivate/lose focus
Message
From
23/03/2024 18:15:14
 
 
To
21/03/2024 10:29:52
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01687751
Message ID:
01687768
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?

Uuuuuhhhmmm,
that calls up bad memories. Similar situation of interconnected forms, with the twist
of being a process already called up by OLE Linking and embedding.
Several other programmers had tried and failed, so they bribed me to take a few swings at it.

Ran into the same wall the others had and then circumvented the problem after getting
enough leeway from the stake holders ("it is important enough that a few ms
or screen glitches dont matter") and I recoded the total stuff into a single form always active
with containers of the 2 form controls in a pageframe and had 2 "display only" forms displayed
whenever the page of the pageframe switched - the whole form danced invisible and Height/Width chenging
to the other place and the "Displayonly" form showed the last data.

Got some flak for "paradigm switch" as I went from working on cursor fields to binding on
memory data objects - those cold then be reused by the pure display forms to show without
doing chin-ups on unsaved buffered data.

Since all other failed attempts had cost much more than my rewrites I had no problem selling
my solution to the stake holders with the promise to get faster init until next release than
the previous version... Some more "magic" allowed loading all those forms
in background without adding to startup time and the actual switch was fast enough not to be noticed,
as I always had "correct" show only forms first.

Think of it as 1 single biz object getting data from always active form and displaying/mirroring
same info in different locations screen.

Clearly not a SOLUTION for your problem, only CIRCUMVENTION.

HTH IAC
thomas
Previous
Reply
Map
View

Click here to load this message in the networking platform