A Few question about XBrowse.

A Few question about XBrowse.

Postby Horizon » Sun Sep 07, 2008 2: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,

Code: Select all  Expand view  RUN
#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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby nageswaragunupudi » Sun Sep 07, 2008 5: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
Code: Select all  Expand view  RUN
#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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Sun Sep 07, 2008 5:54 pm

Here is a screen shot of what the above one line of code can produce

Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Horizon » Sun Sep 07, 2008 6: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby nageswaragunupudi » Mon Sep 08, 2008 12:09 am

This requires FWH 8.08. Please read whatsnew.txt
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Horizon » Mon Sep 08, 2008 8: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby fafi » Mon Sep 08, 2008 8:35 am

Try this :

Code: Select all  Expand view  RUN
** 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
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Postby Horizon » Mon Sep 08, 2008 9: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby James Bott » Mon Sep 08, 2008 1:53 pm

Hakan,

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

Add the DEFAULT clause to your button definition.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Horizon » Mon Sep 08, 2008 2: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby James Bott » Mon Sep 08, 2008 2:48 pm

Without a button try:

oBrw:bKeydown := {|nKey,nFlags| ;
IIF(nKey == VK_RETURN, doWhatever(), oDlg:end(),)}
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Mon Sep 08, 2008 3: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:
Code: Select all  Expand view  RUN
#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
Last edited by Antonio Linares on Mon Sep 08, 2008 3:36 pm, edited 2 times in total.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42111
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Mon Sep 08, 2008 3: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Horizon » Mon Sep 08, 2008 8: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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42111
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 79 guests