1. Tom Peters
  2. PowerBuilder
  3. Thursday, 16 August 2018 14:56 PM UTC

Good Day!

Using PB 2017 R3

I am employing a shared object NVO for a window wherein I display the status of a long-running process. Everything works, beautifully, and the application never freezes because of this approach.

The issue, however, is that the window opened by the shared NVO never goes out of focus, even if I switch to another application. Here's why...

In order for my status window to stay on top, I am using SetPosition( TopMost! ). If I do not, then when I switch from my app to another then back to my app, my status window is lost forever. I have tried setting an instance variable in my NVO and then setting SetPosition( TopMost! ) and SetPosition( NoTopMost! ), WindowState = Normal! and WindowState = Minimized!, accordingly.

My biggest problem is getting a way to know when my application is minimized or the user switches to another application.

I have tried all of the following in my MDI frame and my parent sheet (as appropriate):

  • pbm_mdiactivate
  • activate
  • deactivate
  • resize

Bottom line, I cannot figure out a way to know when my PowerBuilder application is not what the user is currently viewing. Is there a way to catch when the user minimizes my application or switches to another application? Again, none of the events listed above seem to work for me.

Thanks,

Tom

Accepted Answer
Ricardo Colarina Accepted Answer Pending Moderation
  1. Tuesday, 21 August 2018 05:18 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Tom,

In the deactivate event, post a user event.  In the user event, call Windows API GetWindowText which will return the window title of the application that became active.  Use GetForegroundWindow to get the handle to use in GetWindowText.  If the title returned by GetWindowText is not the same as your PowerBuilder application frame's title (assuming you're using a frame), then the application that just became active is not YOUR PowerBuilder application.

Hope this helps.

Best Regards,

Ricardo

Comment
  1. Tom Peters
  2. Tuesday, 21 August 2018 18:44 PM UTC
Thank you, very much. GetForegroundWindow was the key! The PFC already had of_GetWindowText( handle), so I added the external function definition for GetForegroundWindow and wrote code to compare the texts. Brilliant! It works, beautifully.
  1. Helpful
There are no comments made yet.
Tom Peters Accepted Answer Pending Moderation
  1. Tuesday, 21 August 2018 18:42 PM UTC
  2. PowerBuilder
  3. # 1

Thanks. The issue wasn't that I couldn't switch to other applications, but that I couldn't capture when my application was no longer in focus. I did add the Yield( ) though, as part of the solution. Thanks!

Comment
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Tuesday, 21 August 2018 13:07 PM UTC
  2. PowerBuilder
  3. # 2

If my understanding is right, you could put

Yield ()

while displaying the status and allow user to switch to other applications.   When they come back to this application, the status will be showing the right value.

Hope the process is in a loop.

Happiness Always
BKR Sivaprakash

 

Comment
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Thursday, 16 August 2018 21:37 PM UTC
  2. PowerBuilder
  3. # 3

Maybe the deactivate of the window/frame?

Comment
  1. Kevin Ridley
  2. Thursday, 16 August 2018 21:40 PM UTC
Sorry I missed where you said you tried that already.
  1. Helpful
There are no comments made yet.
Tom Peters Accepted Answer Pending Moderation
  1. Thursday, 16 August 2018 16:54 PM UTC
  2. PowerBuilder
  3. # 4

Yes, thanks... I can get the window to minimize. I just need a way to know when the user has:

  1. Switched from my application to another OR
  2. Minimized the application

Thanks!

Comment
  1. alessandro feltrin
  2. Monday, 5 November 2018 19:42 PM UTC
I have the same question! Any answers in the meantime?

Thanks!
  1. Helpful
  1. Tom Peters
  2. Tuesday, 6 November 2018 13:24 PM UTC
I used Ricardo's suggestion. See the accepted answer, above. It works beautifully.
  1. Helpful
There are no comments made yet.
Clarence Chamorro Accepted Answer Pending Moderation
  1. Thursday, 16 August 2018 16:45 PM UTC
  2. PowerBuilder
  3. # 5

How you try making the Window Type: Response!.

Comment
  1. Victor Farias
  2. Wednesday, 20 January 2021 01:01 AM UTC


Please help, when generating Excel with Dw2Xls from PowerBuilder 2019R2, it loses the focus of the window, my application is compiled for web, Thank you very much.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 20 January 2021 05:47 AM UTC
Probably that's because a "progress" window is popping up, indicating how much of the save has been done.

Maybe you should post this as a separate question.

Regards.
  1. Helpful
  1. John Fauss
  2. Wednesday, 20 January 2021 05:49 AM UTC
Hello, Victor -

Hijacking an existing question/issue is not the proper way to request assistance. Please post your request in a new thread. It will have much better visibility to the Community.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.