S_230RH2

LANSA

S_230RH2
* ===================================================================
*
* Component : S_230RH2
* Type : Reusable Part
* Ancestor : PRIM_FORM
*
* Description : This reusable part is the generic CHM help manager
*
* Disclaimer : The following material is supplied as example material
* only. No warranty concerning this material or its use
* in any way whatsoever is expressed or implied.
*
* ===================================================================
FUNCTION OPTIONS(*DIRECT)
BEGIN_COM Role(*EXTENDS #PRIM_FORM) Formstyle(NormalChild) Height(276) Layoutmanager(#ATLM_1) Left(456) Menubar(#MBAR_1) Top(185) Width(465)

* Define the full CHM guide name (ie: Directory + "S_230HELP.CHM")

Define #GuideName Reffld(#SysVar$Av)

* Define the full topic linkage file name (ie: Directory + "S_230HELP.DAT")

Define #TopicFile Reffld(#SysVar$Av)

* Define other variables

Define #CUR_Comp *char 56 Desc('The current linkage component name')
Define #CHM_Comp Reffld(#CUR_Comp) Desc('The CHM linkage component name')
Define #CHM_Topic *char 200 Desc('The CHM topic')
Define #RetCode *char 2 Desc('Standard Return Code')

* Define the list used to store the component / CHM topic linkage
* details. This list is filled by reading from file S_230HELP.DAT
* which links (ie: associates) composite component names with CHM
* topics.
*
* As shipped S_230HELP.DAT contains this information that is loaded
* into list #Topics at run time:
*
* #CHM_Comp #CHM_Topic
* --------- ----------
* S_230FA the_main_demonstration_form.htm
* S_230FA.SURNAME employee_last_name.htm
* S_230FA.EMPNO employee_number.htm
* S_230FA.OK_BUTTON save_Button.htm
* S_230FA.CANCEL_BUTTON cancel_Button.htm
* S_230FB the_secondary_demonstration_form.htm
* S_230FB.SALARY current_salary.htm
* S_230FB.POSTCODE zip_code.htm
* S_230FB.OK_BUTTON save_Button.htm
* S_230FB.CANCEL_BUTTON cancel_Button.htm

Def_List #Topics (#CHM_Comp #CHM_Topic) type(*working) entrys(200)

* Define the MS Active-X Web browser (should be on any systemn with IE installed).

DEFINE_COM CLASS(#S_230XWB.WebBrowser) NAME(#S_230XWB) REFERENCE(*dynamic)

* Form layout and management details

DEFINE_COM Class(#PRIM_ATLM) Name(#ATLM_1)
DEFINE_COM Class(#PRIM_FWLM) Name(#FWLM_1) Flowoperation(Center) Flowoperationhor(Decrease) Marginright(4)
DEFINE_COM Class(#PRIM_ATLI) Name(#ATLI_1) Attachment(Center) Parent(#ATLM_1)
DEFINE_COM Class(#PRIM_ATLI) Name(#ATLI_3) Attachment(Top) Parent(#ATLM_1)
DEFINE_COM Class(#PRIM_GPBX) Name(#GPBX_1) Displayposition(1) Height(35) Layoutmanager(#FWLM_2) Left(0) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(0) Width(457)
DEFINE_COM Class(#PRIM_ATLI) Name(#ATLI_4) Attachment(Top) Parent(#ATLM_1)
DEFINE_COM Class(#PRIM_MBAR) Name(#MBAR_1) Parent(#COM_OWNER)
DEFINE_COM Class(#PRIM_FWLM) Name(#FWLM_2) Marginbottom(8) Marginleft(8) Marginright(8)
DEFINE_COM Class(#PRIM_SPBN) Name(#SPBN_HIDE) Buttonstyle(FlatButton) Caption('Hide') Displayposition(4) Height(20) Left(240) Parent(#GPBX_1) Tabposition(1) Top(8) Width(60)
DEFINE_COM Class(#PRIM_FWLI) Name(#FWLI_1) Manage(#SPBN_HIDE) Parent(#FWLM_2)
DEFINE_COM Class(#PRIM_SPBN) Name(#SPBN_BACK) Buttonstyle(FlatButton) Caption('Back') Displayposition(1) Height(20) Left(12) Parent(#GPBX_1) Tabposition(2) Top(8) Width(60)
DEFINE_COM Class(#PRIM_FWLI) Name(#FWLI_2) Manage(#SPBN_BACK) Parent(#FWLM_2)
DEFINE_COM Class(#PRIM_SPBN) Name(#SPBN_FORWARD) Buttonstyle(FlatButton) Caption('Forward') Displayposition(2) Height(20) Left(82) Parent(#GPBX_1) Tabposition(3) Top(8) Width(60)
DEFINE_COM Class(#PRIM_FWLI) Name(#FWLI_3) Manage(#SPBN_FORWARD) Parent(#FWLM_2)
DEFINE_COM Class(#PRIM_SPBN) Name(#SPBN_ONLINE_GUIDE) Buttonstyle(FlatButton) Caption('Online Guide') Displayposition(3) Height(20) Left(152) Parent(#GPBX_1) Tabposition(4) Top(8) Width(78)
DEFINE_COM Class(#PRIM_FWLI) Name(#FWLI_5) Manage(#SPBN_ONLINE_GUIDE) Parent(#FWLM_2)
DEFINE_COM Class(#PRIM_ATLI) Name(#ATLI_2) Attachment(Top) Manage(#GPBX_1) Parent(#ATLM_1)
DEFINE_COM Class(#PRIM_PHBN) Name(#HIDDEN_ESCAPE_BUTTON) Buttondefault(True) Displayposition(5) Height(0) Left(310) Parent(#GPBX_1) Tabposition(5) Top(8) Width(0)
DEFINE_COM Class(#PRIM_FWLI) Name(#FWLI_4) Manage(#HIDDEN_ESCAPE_BUTTON) Parent(#FWLM_2)

* =====================================================================
* Handle instance creation
* =====================================================================

Evtroutine Handling(#Com_Owner.CreateInstance) Options(*NOCLEARERRORS *NOCLEARMESSAGES)

* This form is initially invisible

Set #Com_Owner Visible(False)

* Make the CHM guide name (ie: Directory + S_230HELP.DAT)

Use TConcat (*Part_Dir_Source S_230Help.Chm) (#GuideName)

* Make the CHM/Topic linkage file name (ie: Directory + S_230HELP.DAT)

Use TConcat (*Part_Dir_Source S_230Help.Dat) (#TopicFile)

* Load up the CHM/Topic linkage into the working list #Topics list

Use Transform_File (#Topics #TopicFile O) TO_GET(#RetCode)

Endroutine

* =====================================================================
* Handle a request to set the current topic into #CUR_Comp
* =====================================================================

Mthroutine uSetCurrentTopic
Define_Map *input #Prim_Objt #uForComponent Pass(*By_Reference)

* Build the 2 part "parent.child" formatted name used as the
* key to the CHM Topic linkage information in the #Topics list

If_ref #uForComponent.Parent is(*Null)
Change #CUR_Comp #uForComponent.Name
else
Use TConcat (#uForComponent.Parent.Name '.' #uForComponent.Name) (#CUR_Comp)
Endif

* Show the topic only if a topic is already being
* shown .... do not force the topic to be shown.

Invoke #Com_Owner.uShowCurrentTopic uForce(FALSE)

Endroutine

* =====================================================================
* Show the online guide
* =====================================================================

Mthroutine uShowOnlineGuide

* To show the online guide simply shell the file name and ask the
* operating system to "Open" the file with the standard file opener.

Use Builtin(SYSTEM_COMMAND) With_Args(H #GuideName) To_Get(#Std_Num)

Endroutine

* =====================================================================
* Show the current topic
* =====================================================================

Mthroutine uShowCurrentTopic
Define_Map *input #Std_Bool #uForce Mandatory(TRUE)

* If a topic is currently visible or if display of the
* topic is being forced

If '(#Com_Owner.Visible = True) or (#uForce.Value = True)'

* Create and initialize the Active-X web browser control

If_ref #S_230XWB is(*Null)
Set_Ref #S_230XWB (*Create_as #S_230XWB.WebBrowser)
Set #S_230XWB Parent(#Com_Owner) VisualStyleofParent(FALSE) DISPLAYPOSITION(3) HEIGHT(45) LEFT(0) TABPOSITION(3) TABSTOP(False) TOP(150) WIDTH(323)
Set #ATLI_1 Manage(#S_230XWB)
Set (#SPBN_Back #SPBN_Forward) Enabled(False)
Invoke #Com_Owner.Realize
Endif

* Set a default CHM help topic

Change #CHM_Topic Unknown.Htm

* Look up the current composite component name to get the
* associated CHM topic ....

Loc_Entry #Topics where('#CUR_Comp = #CHM_COMP')

* Build the appropriate URL for the topic

Use Builtin(TCONCAT) With_Args('ms-its:' #GuideName '::/' #CHM_Topic) To_Get(#SysVar$av)

* Ask the active-X control to display the URL

Invoke Method(#s_230XWB.Navigate) Url(#SysVar$av)

* If this form is not currently visible display it

If '#Com_Owner.Visible *ne True'
Invoke #Com_Owner.RestoreForm
Invoke #Com_Owner.ShowForm
Invoke #Com_Owner.ActivateForm
Set #Com_Owner Visible(True)
Endif

Endif

Endroutine

* ==============================================================
* Control the enabling/disabling of the Back and Forward buttons
* ==============================================================

Evtroutine Handling(#S_230XWB.CommandStateChange) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Command(#Cmd_Button) Enable(#Enable)

Change Field(#Std_Num) To(#Cmd_Button.Value)

Case Of_Field(#Std_Num)
When Value_Is('= 1')
Set Com(#SPBN_Forward) Enabled(#Enable.Value)
When Value_Is('= 2')
Set Com(#SPBN_Back) Enabled(#Enable.Value)
Endcase

Endroutine

* ==============================================================
* Handle the Hide button and Form closure
* ==============================================================

Evtroutine Handling(#Com_Owner.Closing #SPBN_Hide.Click #Hidden_Escape_Button.Click) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Set #ATLI_1 Manage(*Null)
Set_Ref #S_230XWB *null
Set #Com_Owner Visible(False)
Endroutine

* ==============================================================
* Handle the Back button
* ==============================================================

Evtroutine Handling(#SPBN_Back.Click) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Invoke Method(#S_230XWB.GoBack)
Endroutine

* ==============================================================
* Handle the Foward button
* ==============================================================

Evtroutine Handling(#SPBN_Forward.Click) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Invoke Method(#S_230XWB.GoForward)
Endroutine

* ==============================================================
* Handle the Online Guide button
* ==============================================================

Evtroutine Handling(#SPBN_Online_Guide.Click) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
Invoke #Com_Owner.uShowOnlineGuide
Endroutine

END_COM