/***************************************************************************
* Sistema .....: BrwSample
* Programa ....:
* Autor .......: Anderson
* Data ........: 15/02/2008 às 13:35:56
* Revisado em .: 15/02/2008 às 13:35:56
***************************************************************************/
#include 'fivewin.ch'
#include 'xbrowse.ch'
****************************************************************************
function Main()
****************************************************************************
local cWallPaper := '', oBgBmp := nil, nWidth := nHeight := 0,;
cTitle := ""
public oWnd
set Bell Off
set Console Off
set Delimiters Off
set Century On
set Echo Off
set Exclusive Off
set Menu Off
set Intensity On
set Printer Off
set Scoreboard Off
set Delete On
set Wrap On
set Status Off
set 3dlook On
set Talk Off
set Date Brit
set Epoch to 1920
set Device To Screen
set Typeahead To 2048
set Decimal To 2
SetBalloon(.t.)
//-- Icone (Deve ser o primeiro icone do .res) -------------------------//
oIcon := TIcon():New(,,"RCA",,)
//-- Window ------------------------------------------------------------//
cTitle := "RCA Sistemas - WBrowse Sample"
Define Window oWnd ;
Title cTitle ;
Menu CreateMenu() ;
Icon oIcon ;
FROM 0, 0 TO 600,800
oWnd:nHeight := oWnd:nVertRes
oWnd:nWidth := oWnd:nHorzRes
//-- KeyDown -----------------------------------------------------------//
cWallPaper := "BG"
nHeight := 440
nWidth := 440
nLeft := ( oWnd:nHorzRes() - nWidth ) / 2
nTop := ( oWnd:nVertRes() - nHeight) / 2
@ nTop,nLeft Image oImage ;
resource cWallPaper ;
Of oWnd ;
no border ;
Pixel
//-- Barra de ferramentas ----------------------------------------------//
CreateToolBar()
//-- Barra de status ---------------------------------------------------//
Barra()
//-- Ativa a janela ----------------------------------------------------//
Activate Window oWnd Maximized ;
valid ValidClose()
//-- Encerra a procedure principal -------------------------------------//
return( NIL )
/*------------------------------------------------------------------------*/
****************************************************************************
static procedure CreateToolBar()
****************************************************************************
*
* Criar a barra de ferramentas da janela principal
* Parametros: Nenhum
* Retorno: Nenhum
*
* Autor: anderson
* 18/7/2007 - 16:44:24
*
****************************************************************************
local oToolBar := Nil
//-- Barra de ferramentas ----------------------------------------------//
DEFINE ButtonBar oToolBar of oWnd Size 80, 70 2007
Define Button ;
OF oToolBar ;
prompt "Dialogo" ;
Resource "Dialog48" ;
action ShowDlg();
Group
Define BUTTON ;
OF oToolBar ;
prompt "Sair" ;
Resource "Sair48" ;
Action (oWnd:End()) ;
Group
Return Nil
/*------------------------------------------------------------------------*/
****************************************************************************
static function CreateMenu()
****************************************************************************
*
* Criar um objeto menu
* Parametros: Nenhum
* Retorno: Objeto - Menu da janela principal
*
* Autor: Anderson
* 17/7/2007 - 12:24:35
*
****************************************************************************
local Result := Nil
menu Result 2007
menuitem "Menu"
menu
menuitem "Browse piscando" ;
message "Exibir browse piscando" ;
action ShowDlg() ;
resource "Dialog16" ;
helpid ""
separator
menuitem "Sai&r" ;
message "Fechar sistema" ;
accelerator ACC_NORMAL, VK_ESCAPE ;
resource "Sair16" ;
action oWnd:End()
endmenu
endmenu
Return Result
/*------------------------------------------------------------------------*/
****************************************************************************
static function ValidClose()
****************************************************************************
*
* Validar a saida do sistema
* Parametro: Nenhum
* Retorno: Lógico - se permite ou nao sair
*
* Autor: Anderson
* 17/7/2007 - 12:32:42
*
****************************************************************************
local Result := .f.
Result := Sn('Deseja sair do sistema')
Return Result
/*------------------------------------------------------------------------*/
****************************************************************************
function Barra(cMensagem)
****************************************************************************
local oFntMess, cWndName := ""
default cMensagem := "Copyright © 2008 - RCA Sistemas Ltda."
SysRefresh()
Define Font oFntMess Name "Tahoma"
set message ;
of oWnd ;
to cMensagem ;
2007 ;
centered ;
Font oFntMess
SysRefresh()
return NIL
/*------------------------------------------------------------------------*/
****************************************************************************
function SN(cQuestion,cDefault)
****************************************************************************
local cAlias
cDefault := if(ValType(cDefault) != "C","S",cDefault)
cAlias := Alias()
cQuestion := StrTran(cQuestion,";",chr(13))
if Upper(cDefault) == "N" // Foco fica em Nao.
Result := MsgNoYes(AllTrim(cQuestion) + " ?" ,"Confirmação")
else
Result := MsgYesNo(AllTrim(cQuestion) + " ?" ,"Confirmação")
endif
if .not. Empty(AllTrim(cAlias))
Select (cAlias)
end
return Result
/*------------------------------------------------------------------------*/
/***************************************************************************
* Sistema .....: WBrowseSample
* Programa ....: DlgWBrw.PRG
* Autor .......: Anderson
* Data ........: 15/02/2008 às 14:18:56
* Revisado em .: 15/02/2008 às 14:18:56
***************************************************************************/
****************************************************************************
/*FUNCTION ShowDlg()
****************************************************************************
Private oDlg := Nil, oBrw, oTmr
select 0
use customer
Define Dialog oDlg ;
of oWnd ;
resource "DLG"
//-- Browse -----------------------------------------------------------//
Redefine LISTBOX oBrw ;
FIELDS FIRST, ;
LAST, ;
STREET, ;
if(MARRIED,'True','False'), ;
Str(AGE), ;
Str(SALARY) ;
HEADERS "Nome","Sobrenome","Endereço", ;
"Casado","Idade","Salario" ;
Sizes 090,090,090,060,100,100 ;
ID 4001 ;
OF oDlg
oBrw:nClrPane := {|| ClrPaneBrw() }
Activate Dialog oDlg ;
Center ;
on init OnInit()
oTmr:Deactivate()
close all
RETURN nil
*/
/*------------------------------------------------------------------------*/
****************************************************************************
/*------------------------------------------------------------------------*/
FUNCTION ShowDlg()
Private oDlg := Nil, oBrw, oTmr
select 0
USE CUSTOMER ALIAS CUST
Define Dialog oDlg ;
of oWnd ;
SIZE 800,600
@ 10, 10 XBROWSE oBrw OF oDlg ;
SIZE 400, 400 PIXEL ;
AUTOCOLS ALIAS 'CUST' BACKGROUND ""
oBrw:nRowDividerStyle = LINESTYLE_NOLINES
oBrw:nColDividerStyle = LINESTYLE_NOLINES
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
oBrw:bClrStd := { || ClrPaneBrw() } // colori
oBrw:CreateFromCode()
Activate Dialog oDlg ;
Center ;
on init OnInit()
oTmr:Deactivate()
close all
RETURN nil
static procedure OnInit()
Define Timer oTmr ;
Interval 1000 ;
Of oDlg ;
action oBrw:Refresh()
// Action (oBrw:Paint(),oBrw:Refresh(),oBrw:UpStable())
Activate Timer oTmr
Return Nil
static function ClrPaneBrw()
local Result := nRgb(255,255,255)
Local aCol:={ }
if CUST->MARRIED
Result := nRgb(200,200,223)
elseif CUST->AGE > 80
if Val(Right(Time(),2)) % 2 == 0
Result := nRgb(255,0,255)
else
Result := nRgb(0,255,0)
end
end
Return aCol:={CLR_BLACK,Result }