FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Help, How to ::setfocus() after enter with default button?
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Help, How to ::setfocus() after enter with default button?
Posted: Tue Jan 20, 2009 08:05 AM

Dear all, help please.

I have 3 object in dialog and would like to keep focus at ListBox (All time). But when I press Enter the focus will alway move to Get. Event I set oLbx:SetFocus() in all object (ListBox/Get/Button). I don't know why?

Dialog
ListBox Sequence 1
Get Sequence 2
Button (Default) Sequence 3

Regards,
Dutch

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Tue Jan 20, 2009 12:19 PM
Remove in the resource editor the tabstop property (in Pelles C is on the Window style group) or you can do in runtime

#define  CANTFOCUS      1342177281

****************************************************************************
static procedure RemoveTabStop(oObj)
****************************************************************************
*
* Remove tabstop
* Params: oObj
* Return: Nenhum
*
* Autor: Samir
* 13/1/2009 - 11:15:51
*
****************************************************************************
Local nStyle := 0

   nStyle := CANTFOCUS
   SetWindowLong( oObj:hWnd, GWL_STYLE, nStyle )

Return NIL

/*------------------------------------------------------------------------*/


But I sugest to chage in the resource editor.

PS: you can remove the default propertie from button to
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Tue Jan 20, 2009 12:56 PM
dutch wrote:Dear all, help please.

I have 3 object in dialog and would like to keep focus at ListBox (All time). But when I press Enter the focus will alway move to Get. Event I set oLbx:SetFocus() in all object (ListBox/Get/Button). I don't know why?

Dialog
ListBox Sequence 1
Get Sequence 2
Button (Default) Sequence 3

Regards,
Dutch


Dutch,

If you works with resources, please change the parameter TABSTOP to false. This parameter will keep your object out of the movement of focus.
Always when you press the TAB key, this objects never will get focus!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Wed Jan 21, 2009 09:37 AM
Dear sambomb & JC,

I would like to use TABSTOP for get but need to alway setfocus at listbox after press Enter (with Default Button).
How can I keep FOCUS at LISTBOX and able to TAB to GET and I use Default BUTTON for accept Enter in LISTBOX and GET as below picture.



Regards,
Dutch
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Wed Jan 21, 2009 07:32 PM
/***************************************************************************
* Sistema .....: Testes
* Programa ....: BrowseEdit
* Autor .......: Samir
* Data ........: 12/1/2009 Ć s 09:47:55
* Revisado em .: 12/1/2009 Ć s 09:47:55
***************************************************************************/

#include 'fivewin.ch'
#include 'xbrowse.ch'
#define  GWL_STYLE      -16
#define  PODEFOCAR      1342242817
#define  NAOPODEFOCAR   1342177281

****************************************************************************
FUNCTION BrowseEdit()
****************************************************************************
Private oDlg, oBrw, oBtn, oBtns := Array(5), lTab := .F.

   if !Net_Use("ESTOQUE")
      Return nil
   end

   Select ESTOQUE

   //-- Dialogo ----------------------------------------------------------//

   Define   Dialog   oDlg;
            Resource "BROWSEEDIT";
            of       oWnd

   GeraBrowse()

   Redefine ButtonBMP   oBtn;
            ID          101;
            Action      Alert(GetWindowLong( oBtn:hWnd, GWL_STYLE ));
            Prompt      "Sair  ";
            Bitmap      "SAIR16";
            TEXTRIGHT;
            Update

   Redefine ButtonBMP   oBtns[1];
            ID          4001;
            Action      Muda_Tab(lTab);
            Prompt      "Muda TAB ";
            TEXTRIGHT;
            Update

   Redefine ButtonBMP   oBtns[2];
            ID          4002;
            Action      Alert(GetWindowLong( oBtn:hWnd, GWL_STYLE ));
            Prompt      "WS_VISIBLE ";
            TEXTRIGHT;
            Update

   Redefine ButtonBMP   oBtns[3];
            ID          4003;
            Action      Alert(WS_BORDER);
            Prompt      "WS_BORDER ";
            TEXTRIGHT;
            Update

   Redefine ButtonBMP   oBtns[4];
            ID          4004;
            Action      Alert(WS_TABSTOP);
            Prompt      "WS_TABSTOP ";
            TEXTRIGHT;
            Update

   Redefine ButtonBMP   oBtns[5];
            ID          4005;
            Action      Alert(Upper( oWnd:ClassName() ));
            Prompt      "Upper( oWnd:ClassName() ) ";
            TEXTRIGHT;
            Update

   Activate Dialog   oDlg;
            CENTERED;
            On Init  oBrw:SetFocus()

   //-- Destruir dialogo -------------------------------------------------//

	FreeAndNilDlg(@oDlg)
   Close All

