1. Tom Peters
  2. PowerBuilder
  3. Thursday, 20 September 2018 16:19 PM UTC

Hello All!

I implemented GetForegroundWindow in my PB 2017 R3 application as follows:

Function ulong GetForegroundWindow( ) Library "USER32.DLL"

I call it, capturing the return into an unsignedlong.

This all works fine in the IDE (32 bit), but when I run the 64 bit EXE, GetForegroundWindow always returns 0.

Should I do something different?

Thanks,

Tom

Accepted Answer
René Ullrich Accepted Answer Pending Moderation
  1. Friday, 21 September 2018 05:19 AM UTC
  2. PowerBuilder
  3. # Permalink

GetForegroundWindow returns HWND handle. I think this is a 64 bit value for 64 bit applications . Try using LongLong as return type.

Comment
  1. Tom Peters
  2. Monday, 24 September 2018 17:44 PM UTC
Thanks!
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 24 September 2018 19:27 PM UTC
  2. PowerBuilder
  3. # 1

Hi Tom;

   If a LongLong does not work, try using a return data type of  Longptr

HTH

Regards ... Chris

Comment
  1. Tom Peters
  2. Wednesday, 26 September 2018 12:54 PM UTC
Hi Chris - LongLong did work, but I will make note of this for future API calls. Thanks!
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 26 September 2018 13:42 PM UTC
Thanks for the feedback Tom .. glad it now works! :-)



Tip: Use the Environment object class and check the "processbitness" property in your App's to know which flavour of GetForegroundWindow to use at run-time. ;-)
  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.