1. Mario Parietti
  2. PowerBuilder
  3. Friday, 27 November 2020 15:50 PM UTC

Good morning

I am trying to activate my powerbuilder application while working on another (non powerbuilder) application.

What I have to do is, when the second application write a file in a predefined folder, my PB application must consume the file activating itself, and becaming the actual active window application.

I tried whit this code:

unsignedlong hwnd
hwnd = FindWindow(0, "My PB App")
SetForegroundWindow(hwnd)

 

using these API declaration:

PUBLIC FUNCTION unsignedlong FindWindow (long classname, string windowname) LIBRARY "user32.dll"
FUNCTION BOOLEAN SetForegroundWindow( LONG HWND ) LIBRARY "USER32"

 

but it doen't work.

Any suggestion?

 

Thanks in advance.

Mario

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 27 November 2020 16:41 PM UTC
  2. PowerBuilder
  3. # 1

Hi Mario;

  FWIW: The ANSI version of FindWindow API will no longer work if you are using W10. If so, please change the API declaration to ...

FUNCTION   uLong  FindWindow ( ref String classname, ref string windowname ) Library "USER32.DLL" ALIAS FOR "FindWindowW"

Note: Also, your app should check that the "hwnd" variable is valid before using it.  ;-)

HTH

Regards ... Chris

 

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.