FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A Few question about XBrowse.
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
A Few question about XBrowse.
Posted: Sun Sep 07, 2008 02:24 PM
Hi,

1) I want to select a row with enter key. How Can I? I can do it with double click.

2) I have added a button to sample (thanks to nageswaragunupudi) below. Before than I can use the XBrowse object as a default, but after added the button in order to choice from xbrowse i must select it. I wrote the oBrw:SetFocus() on Dialog ON INIT. It did not change anything. How can i focus the XBrowse when i activate the dialog.

Thanks,

#include 'fivewin.ch' 
#include 'xbrowse.ch' 

REQUEST DBFCDX 

function Main() 

   local oDlg, oBrw 
   local oSeek, cSeek := Space(25) 

   USE CUSTOMER NEW ALIAS CUST SHARED VIA 'DBFCDX' 
   SET ORDER TO TAG SALARY 
   GO TOP 

   DEFINE DIALOG oDlg SIZE 540,480 PIXEL 

   @  10, 10 XBROWSE oBrw ; 
      COLUMNS 'First','Last','Salary' ; 
      SIZE 250,200 PIXEL ; 
      OF oDlg ; 
      ALIAS 'CUST' ; 
      AUTOSORT 

   @ 220, 10 SAY oSeek VAR cSeek SIZE 100,10 PIXEL OF oDlg ; 
         COLOR CLR_BLACK, CLR_YELLOW 

   @ 220, 210 BUTTON "&OK" PIXEL OF oDlg 
         
   oBrw:bSeek  := { |cSeek| CUST->( DbSeek( Val( cSeek ), .t. ), !eof() ) } 
   oBrw:oSeek  := oSeek 

   oBrw:CreateFromCode() 

   ACTIVATE DIALOG oDlg CENTERED on INIT oBrw:SetFocus()
 return nil
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
A Few question about XBrowse.
Posted: Sun Sep 07, 2008 05:47 PM
If you want to show a picklist from a dbf ( or any source ) for selection, Xbrowse provides a very simple one line code. Please compile the following sample
#include 'fivewin.ch'
#include 'xbrowse.ch'

function main()

   local cState   := Space( 2 )

   USE STATES NEW SHARED

   XBROWSER 'STATES' SELECT ( cState := STATES->Code )

   if Empty( cState )
      MsgInfo( 'Not Selected' )
   else
      MsgInfo( 'Selected ' + cState )
   endif

return nil

The one line code "XBROWSER 'STATES' SELECT ( cState := STATES->Code )" displays States in a suitably sized xbrowse dialog with "select" button. If the button is clicked the selection is made.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
A Few question about XBrowse.
Posted: Sun Sep 07, 2008 05:54 PM
Here is a screen shot of what the above one line of code can produce

Regards



G. N. Rao.

Hyderabad, India
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
A Few question about XBrowse.
Posted: Sun Sep 07, 2008 06:52 PM

Thanks nageswaragunupudi.

But I could not find any documentation about XBROWSER. I could not compile the code you have given. does XBROWSER support the bSeek Method?

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 12:09 AM

This requires FWH 8.08. Please read whatsnew.txt

Regards



G. N. Rao.

Hyderabad, India
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 08:19 AM

Hmmm. I think I should upgrade the FWH.

Just one question. How Can I detect ENTER key and assign a procedure?

Thanks,

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 08:35 AM
Try this :

** this browse for detail invoice
@145,2 XBROWSE oBrw1  ;
            COLUMNS "DI_ITMABV"  ,; 
                    "DI_MUNITS"  ,;
                    "DI_SALEPRC" ,;
                    "DI_UNTPRC"  ,;
                    "DI_INVQTY"  ,;
                    "DI_DISCNT"  ,;
                    "DI_EXTDAMT"  ;                   
            OF oDlg ;
            SIZE 390,75 PIXEL ;
            PICTURE "@!","@!","9999.99","9999.99","9999.99","99.99%","9999.999" ;
            COLSIZES 270,50,80,80,80,80,80 ;
            HEADERS "Item Description",;
                    "Unit",;
                    "Default Price",;
                    "Sale Price",;
                    "Quantity",;
                    "Discount",;
                    "Amount" ;
              ALIAS "dinvoice" 


   oBrw1:bKeyDown := { |nKey,nFlag| DetailAction(nKey,oBrw1) }
      
   if ! Empty( oCol := oBrw1:aCols[4] ) // Price
       oCol:nEditType   := EDIT_GET
       oCol:bOnPostEdit := {| o, u, n| PostEditDetail( o, u, n ) }
   endif
   
   if ! Empty( oCol := oBrw1:aCols[5] ) // Quantity
       oCol:nEditType   := EDIT_GET
       oCol:bOnPostEdit := {| o, u, n| PostEditDetail( o, u, n ) }
   endif
   
   if ! Empty( oCol := oBrw1:aCols[6] ) // Discount
       oCol:nEditType   := EDIT_GET
       oCol:bOnPostEdit := {| o, u, n| PostEditDetail( o, u, n ) }
   endif
   
   XbrStyles( oBrw1 )   
   oBrw1:CreateFromCode()