RETURN nil
/*------------------------------------------------------------------------*/

****************************************************************************
static procedure GeraBrowse()
****************************************************************************
*
* Redefinir o browse
* Parametros:
* Retorno: Nenhum
*
* Autor: Samir
* 12/1/2009 - 09:49:13
*
****************************************************************************

local oCol, i := 0

   oBrw := TXBrowse():New( oDlg )
   oBrw:CreateFromResource( 100 )

   //oBrw:SetRDD(.F.,.F.)   //--> Estilo da barra de seleƧao.

   oBrw:cAlias := "ESTOQUE"

   oBrw:nDataType := 0

   //-- Estilo --------------------------------//
   oBrw:lUpdate := .T.
   oBrw:nMarqueeStyle     := MARQSTYLE_HIGHLCELL
   oBrw:nColDividerStyle  := LINESTYLE_LIGHTGRAY
   oBrw:nRowDividerStyle  := LINESTYLE_LIGHTGRAY
   oBrw:nHeaderLines      := 01   //-----------> Linhas do Cabecalho.
   oBrw:lAllowColSwapping := .F.  //-----------> Trocar Colunas
   oBrw:lAllowRowSizing   := .F.  //-----------> Nao move as Linhas
   oBrw:lFooter           := .F.  //-----------> RodapƩ
   oBrw:l2007             := .T.

   //-- Colunas -------------------------------//

   oCol:= oBrw:AddCol()
   oCol:bStrData  := { || EDESC }
   oCol:cHeader   := "Descrição"
   oCol:nWidth    := 300

   oCol:= oBrw:AddCol()
   oCol:bStrData  := { || Transform(EESTOAT, MascaraQtde() ) }
   oCol:cHeader   := "Estoque atual"
   oCol:nWidth    := 85

   oCol:= oBrw:AddCol()
   oCol:bStrData  := { || Transform(EESTOM, MascaraQtde() )  }
   oCol:cHeader   := "Estoque minimo"
   oCol:nWidth    := 85

   oCol:= oBrw:AddCol()
   oCol:bStrData  := { || EUNI  }
   oCol:cHeader   := "UN"
   oCol:nWidth    := 85

   oCol:= oBrw:AddCol()
   oCol:bStrData  := { || Transform(EPRC, MascaraPreco() ) }
   oCol:cHeader   := "PreƧo de custo"
   oCol:nWidth    := 85

   oCol:= oBrw:AddCol()
   oCol:bStrData  := { || Transform(EPRV, MascaraPreco() )  }
   oCol:cHeader   := "PreƧo de venda"
   oCol:nWidth    := 85
   
   For i = 1 to 6
      oBrw:aCols[i]:nDataStrAlign   := AL_RIGHT
      oBrw:aCols[i]:nEditType       := EDIT_GET
   end

   oBrw:aCols[1]:bOnPostEdit     := { |o,x| Edit(x,1)}
   oBrw:aCols[2]:bOnPostEdit     := { |o,x| Edit(x,2)}
   oBrw:aCols[3]:bOnPostEdit     := { |o,x| Edit(x,3)}
   oBrw:aCols[4]:bOnPostEdit     := { |o,x| Edit(x,4)}
   oBrw:aCols[5]:bOnPostEdit     := { |o,x| Edit(x,5)}
   oBrw:aCols[6]:bOnPostEdit     := { |o,x| Edit(x,6)}

   oBrw:aCols[1]:nDataStrAlign := AL_LEFT

   oBrw:bKeyDown := { |nKey| KeyDown(nKey) }

   //-- Cores ---------------------------------//
                                     //--> Cor da barra de seleƧao.
   oBrw:bClrSelFocus      := {|| { CLR_BLACK, nRGB( 250, 250, 125 ) } }

                                     //--> Cor da barra de seleƧao qdo sem foco.
   oBrw:bClrSel           := {|| { CLR_BLACK, nRGB( 255, 200, 125 ) } }

