Page 2 of 3

Re: Combo control

Posted: Sat Mar 27, 2010 6:55 pm
by RDalzell
Michael,

Look at DC_LastFocus()

Rick

Re: Combo control

Posted: Sun Mar 28, 2010 10:34 am
by Cliff Wiernik
You sent some email yesterday (Saturday afternoon) to my office email address, also I think from your Toronto associate. Please send also to my cwsoft email address as I don't have access to the office email currently as it is in our spam filter and I cannot access via citrix from my location currently. Later I will be able to.

From the popup browse, if it is a new modal thread, you can not access the dcget at the same time as the modal browse. You can return to it and as I have in my example, you can have a seek key also in the popup that has the same DCGET info. Then you would return to the field and can also update that field and the display but is the popup is modal, you cannot access both.

Looking forward to hearing from you on Monday.

Cliff.

Re: Combo control

Posted: Mon Mar 29, 2010 2:21 pm
by sfsltd
Cliff / Rick / Roger

Thanks for all the advice. We are not yet out of the woods but ... can see some glinting lights.

Michael

Re: Combo control

Posted: Thu Apr 15, 2010 10:36 am
by sfsltd
Ok, this seems to work as a name lookup.

The features are:
  • Typing in the dcget() searches Name records and 'reveals' a three line two column browse of names.
    The top line of the browse is populated with the closest matching name to the typed characters.
    The user can keep typing -or- press the down/up cursor keys -or- click in the browser to scroll through the list of names
    Once in the browse list the user can press the up/down cursor keys -or- use the vertical scroll bar to locate any name.
    If the user scrolls to the very top of the browse, they see an <add new> record.
    Selecting the <add new> record opens a pop-up that conveniently adds a new name into the names table (PERS.DBF), completing the record selection.
    Pressing ENTER -or- TAB passes -or- clicking on a Name selects that name, enters it into the dcget(), hides the browse & moves the cursor to the next field.
    If ENTER -or- TAB is pressed when the text in the dcget() does NOT match a name in the database (unresolved) the dcget() field changes color to red.

Please note: We use this code within an existing form containing several dcget() fields.
If you use it you need to optimise it and manage memory resources.

Code: Select all

aNRecs ={}
cComp = ""
lPFlag       := .f.
Set4HuntandBrowse("P",lPFlag)
LoadNames(@aNRecs,.t.,lPFlag) //status problem <> "*"
nPointer1 = 0
    @ 5.7,DCGUI_COL+10 dcget cNameT GETID 'G_NAME';
       POPUP{|c,oGet|NameBrsflg:=!NameBrsflg,;
   IIf(NameBrsflg == .t.,LoadNamePointer(aNRecs,cComp,oGet,cNameT,"",48,@nPointer1),),;
   IIf(NameBrsflg == .t.,oBrowse2:gotop(),),;
   IIf(NameBrsflg == .t.,SetAppFocus(d_oPagegroup2),),;
   IIf(NameBrsflg == .t.,DC_BrowseRow( oBrowse2, nPointer1 ),),;
   IIf(NameBrsflg == .t.,oBrowse2:refreshAll(),),;
      DC_GetRefresh(GetList)};	      
   KEYBLOCK {|a,b,o|LoadNamePointer(aNRecs,cComp,o,cNameT,"",a,@nPointer1),;
   	      SearchtheName(a,b,o,@cNameT,@cClass,@oClass,@lFName,"P",lPFlag,@cTCode),;
      	      oBrowse2:gotop(),;
	      IIf(!IsValidateKey(a) .and. Downarrowpressed,NameBrsflg := .t.,NameBrsflg := .f.),;
	      IIf(IsValidateKey(a),NameBrsflg := .t.,),;
	      IIf(Downarrowpressed,SetAppFocus(d_oPagegroup2),),;
	      DC_BrowseRow( oBrowse2, nPointer1 ),;
	      oBrowse2:refreshAll(),;
	      Downarrowpressed := .f.,;
	      DC_GetRefresh(GetList)} ;	      
   GETSIZE 35;
   GETOBJECT oCName2;
   TABSTOP;
   WHEN {|| !empty( cFrom ) }           ;
   GOTFOCUS {|a,b,o|DC_GetCargo(o,o:setPresParam(aSelected))} ;
   LOSTFOCUS {|a,b,o|iif(lFName,,o:setPresParam(aPresit))} ;
   PREEVAL {||InitPick("P",lPFlag,@cNameT,@cClass)}

nTNWidth = 37.5
nTNHeight = 5
//   @ 1,18 DCGET cFrom ;
//       @ 5.7,DCGUI_COL+10 dcget cNameT GETID 'G_NAME';
//@ 2.5,18.5
@ 7.2,9 DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX OBJECT d_oPagegroup2       ;
            SIZE nTNWidth,nTNHeight PARENT oDialog ;
            COLOR GRA_CLR_BLACK,GRA_CLR_PALEGRAY ;
	    HIDE {|| NameBrsflg == .f.}  