************** create this function

static function PostEditDetail( oCol, xValue, nLastKey )

   local nOldVal, nFldNo,nCol := oCol:nPos
   local cAlias := oCol:oBrw:cAlias

   if nLastKey == 13 // this is enter
      nOldVal  := Eval( oCol:bEditValue )
      if !( nOldVal == xValue )
         if dinvoice->(dbrLock())
            do case
               case nCol == 4  // price
                    dinvoice->DI_UNTPRC := xValue
               case nCol == 5  // quantity
                    dinvoice->DI_INVQTY := xValue
               case nCol == 6  // discount
                    dinvoice->DI_DISCNT := xValue
                  
            endcase        
            nHarga := dinvoice->DI_UNTPRC * dinvoice->DI_INVQTY
            nDisc  := 0
            if dinvoice->DI_DISCNT # 0
               nDisc := nHarga * ( dinvoice->DI_DISCNT / 100 )
            endif   
            nTotal := nHarga - nDisc
            dinvoice->DI_EXTDAMT := nTotal
            dinvoice->( dbUnlock() )
            
            SumTotalHeader()
            
         endif
      endif
      oCol:oBrw:goRight()
   endif

return nil


Best Regards
Fafi
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 09:18 AM

Thank you for your reply Fafi.

But I use xbrowse as a picklist. I do not edit any field in the xbrowse. I only want to select the row.

I'll try to use the code you posted. thanks again.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 01:53 PM

Hakan,

>How Can I detect ENTER key and assign a procedure?

Add the DEFAULT clause to your button definition.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 02:40 PM

Thanks James,

There are two condition.

1) There is a button and default.
2) There is not button.

1) if i add the button, user should focus the xbrowse and than choice the desired row and press ENTER to select. It is not usable for user.

2) if i did not add the button, xbrowse is default. it is ok. user can choice the row and ENTER to select.

I need the 2. condition now. I have not any button. I need the select enter key like ON DBLCLICK.

Thanks,

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 02:48 PM

Without a button try:

oBrw:bKeydown := {|nKey,nFlags| ;
IIF(nKey == VK_RETURN, doWhatever(), oDlg:end(),)}

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 03:05 PM
James,

A little typo in your code: the dialog should be closed when enter is pressed. Edited: ops, no its a missing "(" only

Hakan, here you have your example working:
#include 'fivewin.ch' 
#include 'xbrowse.ch' 

REQUEST DBFCDX 

function Main() 

   local oDlg, oBrw 
   local oSeek, cSeek := Space(25) 

   USE CUSTOMER NEW ALIAS CUST SHARED VIA 'DBFCDX' 
   SET ORDER TO TAG SALARY 
   GO TOP 

   DEFINE DIALOG oDlg SIZE 540,480 PIXEL 

   @  10, 10 XBROWSE oBrw ; 
      COLUMNS 'First','Last','Salary' ; 
      SIZE 250,200 PIXEL ; 
      OF oDlg ; 
      ALIAS 'CUST' ; 
      AUTOSORT 
      
   oBrw:bKeyDown = { | nKey, nFlags | If( nKey == VK_RETURN, oDlg:End(),) }   
   oBrw:bLDblClick = { || oDlg:End() }  

   @ 220, 10 SAY oSeek VAR cSeek SIZE 100,10 PIXEL OF oDlg ; 
         COLOR CLR_BLACK, CLR_YELLOW 

   @ 220, 210 BUTTON "&OK" PIXEL OF oDlg ACTION oDlg:End()
          
   oBrw:bSeek  := { |cSeek| CUST->( DbSeek( Val( cSeek ), .t. ), !eof() ) } 
   oBrw:oSeek  := oSeek 

   oBrw:CreateFromCode() 

   ACTIVATE DIALOG oDlg CENTERED

 return nil

edited: added code for closing wirth double click too
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 03:31 PM

Antonio,

>A little typo in your code: the dialog should be closed when enter is pressed.

Ops. I meant it to be:

oBrw:bKeydown := {|nKey,nFlags| ;
IIF(nKey == VK_RETURN, ( doWhatever(), oDlg:end() ), ) }

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 08:48 PM

Thank you very much James, Antonio.

It works perfectly.

Antonio : How Can get the new TComboBox class?

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
A Few question about XBrowse.
Posted: Mon Sep 08, 2008 10:57 PM

Hakan,

> How Can get the new TComboBox class?

Please check your email :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion