cancel
Showing results for 
Search instead for 
Did you mean: 

Signalling PB Classic window from a .NET COM object

former_member329524
Active Participant
0 Kudos

Hello, all

I was wondering if anyone here successfully dealt with this problem before.

We have several large PB Classic Apps. They all need to operate a small module, which connects to various external data sources, handles hardware peripherals, and, in general, does all the sort of stuff that PB is not very good at.

The main idea is to write a .NET component and compile it as COM. That, in itself, solves about 80% of the problem. The remaining 20% are located in the requirement of backward event-driven communication between non-visual COM objects and the parent PB apps.

Does anyone have any suggestion what is the best way to do it? The "brute-force" solution of putting the components on the MDI Frame window is the absolutely last resort. wWe would rather have a possibility to pass the reference to the PB window to the component, so the component could, somehow, signal it or raise an event.

Do anyone have any experience with that?

Thank you

Arcady

View Entire Topic
Former Member
0 Kudos

Hi Arcady;

  Thought:  I wonder if the .Net component could use the MS-Windows SendMessage () API to send a message to your PB application - which in turn can fire a "Custom Event? I have done this many times between PB application EXE's where PB.App1 sends a Message ID 1024 to PB.App2 for example. This Message# in turn fires PB.App2's "Custom01" user event to wake it up that there is something to do. The SendMessage API also allows the sender to send up to two parameters as well.

FYI:  SendMessage function (Windows)

Food for thought.  😉

Regards ... Chris

former_member329524
Active Participant
0 Kudos

Thank you, Chris

I thought of that too, but I do not have any examples or best practices in PB Classic on how to receive a message to fire a custom event.

Do you have any, by any chance?

Former Member
0 Kudos

Hi Arcady;

  Yes, I sure do.  😉

BTW: I should have also mentioned that a PostMessage ( ) API call is also available and may be more appropriate when performing asynchronous tasks. https://msdn.microsoft.com/en-us/library/windows/desktop/ms644944%28v=vs.85%29.aspx

   Here is an example of an assembly that uses the handle of the PB Application's MDI frame window to send multiple messages #1024 (custom01) through #1040 (custom16) events. Each event number represents a different action that the PB application needs to take.


Code on oe_message1:

THIS.Setmicrohelp ( "The thread's CPU time is "  + String ( lparam))                   

THIS.Setmicrohelp ( "The thread's CPU time is "  + String ( lparam) + "  oe_message of wn_mt_controller_e event called from nc_callback" )               

THIS.Title +=  " Polled:"  + String ( lparam)

HTH

Regards ... Chris