ControlEvents library

agraham

Expert
Licensed User
Longtime User
There are some events "missing" from the built-in controls in B4PPC. This library enables them to be used if anyone so wants. The included help file gives details.


This library is built for .NET 2.0 as I cannot target .NET 1.1 or CF 1.0. However I have included the source in the zip so maybe some kind person can recompile it for .NET 1.1 and repost it as (say) ControlEvents1.dll so that anyone who want to use doesn't need .NET 2.0.
 

Attachments

  • ControlEvents.zip
    9.2 KB · Views: 141

agraham

Expert
Licensed User
Longtime User
It may not be obvious but you can add the events in this library to the controls in the ControlEx library although it may not be useful or work for some of them. For example - A TrackBar

B4X:
' assuming a ControlEvents Object called TrkBrEvents
' and a TrackBar object called TrkBr

Sub App_Start
   Form1.Show
   TrkBr.New1("Form1",10,10,100,30,false) ' new TrackBar Control
   TrkBrEvents.New1(TrkBr.ControlRef)      ' add the new events
End Sub

Sub TrkBrEvents_GotFocus
   ' do something 
End Sub
You can also add the events to controls added at runtime by just specifying their name -
B4X:
   AddButton("Form1","RunTimeButton",10,10,60,30,"ClickMe") 
   BtnEvents.New1("RunTimeButton")
 

agraham

Expert
Licensed User
Longtime User
Apologies if anyone saw this post come and (rapidly) go a bit earlier. I posted a zip that had the wrong help file. Helpmaker may be free but it is also very idiosyncratic and it seems to be easy to get it confused in several different ways - I ended up reposting the original help. Hopefully all is well this time.

Second and final (hopefully) version of the library with modified help and source. Again compiled for .NET 2.0 - dzt's opportunity to get in fast!

The Key events have been added so this, together with the built-in events in B4PPC, gives access to just about all the meaningful control events in the Compact Framework.

A ControlRef property is added for completeness but is probably of no use to anyone.

Dispose has been improved to unhook the added events from the enhanced control but you don't need to worry about this..
 

Attachments

  • ControlEvents.zip
    11.6 KB · Views: 68

dzt

Active Member
Licensed User
Ready. .Net CF 1.0 attached.

Thanks for the opportunity.:)

It was not so easy as
Ctrl.EnabledChanged -= EnabledChangedEvent;
does not compile for .NETCF 1.0 so I changed it to
Ctrl.EnabledChanged -= newEventHandler(EnabledChangedEvent);

Cheers
 

Attachments

  • ControlEvents1.zip
    11.7 KB · Views: 73
Last edited:

agraham

Expert
Licensed User
Longtime User
Thanks dzt.
It was not so easy as
Ctrl.EnabledChanged -= EnabledChangedEvent
Sorry - C# version 2.0 syntax "improvement" that isn't backwards compatible.

I'm really a VB man but libraries are better in C# because of all the baggage that VS2005 VB puts in a module and becomes visible in B4PPC, and I have only ever used version 2 as I only have .NET 2.0 on my machine.
 

dzt

Active Member
Licensed User
Hello agraham (multithreading contact:)),

I'm really a VB man but libraries are better in C# because of all the baggage that VS2005 VB puts in a module and becomes visible in B4PPC

Compiling with #develop you can avoid all that baggage. SharpDevelop also has a built-in VB.NET to C#.NET and vice versa, convertion tool.
 
Top