/***************************************************************************
* 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.