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

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
  2. PowerBuilder
  3. # Permalink
1
Votes
Undo

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
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. Tom Peters
  2. Tuesday, 21 August 2018 18:44 PM
There are no comments made yet.
Tom Peters Accepted Answer Pending Moderation
  1. Tuesday, 21 August 2018 18:42 PM
  2. PowerBuilder
  3. # 1
0
Votes
Undo

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
  2. PowerBuilder
  3. # 2
0
Votes
Undo

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
  2. PowerBuilder
  3. # 3
0
Votes
Undo

Maybe the deactivate of the window/frame?

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

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
I have the same question! Any answers in the meantime?

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

How you try making the Window Type: Response!.

Comment
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.