NET Component Sample Code

Visual LANSA

.NET Component Sample Code

This sample uses the standard .NET assembly System.Windows.Forms.dll. This assembly is normally located in the following locations:

32-bit system: C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

64-bit system: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 

Create a .Net Component named #DNETDEMO

The resulting .Net Component source should look as follows (on 32-bit machines):

 

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_OBJT) Componentassembly('C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Windows.Forms.dll')
End_Com
 

Create a form with the following code

 

Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientheight(690) Clientwidth(1030) Height(728) Left(723) Top(181) Width(1046)
Define_Com Class(#DNETDEMO.System.Windows.Forms.WebBrowser) Name(#Browser) Displayposition(8) Height(617) Left(16) Parent(#COM_OWNER) Tabposition(8) Top(40) Width(1001)
Define_Com Class(#PRIM_STBR) Name(#STBR_1) Displayposition(1) Height(24) Left(0) Messageposition(1) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(666) Width(1030)
Define_Com Class(#STD_QSEL.Visual) Name(#WebAddr) Caption('Address') Displayposition(2) Height(19) Labeltype(Caption) Left(96) Marginleft(60) Parent(#COM_OWNER) Tabposition(2) Top(16) Usepicklist(False) Width(801)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_Go) Buttondefault(True) Caption('Go') Displayposition(3) Left(904) Parent(#COM_OWNER) Tabposition(3) Top(13) Width(27)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_Back) Displayposition(4) Image(#VB_ARROWL) Left(22) Parent(#COM_OWNER) Tabposition(4) Top(13) Width(27)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_Forward) Displayposition(5) Image(#VB_ARROWR) Left(56) Parent(#COM_OWNER) Tabposition(5) Top(13) Width(27)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_Stop) Displayposition(6) Image(#VB_STOP) Left(936) Parent(#COM_OWNER) Tabposition(6) Top(13) Width(27)
Define_Com Class(#PRIM_PHBN) Name(#PHBN_Print) Displayposition(7) Image(#VB_PRINT) Left(984) Parent(#COM_OWNER) Tabposition(7) Top(13) Width(27)
 
Evtroutine Handling(#com_owner.Initialize)
Set Com(#com_owner) Caption(*component_desc)
#Browser.ScriptErrorsSuppressed := True
#COM_OWNER.ShowWebpage( 'http://www.lansa.com' )
Endroutine
 
Evtroutine Handling(#Browser.Navigated) Sender(#Sender) E(#EventArgs)
#WebAddr := #Browser.Url.ToString()
Endroutine
 
Evtroutine Handling(#PHBN_Go.Click)
If (#WebAddr.Substring( 1, 7 ).LowerCase() <> 'http://')
#WebAddr := 'http://' + #WebAddr
Endif
 
#COM_OWNER.ShowWebpage( #WebAddr )
Endroutine
 
Evtroutine Handling(#PHBN_Back.Click)
#Browser.GoBack
Endroutine
 
Evtroutine Handling(#PHBN_Forward.Click)
#Browser.GoForward
Endroutine
 
Evtroutine Handling(#PHBN_Stop.Click)
#Browser.Stop
Endroutine
 
Evtroutine Handling(#PHBN_Print.Click)
#Browser.ShowPrintDialog
Endroutine
 
Mthroutine Name(ShowWebpage)
Define_Map For(*INPUT) Class(#STD_QSEL) Name(#WebPageAddress)
Define_Com Class(#DNETDEMO.System.Uri) Name(#Uri) Reference(*DYNAMIC)
 
#Uri <= *New #DNETDEMO.System.Uri.Uri( #WebPageAddress )
#Browser.Url <= #Uri
Endroutine
 
End_Com