1. Joakim Krook
  2. PowerBuilder
  3. Wednesday, 14 June 2023 08:18 AM UTC

We are using PB2019 R3 and need to call a function in a running powerbuilder application from a C# program.

 

Is there a way to use PBNI for this or should we try some windows messaging approach?

 

Thanks in advance for assistance in this.

/Joakim

Accepted Answer
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Wednesday, 14 June 2023 10:38 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Joakim,

you can use the pbm_customXX events to receive and process custom messages from other applications. pbm_custom01 maps to WM_USER (=1024), pbm_custom02 is WM_USER+1 etc. So you can have your C# app send a WM_USER message to your main PB window and map an event to pbm_custom01 there.

Note that the PB help file lists this as an "obsolete technique". For sending messages within the same PB app I'd agree but as far as I know there's no alternative for processing custom messages from other applications.

Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 14 June 2023 13:50 PM UTC
Hi Jokam;

For that C# implementation that you describe above, the key SDK call would be to use the FindWindowW() O/S command to locate the PB Window class in memory. Then your App can use the SDK Send() command for those PBM_xxx custom events.

FYI: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-findwindoww

You could also use DDE: from C#: http://chrispollach.blogspot.com/2023/04/dde.html

You could also use TCP/IP from C#: http://chrispollach.blogspot.com/2023/04/socket.html

HTH ;-)

Regards ... Chris
  1. Helpful 2
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Wednesday, 14 June 2023 15:37 PM UTC
  2. PowerBuilder
  3. # 1

Topwiz Software - PowerSharp (topwizprogramming.com)

 

No idea if you can open a visual component in c# (window).    you can write something with pbni, or use the above prebuild/tested product from the topwiz

 

you can also just run a pb app using command line arguments from c# if that makes sense.  Or post an application event as others have suggested

 

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 14 June 2023 08:25 AM UTC
  2. PowerBuilder
  3. # 2

In the title you mention: "Opening Window...". What exactly you need to do?

Andreas.

Comment
  1. Andreas Mykonios
  2. Wednesday, 14 June 2023 08:53 AM UTC
  1. Helpful
  1. Joakim Krook
  2. Wednesday, 14 June 2023 09:09 AM UTC
Are you suggesting that we may use this technique to call a PB function FROM a C# component?
  1. Helpful
  1. Andreas Mykonios
  2. Wednesday, 14 June 2023 09:29 AM UTC
You can try it. This is the easier way to go. What may be an issue is using some window in your c# code.

Andreas.
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 14 June 2023 08:23 AM UTC
  2. PowerBuilder
  3. # 3

Hi.

The easier way is to use .NET DLL Importer. Take a look at: Calling .NET Assembly - - What's New (appeon.com)

Andreas.

Comment
  1. Joakim Krook
  2. Wednesday, 14 June 2023 08:40 AM UTC
Thank you, but that seems to adress the problem of calling C# functions from powerbuilder, we would like to do the opposite, calling a powerbuilder function from C#.
  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.