//nPointer := 3
@ 0,0 DCBROWSE oBrowse2 ;
      SIZE nTNWidth,nTNHeight ;
      PARENT d_oPagegroup2;
      FONT cDefaultFont;
      DATA aNRecs ;
      PRESENTATION DC_BrowPres() ;
      TABSTOP;
      POINTER nPointer1 ;
      NOHSCROLL ;
      CURSORMODE XBPBRW_CURSOR_ROW HIDE {|| NameBrsflg == .f.};
      ITEMSELECTED {||;
           IIF(trim(aNRecs[nPointer1,1]) = "< Add New >",,cNameT := PadR(aNRecs[nPointer1,1]  , 30, " ")), ;
           IIF(trim(aNRecs[nPointer1,1]) = "< Add New >",,cClass := aNRecs[nPointer1,2]),;
           IIF(trim(aNRecs[nPointer1,1]) = "< Add New >",,cTCode := aNRecs[nPointer1,3]),;
	   IIF(trim(aNRecs[nPointer1,1]) = "< Add New >",,oCName2:setPresParam(aSelected)),;
	   IIF(trim(aNRecs[nPointer1,1]) = "< Add New >",,lFName := .t.),;
	   IIF(trim(aNRecs[nPointer1,1]) = "< Add New >",NewNames(oDialog,@cNameT,@cClass),),;
	   IIF(trim(aNRecs[nPointer1,1]) = "< Add New >",cTCode := NewzPersCode,),;
	   IIF(trim(aNRecs[nPointer1,1]) = "< Add New >",AddtoNameArray(aNRecs,cNameT,cClass,NewzPersCode),),;	   
	   NameBrsflg := .f.,SetAppFocus(oCName2),;
	   DC_GetRefresh(GetList)};
      LOSTFOCUS {|| NameBrsflg := .f.} ;
      GOTFOCUS {|| nPointer1 := 1} ;      
       
//determine how the browse will look
 //bSortCol := {|a,n,o| SortBrowse(aRecs,n)}
 
DCBROWSECOL ELEMENT 1 PIXEL WIDTH 116*Ratio HEADER 'Name' PARENT oBrowse2 SORT bSortCol 
DCBROWSECOL ELEMENT 2 PIXEL WIDTH 62*Ratio  HEADER 'Class' PARENT oBrowse2 SORT bSortCol 

Re: Combo control

Posted: Thu Apr 15, 2010 10:54 am
by rdonnay
Michael -

Is there enough info here for me to make a sample program from the code you posted?

Roger

Re: Combo control

Posted: Thu Apr 15, 2010 11:03 am
by sfsltd
Hi again

This image (PNG attached) shows how it looks after typing the letter F in the dcget().

If anyone has a better way of doing this, has a better name or can see code improvements, I'm happy to listen.

Michael

PS A known issue is the way the red highlight fails to clear when the users returns to the dcget() to correct a mismatched name selection

Re: Combo control

Posted: Thu Apr 15, 2010 11:19 am
by sfsltd
Roger

There should be enough to make a demo, but you might like to optimise it and confirm it handles memory properly.

The workaround for the focus issue we had in our earlier code was:
  • not to use a pop-up brows
    reveal a hidden subform
Cliff helped us a lot with the hidden form. He uses that trick in his finance application.

We also had to modify the way XBase handled the cursor keys (by default our earlier code mapped cursor key presses as TAB)

Happy to provide anything that is missing, although you may already have it in the SFW code you have from me.


Michael

Re: Combo control

Posted: Sat Apr 17, 2010 3:53 pm
by sfsltd
Hi Roger

We have tracked down a memory leak when a dialogue control contains a browse

Code: Select all

@ 0,0 DCBROWSE oBrowse  DATA aURecs
Do you have any suggestions on what we need to do to release the memory when we destory the dialog?

Code: Select all

aRecs := {}
LoadTranasctions( @aRecs, cFrom )
@ 15.5,1 DCBROWSE oRecs DATA aRecs ;
      SIZE  88,6 ;
      CURSORMODE XBPBRW_CURSOR_NONE;
      PRESENTATION aPres
DCBROWSECOL Object oListBox ELEMENT 1 PIXEL WIDTH 76 PARENT oRecs
DCBROWSECOL ELEMENT 2 PIXEL WIDTH 137 PARENT oRecs
DCBROWSECOL ELEMENT 3 PIXEL WIDTH 56 PARENT oRecs
DCBROWSECOL ELEMENT 4 PIXEL WIDTH 136 PARENT oRecs ALIGN XBPALIGN_LEFT
DCBROWSECOL ELEMENT 5 PIXEL WIDTH 34 PARENT oRecs ALIGN XBPALIGN_LEFT
DCBROWSECOL ELEMENT 6 PIXEL WIDTH 80 PARENT oRecs ALIGN XBPALIGN_RIGHT
DCBROWSECOL ELEMENT 7 PIXEL WIDTH 83 PARENT oRecs ALIGN XBPALIGN_RIGHT
Thanks

Re: Combo control

Posted: Sat Apr 17, 2010 4:01 pm
by rdonnay
If you can give me a sample program that demonstrates this problem, I will give it the highest priority to help solve it.

Re: Combo control

Posted: Sat Apr 17, 2010 5:21 pm
by sfsltd
Roger

Thanks, we will try to get you a sample on Monday

Michael