Hiding a window while a started process runs: the LoseFocus and GainFocus embeds are not always called

Applies to: the poster wrote "C55d ABC"; posted in the Clarion 5.5 EE group.

Problem

A procedure may START one of several process procedures. The poster wanted to hide his window before the process starts and unhide it on return, using the EVENT:LoseFocus and EVENT:GainFocus embeds (WindowManager.TakeWindowEvent). In the debugger the code was not always reached. The first time a process started, the hide in LoseFocus was not called but the unhide in GainFocus was. The second time, the hide ran and the unhide did not.

Solution

  1. Have the started procedure do the hiding for its parent. Pass the parent's thread number to the started procedure, then in it:
SETTARGET(,ParentThread)
0{PROP:Hide} = TRUE
SETTARGET
DO YourProcess
SETTARGET(,ParentThread)
0{PROP:Hide} = FALSE
SETTARGET
  1. Or register a method with the runtime (global equates and the REGISTER function) and POST events from the process procedure to the parent.
  2. The original poster did something similar: a thread manager class that posts to the parent thread. He also learned that a parent whose window is hidden gets no events posted when execution returns from the child.

Caveats

  • This explains only part of what he saw; he wrote that it got him back on track.
  • The thread did not say whether the first suggestion was tried.

Today (2026)

Not re-tested. Hiding and unhiding a window from another thread through SETTARGET is plain language behaviour, so it likely still works; re-test the event behaviour on your build.

Sources: Douglas J. (Jul 2002, the question), Jeff S., Dennis E. (Jul 2002) in softvelocity.products.c55ee.