MSM-ViEW
Product         =   Builder
ProductVersion  =   2.0.0
Format          =   Export
FormatVersion   =   1.1
Workshop        =   __A,__A
Workbench       =   3500372;1484148006
Date            =   28 FEB 01
Time            =    8:42 AM
Begin Window HandT011 GUI.MSM
   Active          =   1
   AlwaysOnTop     =   0
   CompPrefixGbl   =   XXX
   CompPrefixRtn   =   XXX
   CompTrace       =   0
   DefaultButton   =   btnOK
   DevMode         =   GUI
   FontFace        =   M,SANS
   FontSize        =   8
   GridHeight      =   4
   GridOn          =   1
   GridSnap        =   1
   GridUnits       =   ZDLG
   GridWidth       =   4
   MVersion        =   MSM
   Maximized       =   0
   MinButton       =   0
   Modal           =   PARENT
   PosJustifyH     =   C
   PosJustifyV     =   C
   PosLeft         =   0
   PosRecall       =   1
   PosTop          =   0
   PosUnits        =   ZDLG
   Resizable       =   0
   SizeHeight      =   177
   SizeRecall      =   1
   SizeUnits       =   ZDLG
   SizeWidth       =   194.5
   TForeColor      =   0,0,65535
   Title           =   Choose a word
   Type            =   APPLICATION
   Units           =   ZDLG
   Visible         =   1
   WinHeight       =   192.5
   WinUnits        =   ZDLG
   WinWidth        =   200.5
   Begin Control Label1 LABEL
      AutoSize        =   1
      Border          =   0
      ForeColor       =   0,0,65535
      PosLeft         =   16
      PosTop          =   24
      PosUnits        =   ZDLG
      SizeHeight      =   7
      SizeUnits       =   ZDLG
      SizeWidth       =   116
      TFontFace       =   M,SANS
      TFontSize       =   8
      Title           =   Here you can type in the word you are looking for
      Type            =   LABEL
   End
   Begin Control btnANNUL BUTTON
      Active          =   1
      CanContain      =   0
      Cancel          =   0
      Picture         =   
      PosLeft         =   152
      PosTop          =   32
      PosUnits        =   ZDLG
      SizeHeight      =   12
      SizeWidth       =   36
      TFontBold       =   0
      TFontFace       =   M,SANS
      TFontItalic     =   0
      TFontSize       =   8
      TFontUline      =   0
      Title           =   Close
      Type            =   BUTTON
      Begin Event Ev30v1 
-------- Begin Document ActionLogic 1
	 %%Return
-------- End
      End
   End
   Begin Control btnOK BUTTON
      Active          =   1
      CanContain      =   0
      Cancel          =   0
      Picture         =   
      PosLeft         =   152
      PosTop          =   152
      PosUnits        =   ZDLG
      SizeHeight      =   12
      SizeUnits       =   ZDLG
      SizeWidth       =   36
      TFontBold       =   1
      TFontFace       =   M,SANS
      TFontItalic     =   0
      TFontSize       =   8
      TFontUline      =   0
      Title           =   OK
      Type            =   BUTTON
      Begin Event Ev30v1 
-------- Begin Document ActionLogic 6
	 %%GetSel(lstTREF,RESULT) ; results are being placed in an array RESULT
	 ; vb RESULT(10)="teksten"   This is the one that we want to have
	 S RESULT=$O(RESULT("")) ; there is always only one choice
	 I RESULT'="" S RESULT=RESULT(RESULT) ; get the text/title of the choice
	 D I^%msgbox("You have chosen: "_RESULT)
	 %%Return
-------- End
      End
   End
   Begin Control lstTREF LIST
      Active          =   1
      ChoiceField     =   
      ChoiceVar       =   TREFW
      DisplayOnly     =   0
      MaxSelect       =   1
      PosLeft         =   16
      PosTop          =   44
      PosUnits        =   ZDLG
      SizeHeight      =   120
      SizeUnits       =   ZDLG
      SizeWidth       =   132
      Type            =   LIST
      VarName         =   
      VarPermanent    =   0
   End
   Begin Control txtINPUT TEXT
      Active          =   1
      Border          =   1
      DispFmtParams   =   
      DispFmtType     =   
      DisplayOnly     =   0
      FontFace        =   M,SANS
      FontSize        =   8
      MaxLength       =   
      PosLeft         =   16
      PosTop          =   32
      PosUnits        =   ZDLG
      SizeHeight      =   12
      SizeUnits       =   ZDLG
      SizeWidth       =   132
      Type            =   TEXT
      ValidateParams  =   
      ValidateType    =   
      VarName         =   INPUT
      VarPermanent    =   0
      Begin Event EvCHAR 
