Visual LANSA Source
Function Options(*DIRECT)
BEGIN_COM ROLE(*EXTENDS #PRIM_PANL) DISPLAYPOSITION(1) HEIGHT(201) LAYOUTMANAGER(#ATLM_1) LEFT(0) TABPOSITION(1) TOP(0) WIDTH(323)
Attribute Class(#PRIM_ATTR.AX_TYPELIB) Guid('{0D4F2AF5-A003-464A-A10E-C60842AB9A4E}') TypeLibName('LANSA_AXPANELA_LIB')
Attribute Class(#PRIM_ATTR.AX_CLASS) Guid('{643DEA7B-A45C-498D-9983-F5044CE8281E}') ProgId('LANSA.AXPANELA')
Attribute Class(#PRIM_ATTR.AX_IN_INTERFACE) Guid('{AD3DAC73-0CE5-44BE-8694-740FFFF1E78B}') BaseDispId(0)
Attribute Class(#PRIM_ATTR.AX_EVT_INTERFACE) Guid('{7BDC12E6-3D78-4247-A89F-FF763D0DB017}') BaseDispId(0)
DEFINE_COM CLASS(#PRIM_GRID) NAME(#GRID_1) CAPTIONNOBLANKLINES(True) COLUMNBUTTONHEIGHT(18) COMPONENTVERSION(1) DISPLAYPOSITION(1) HEIGHT(201) LEFT(0) PARENT(#COM_OWNER) SHOWBUTTONSELECTION(True) SHOWSELECTION(True) SHOWSELECTIONHILIGHT(False) SHOWSORTARROW(True) TABPOSITION(1) TOP(0) WIDTH(323)
DEFINE_COM CLASS(#PRIM_ATLM) NAME(#ATLM_1)
DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_1) ATTACHMENT(Center) MANAGE(#GRID_1) PARENT(#ATLM_1)
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_1) CAPTIONALIGN(Left) CAPTIONTYPE(ColumnHeadings) DISPLAYPOSITION(1) PARENT(#GRID_1) SOURCE(#SKILCODE) WIDTH(20)
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_2) CAPTIONTYPE(ColumnHeadings) COLUMNALIGN(Center) DISPLAYPOSITION(2) PARENT(#GRID_1) SOURCE(#GRADE) WIDTH(11)
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_3) CAPTIONALIGN(Left) DISPLAYPOSITION(3) PARENT(#GRID_1) SOURCE(#SKILDESC) WIDTH(20) WIDTHTYPE(MinRemainder)
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_4) PARENT(#GRID_1) SOURCE(#EMPNO) VISIBLE(False) WIDTH(20)
*
Define_Pty Name(uEmployeeGiveName) Get(*auto #givename)
Attribute Class(#PRIM_ATTR.AX_IN_MEMBER) Dispid(0) Name('uEmployeeGiveName')
Define_Pty Name(uEmployeeSurname) Get(*auto #surname)
Attribute Class(#PRIM_ATTR.AX_IN_MEMBER) Dispid(1) Name('uEmployeeSurname')
Define_Pty Name(uEmployeeSalary) Get(*auto #salary)
Attribute Class(#PRIM_ATTR.AX_IN_MEMBER) Dispid(2) Name('uEmployeeSalary')
*
Mthroutine Name(uShowEmployeeSkills)
Attribute Class(#PRIM_ATTR.AX_IN_MEMBER) Dispid(3) Name('uShowEmployeeSkills')
Define_Map For(*input) Class(#empno) Name(#i_empno)
Define_Map For(*output) Class(#prim_boln) Name(#uDirty)
Set Com(#uDirty) Value(#com_false)
Clr_List Named(#GRID_1)
Change Field(#EMPNO) To(#I_EMPNO)
Fetch Fields(#SURNAME #GIVENAME #SALARY) From_File(PSLMST) With_Key(#EMPNO)
If_Status Is(*OKAY)
Select Fields(#SKILCODE #GRADE) From_File(PSLSKL) With_Key(#EMPNO)
Fetch Fields(#SKILDESC) From_File(SKLTAB) With_Key(#SKILCODE) Keep_Last(5)
Add_Entry To_List(#GRID_1)
Endselect
Endif
* set return code
If Cond('#grid_1.entries *eq 0')
Set Com(#uDirty) Value(#com_true)
Endif
Endroutine
End_Com
Source Code ActiveX Example 2 - Visual Basic - Object
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
Caption = "Imbedded version of ActiveX Interaction 101"
ClientHeight = 4545
ClientLeft = 60
ClientTop = 345
ClientWidth = 5400
LinkTopic = "Form1"
ScaleHeight = 4545
ScaleWidth = 5400
StartUpPosition = 3 'Windows Default
Begin MSComctlLib.StatusBar sbcase2
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 3
Top = 4170
Width = 5400
_ExtentX = 9525
_ExtentY = 661
Style = 1
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.CommandButton cmdShowEmployee
Caption = "Show Skills"
Default = -1 'True
Height = 350
Left = 3000
TabIndex = 1
ToolTipText = "Invoke Visual LANSA method to retrieve employee details"
Top = 120
Width = 1455
End
Begin VB.TextBox uEmployeeNumber
Height = 350
Left = 1680
TabIndex = 0
Text = "A1012"
Top = 120
Width = 975
End
Begin VB.Label LblEmployee
Caption = "Employee Number:"
Height = 345
Left = 120
TabIndex = 2
Top = 120
Width = 1335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Source Code ActiveX Example 2 - Visual Basic - Code
Option Explicit
Public Session As LANSA_ACTIVEX_LIB.Session
Public gbDirty As Boolean
Private Sub cmdShowEmployee_Click()
Call AXPANELA.uShowEmployeeSkills(uEmployeeNumber, gbDirty)
If gbDirty = True Then
sbcase2.SimpleText = "No skills found for employee"
Else:
sbcase2.SimpleText = " Employee skills selected"
End If
End Sub
Private Sub Form_Load()
' login to LANSA using default user, password and session location
If Session Is Nothing Then
Call ConnectToLansa("<user name>", "<password>", "<session.cfg path>")
End If
Call Session.AddComponent(AXPANELA.object)
End Sub
Private Sub ConnectToLansa(ByVal username As String, ByVal password As String, ByVal txtlocation As String)
On Error GoTo ErrorHandler
Set Session = New LANSA_ACTIVEX_LIB.Session
' Set the session configuration file
Session.ConfigFile = txtlocation
Call Session.SetConnectParam("USER", username)
Call Session.SetConnectParam("PSPW", password)
Call Session.Connect
Exit Sub ' Exit to avoid handler.
ErrorHandler: ' Error-handling routine.
MsgBox ("Error :" + Err.Description)
End Sub