Thank you all,
This is what I came up whith from all you examples.
With this I can put MYLIST procedure in my main program procedure file and use from any program or procedure in any large program by
sending the paramaters I want pick.
I used this a another large electric motor project and use foe action from buttons as well as below.
Hope this is useful for others. Saves making a lot of list boxes in programs.
Code: Select all
/*
* HMG - Harbour Win32 GUI library Demo
*
* Copyright 2002 Roberto Lopez <mail.box.hmg@gmail.com>
* http://www.hmgforum.com//
*/
#include "hmg.ch"
Function Main
PRIVATE MLAR := '', MLR := ''
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'HMG Demo' ;
MAIN
@ 10,10 TEXTBOX Text_1 ;
VALUE 123 ;
TOOLTIP 'Numeric TextBox' ;
NUMERIC ;
MAXLENGTH 5 ;
RIGHTALIGN ;
ON LOSTFOCUS if ( This.Value < 100 , This.SetFocus , Nil)
@ 40,10 TEXTBOX Text_2 ;
VALUE ' ';
TOOLTIP 'Character TextBox' ;
DISABLEDBACKCOLOR { 0,255,0 } ;
DISABLEDFONTCOLOR { 255,255,255 };
ON ENTER Form_1.Text_1.SetFocus ; // the parameter 4 is the number of items which sets height if list box
ON LOSTFOCUS If (len(alltrim(This.Value)) <> 0,{This.Value:= '', MLAR:={' ','A','B','C','D'},This.Setfocus,MyList(' ',4),;
This.Value:= MLR},{Form_1.Text_1.Setfocus}) // In this case 0 (blank) is my prefered value
END WINDOW
Form_1.Center
Form_1.Activate
Return Nil
Procedure MyList(ML,HI)
Local LA := 0, HIT := 160, HIT1:=0
HIT1:= HIT+(HI*8)
HIT := (HIT1)
MLR := ALLTRIM(ML)
IF .NOT. ISWINDOWACTIVE(WMYLIST)
DEFINE WINDOW WMYLIST ;
AT 160,790 ;
WIDTH 300 ;
HEIGHT hit +120 ; //520 ; //250 ;
TITLE 'Pick Item ** Escape Will Exit' ;
MODAL ;
SYSMENU .F.
ON KEY ESCAPE OF WMYLIST ACTION {WMYLIST.RELEASE}
DEFINE LISTBOX LIST1
ROW 2 //2
COL 100
WIDTH 100
HEIGHT hit + 40 //440
ITEMS MLAR
on dblclick {||{la:=Wmylist.list1.value},{ mlr:=(Wmylist.list1.item(la))}, {Wmylist.release}}
END LISTBOX
DEFINE button button_1 // FOR BUTTON TO CLICK TO EDIT CUSTOMER
ROW hit + 60 //460
COL 120
WIDTH 60
HEIGHT 20 // 20
TOOLTIP 'Exit With No Change'
CAPTION 'E&xit'
ACTION {wmylist.release}
END button
END WINDOW
WMYLIST.activate
ELSE
MSGINFO('Already in Use')
ENDIF
Return