I must admit, I'm having fun using PB11 with C#.
I've found a way to add my own event handling in PB Winforms simply by using a .NET Assembly. Some events are not available to us in the IDE. Some events that we use to use have been "filtered" out and become unsupported. There is a way to execute these events with a couple function calls.
There were 2 events in my case that I needed to trap. Neither of which were available in the IDE. They were the Paint and MouseLeave event. In the past I would have used the pbm_paint event id for the Paint event and the Other event for the MouseLeave event. PB11 filters these events out so they are no longer options.
To get around this I created a .NET assembly in C#. This new class had 1 public function and accepted one arguements ("object pbObj"). The function did the following:
namespace PBEvent
{
public class PBEventHandler
{
private object pbObject;
private void PBTriggerEvent(string eventId)
{
Sybase.PowerBuilder.Win.PBUserObject pbUO = (Sybase.PowerBuilder.Win.PBUserObject)pbObject;
pbUO.TriggerEvent(eventId);
}
public void PBRegisterObject(object pbObj)
{
pbObject = pbObj;
pbObj.Paint += delegate { PBTriggerEvent("ue_Paint"); };
pbObj.MouseLeave += delegate { PBTriggerEvent("ue_MouseLeave"); };
}
}
}
And calling it was even simpler:
PB Code:
//Declare instance Variable
#if defined PBDOTNET then
PBEvent.PBEventHandler i_PBEventHandler
#end if
//Register events - Constructor event
#if defined PBDOTNET then
i_PBEventHandler = CREATE PBEvent.PBEventHandler
i_PBEventHandler.PBRegisterObject(THIS)
#end if
Brad