-------- Begin Document ActionLogic 13
	S KEY=%%EvKey
	I KEY?1ANP S INPUT=INPUT_KEY
	;
	I $a(KEY)=8 S INPUT=$E(INPUT,1,$L(INPUT)-1)
	%%SetVar(INPUT)
	S DUM=$L(INPUT)_","_0
	%%Set(txtINPUT.SelStartLength,DUM)
	D MAKELIST
	%%ResetChoice(lstTREF)
	%%SetChoice(lstTREF,TREFW)
	I $G(TREFW(1))'="" D
	. %%SetSel(lstTREF,TREFW(1),T)
	q
-------- End
      End
      Begin Event EvKEYDOWN 
-------- Begin Document ActionLogic 24
	;
	; This label traps the input of key-up and key-down, when in the textbox, and than moves
	; the selection in the listbox. (with a little help of John M ...)
	N DIR,KEUZE
	I %%EvKey="DOWN" S DIR=1
	E  I %%EvKey="UP" S DIR=-1
	E  I %%EvKey="PAGEDOWN" S DIR=10 ; jump down with 10 at a time
	E  I %%EvKey="PAGEUP" S DIR=-10
	E  I %%EvKey="END" S DIR=9999 
	E  I %%EvKey="HOME" S DIR=-9999
	E  Q
	%%GetSel(lstTREF,KEUZE) ; get current selection into an array KEUZE
	S KEUZE=+$O(KEUZE("")) ; find out which node in the array is filled = choosen
	;
	; In the following two lines we check that the jump didn't get us passed the
	; boundaries of the array. We than adjust the value of DIR so that it brings us to the beginning or the end.
	; 
	I DIR=10!(DIR=9999),KEUZE+DIR>$O(TREFW(""),-1) S DIR=$O(TREFW(""),-1)-KEUZE ; LAST ONE
	I DIR=-10!(DIR=-9999),KEUZE+DIR<1 S DIR=1-KEUZE ; first one
	;
	Q:$G(TREFW(KEUZE+DIR))=""
	K KEUZE(KEUZE) S KEUZE(KEUZE+DIR)="" ; put the new selection value into the array
	%%ResetSel(lstTREF,KEUZE) ; use ResetSel here (not SetSel ...)
	Q
-------- End
      End
   End
   Begin Event Ev10 
----- Begin Document ActionLogic 5
	S INPUT=$G(INPUT)
	D GENERATE
	D MAKELIST	
	%%SetFocus(txtINPUT)
	;
----- End
   End
   Begin Event Ev90 
----- Begin Document ActionLogic 44
	;
	; A small sample to demonstrate the use of a 'lookup' listbox
	; build with a combination of a text field and a listbox
	; 
	; Henk Westerhof, 23-2-2001, Amsterdam, The Netherlands
	; westerhof@simar.nl
	; 
	; Published at www.georgejames.com/ws/HandT011.htm
	; with permission
	; 
	; If anyone would like: this example code is free to use for the MSM-WS community.
	;
MAKELIST	;build the list of options, based upon the input
	;
	K TREFW
	S N=INPUT,COUNT=1
		;
	S GLB="SOURCE" ; Global where the source list is, format =  SOURCE("WORD")=""
	;
	I N="" D ALLES Q
	;
	;
	; loop to fill searchlist  - format of search list is here   TREFW(n)="word"
	I $D(@GLB@(N)) S TREFW(COUNT)=N,COUNT=COUNT+1 ; exact match
	F  S N=$O(@GLB@(N)) Q:N=""  Q:$E(N,1,$L(INPUT))'=INPUT  D
	. S TREFW(COUNT)=N,COUNT=COUNT+1
	;
	Q
	;
ALLES	S N="" F J=1:1 S N=$O(@GLB@(N)) Q:N=""  S TREFW(J)=N
	Q
	;
	S INPUT=""
	;
	Q
	;
GENERATE	; generate a 'database' with items (500 words of 8 characters)
	; 
	K SOURCE
	F J=1:1:500 D
	. S WORD=""
	. F K=1:1:8 S L=$R(26) S:K>1 L=$R(10) S L=L+97,WORD=WORD_$C(L)
	. S SOURCE(WORD)=""
	Q
----- End
   End
End