Return Nil

/*------------------------------------------------------------------------*/

****************************************************************************
static procedure Edit(Valor,Col)
****************************************************************************
*
* Editar uma cƩlula
* Parametros: o,x,i
* Retorno: Nenhum
*
* Autor: Samir
* 12/1/2009 - 10:05:54
*
****************************************************************************

   While !Rec_Lock() ; End

   If Col = 1       //-- Descrição
      replace EDESCRICAO   with Valor
   elseIf Col = 2   //-- Estoque atual
      replace EESTOATUAL   with Val(Valor)
   elseIf Col = 3   //-- Estoque minimo
      replace EESTOMIN     with Val(Valor)
   elseIf Col = 4   //-- Unidade 
      replace EUNIDADE     with Valor
   elseIf Col = 5   //-- PreƧo de custo 
      replace EPRCUSTO     with Val(Valor)
   elseIf Col = 6   //-- PreƧo de venda
      replace EPRVENDA     with Val(Valor)
   end
   
   Unlock

   oBrw:Refresh()

   Muda_TAB(.T.)

Return Nil

/*------------------------------------------------------------------------*/

****************************************************************************
static procedure KeyDown(nKey)
****************************************************************************
*
* Definir ação a ser realizada quando pressionada uma tecla
* Parametros: nKey
* Retorno: Nenhum
*
* Autor: Samir
* 12/1/2009 - 09:49:51
*
****************************************************************************

   if nKey = VK_ESCAPE
      oDlg:End()
   elseif nKey = VK_RETURN
      Muda_TAB(.F.)
   end

Return Nil

/*------------------------------------------------------------------------*/

****************************************************************************
static procedure Muda_TAB(lTab)
****************************************************************************
*
* Alterar o tabstop
* Parametros: lTab
* Retorno: Nenhum
*
* Autor: Samir
* 13/1/2009 - 11:15:51
*
****************************************************************************
Local nStyle := i := 0

   nStyle := GetWindowLong( oBtn:hWnd, GWL_STYLE )

   if lTab
      nStyle := PODEFOCAR
   else
      nStyle := NAOPODEFOCAR
   end
   
   SetWindowLong( oBtn:hWnd, GWL_STYLE, nStyle )

   For i = 1 to 5
      SetWindowLong( oBtns[i]:hWnd, GWL_STYLE, nStyle )
   End

   lTab := !lTab

Return NIL

/*------------------------------------------------------------------------*/


Maybe it will help :-)

PS: Muda_Tab( lTab ) change the tabstop properties turning on when .T. and turning off when .F.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Wed Jan 21, 2009 10:19 PM

Dutch,

Try something like:

oGet:bLostFocus:= {|| oLbx:setFocus() }

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Thu Jan 22, 2009 12:07 PM
James Bott wrote:Dutch,

Try something like:

oGet:bLostFocus:= {|| oLbx:setFocus() }

Regards,
James


I think that it won't help, I think he use xBrowse and in xBrowse (my version is 8.04) a bug occurs with enter+edit cell + other object with tabfocus propertie active.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Thu Jan 22, 2009 05:10 PM
Dear James&Sambomb&JC,

It work now, thanks all.

James Bott wrote:Dutch,

Try something like:

oGet:bLostFocus:= {|| oLbx:setFocus() }

Regards,
James


Regards,
Dutch
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Fri Jan 23, 2009 12:13 PM

Congratulations!

PS: how you focus the get now?

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Sun Jan 25, 2009 04:17 PM

Dear Sambomb

I don't remove TABSTOP in GET.

Regards,
Dutch

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Mon Jan 26, 2009 11:19 AM
dutch wrote:Dear Sambomb

I don't remove TABSTOP in GET.

Regards,
Dutch

Sorry... I take a look again and see that the lostfocus is on the get, not in the browse.... Thanks :-)
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Mon Jan 26, 2009 09:55 PM

Samir,

I think you may be confused about the GET. The GET he is referring to is not the GET used to edit a cell of the browse, but a GET at the top of the screen (see his screenshot) used for a search.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Help, How to ::setfocus() after enter with default button?
Posted: Tue Jan 27, 2009 10:50 AM

James, my connection is blocked to allow only some sites... so I can't see the screenshot if it isn't uploaded in an allowed website....

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2

Continue the discussion