Habilitar/desatiblitar hedit
Enviado: 26 Fev 2023 15:01
Não encontrei aonde habilitar/desabilitar o hedit
Tem como?
Tem como?
Código: Selecionar todos
@ nCol + Int( ::nFontSize * 11 ), nRow GET oControl VAR aEdit[ HEDIT_VALUE ] SIZE aEdit[ DBS_LEN ] * Int( ::nFontSize * 1.2 ), Int( ::nFontSize * 2 ) ;
STYLE iif( aEdit[ DBS_TYPE ] == "N", ES_RIGHT, ES_LEFT ) ;
MAXLENGTH aEdit[ DBS_LEN ]
oControl:Disable()
Está sendo atribuído o mesmo nome a todos os controles, oBtn pra button, oControl pra hedit.SYSTEM ERROR
Error BASE/1004 No exported method: DISABLE
Called from DISABLE(0)
Called from ONEFRMCLASS:TELACREATE(222)
Called from ONEFRMCLASS:EXECUTE(108)
Called from EXECUTE(35)
Called from PTESHWGUICADASTRO(24)
Called from DO(0)
Called from DOPRG(144)
Called from (b)RUNMODULE(120)
(1) = Tipo: A Valor: __itemSetObj( __itemSetRef( {{{"OBJNAME", "OBTN"}, {"OPARENT", {{"TITLE", "teste"}, {"TYPE", 11}, {"NTOP", 0}, {"NLEFT", 0}, {"NWIDTH", 1188}, {"NHEIGHT", 798}, {"BRUSH",
Código: Selecionar todos
FOR nCont = 1 TO Len( ::oFrm:aControls )
IF __ObjHasMsg( ::oFrm:aControls[ nCont ], "BSETGET" ) .AND. ::oFrm:aControls[ nCont ]:bSetGet != Nil
::oFrm:aControls[ nCont ]:Disable()
ENDIF
NEXT
Código: Selecionar todos
FOR nCont = 1 TO Len( ::oFrm:aControls )
IF ::oFrm:aControls[ nCont ]:winClass== "EDIT"
::oFrm:aControls[ nCont ]:Disable()
ENDIF
NEXT
Código: Selecionar todos
CLASS HEdit INHERIT HControl
CLASS VAR winclass INIT "EDIT"
Código: Selecionar todos
CLASS HControl INHERIT HCustomWindow
DATA id
DATA tooltip
DATA lInit INIT .F.
DATA Anchor INIT 0
METHOD New( oWndParent, nId, nStyle, nLeft, nTop, nWidth, nHeight, ;
oFont, bInit, bSize, bPaint, cTooltip, tcolor, bColor )
METHOD NewId()
METHOD Init()
METHOD Disable()
METHOD Enable()
METHOD Enabled( lEnabled ) SETGET
Código: Selecionar todos
...
METHOD Enabled( lEnabled ) SETGET
...
METHOD Disable() CLASS HControl
hwg_Enablewindow( ::handle, .F. )
RETURN NIL
METHOD Enable() CLASS HControl
hwg_Enablewindow( ::handle, .T. )
RETURN NIL
METHOD Enabled( lEnabled ) CLASS HControl
IF lEnabled != Nil
IF lEnabled
hwg_Enablewindow( ::handle, .T. )
RETURN .T.
ELSE
hwg_Enablewindow( ::handle, .F. )
RETURN .F.
ENDIF
ENDIF
RETURN hwg_Iswindowenabled( ::handle )
Código: Selecionar todos
oControl:Enabled := .F.
Código: Selecionar todos
#include "hbclass.ch"
#include "hwgui.ch"
#include "dbstruct.ch"
#include "directry.ch"
#include "hbgtinfo.ch"
#include "ze_rmchart.ch"
#define HEDIT_VALUE 5
#define HEDIT_CONTROL 6
PROCEDURE PTEShwguiCadastro( cModule, cTitle, ... )
LOCAL aFileList, aFile
(cModule)
(cTitle)
SET EXCLUSIVE OFF
aFileList := Directory( "*.dbf" )
IF Len( aFileList ) == 0
? "sem arquivos para teste"
Inkey(0)
ENDIF
FOR EACH aFile IN aFileList
Execute( hb_FNameName( aFile[ F_NAME ] ) )
NEXT
RETURN
FUNCTION Execute( cFile )
LOCAL oFrm
oFrm := OneFrmClass():New( "teste", "teste", "CIAGEPU+-" )
oFrm:cFileDBF := cFile
oFrm:Execute()
RETURN Nil
CREATE CLASS OneFrmClass INHERIT FrmClass
// To create specific frm derived from main
ENDCLASS
CREATE CLASS FrmClass
VAR oFrm
VAR cPRGName
VAR cOptions
VAR cTitulo
VAR cFileDBF
VAR hEditList INIT {}
VAR nFontSize INIT 10
METHOD New( cTitulo, cModulo, cOptions, cFileDBF )
METHOD CreateButtons()
METHOD Execute()
METHOD Consulta() INLINE Nil
METHOD Altera() INLINE Nil
METHOD Exclui() INLINE Nil
METHOD Inclui() INLINE Nil
METHOD Primeiro() INLINE &( ::cFileDbf )->( dbgotop() ), ::TelaUpdate()
METHOD Ultimo() INLINE &( ::cFileDbf )->( dbgobottom() ), ::TelaUpdate()
METHOD Seguinte() INLINE &( ::cFileDbf )->( dbSkip() ), ::TelaUpdate()
METHOD Anterior() INLINE &( ::cFileDbf )->( dbSkip( -1 ) ), ::TelaUpdate()
METHOD Sair() INLINE ::oFrm:Close()
METHOD Grafico()
METHOD TelaUpdate()
METHOD TelaCreate()
ENDCLASS
METHOD New( cTitulo, cModulo, cOptions, cFileDBF ) CLASS FrmClass
::cPRGName := cModulo
::cOptions := cOptions
::cTitulo := cTitulo
::cFileDBF := cFileDBF
::nFontSize := hb_gtInfo( HB_GTI_FONTWIDTH )
RETURN Self
METHOD Grafico()
LOCAL aColors := { RMC_COLOR_LIGHT_GREEN, RMC_COLOR_YELLOW, RMC_COLOR_GOLDENROD, RMC_COLOR_CRIMSON }
LOCAL aData := { 40, 30, 60, 20 }
LOCAL oRmChart := RMChartClass():New()
LOCAL ID_RMC1 := 1
oRmChart:CreateChart( hwg_GetActiveWindow(), ID_RMC1, 0, 0, 790, 590, RMC_COLOR_MIDNIGHT_BLUE, RMC_CTRLSTYLEIMAGE, .F., "seasky.jpg", "Tahoma", 0, RMC_COLOR_DEFAULT )
oRMChart:AddRegion( ID_RMC1, 5, 5, -5, -5, "", .F. )
oRMChart:AddLegend( ID_RMC1, 1, "Apples*Citrons*Bananas*Cherries", RMC_LEGEND_CUSTOM_CENTER, RMC_COLOR_DEFAULT, RMC_LEGENDNORECT, RMC_COLOR_WHITE, 8, .F. )
oRmChart:AddGridlessSeries( ID_RMC1, 1, aData, 4, aColors, 4, RMC_DONUT_GRADIENT, RMC_FULL, 0, .F., RMC_VLABEL_TWIN, RMC_HATCHBRUSH_OFF, 0 )
oRmChart:SetWatermark( RMC_USERWM, RMC_USERWMCOLOR, RMC_USERWMLUCENT, RMC_USERWMALIGN, RMC_USERFONTSIZE )
oRmChart:Draw( ID_RMC1 )
ORMChart:Reset( ID_RMC1 )
RETURN Nil
METHOD Execute() CLASS FrmClass
SELECT 0
USE ( ::cFileDBF )
INIT DIALOG ::oFrm CLIPPER NOEXIT TITLE ::cTitulo ;
AT AppWindowRect( 1 ), AppWindowRect( 2 ) SIZE AppWindowRect( 3 ), AppWindowRect( 4 ) ;
BACKCOLOR ze_DlgBackColor() ON EXIT hwg_EndDialog()
::CreateButtons()
::TelaCreate()
ACTIVATE DIALOG ::oFrm CENTER
RETURN Nil
METHOD CreateButtons() CLASS FrmClass
LOCAL nRow, nCol, acOptions := {}, cCaption, bCode, oBtn, cIcon, nRowLine := 1, nCont
//PREPARE FONT oFont NAME "Times New Roman" WIDTH 0 HEIGHT 20 WEIGHT 400
IF "I" $ ::cOptions
AAdd( acOptions, "Inclui" )
ENDIF
IF "A" $ ::cOptions
AAdd( acOptions, "Altera" )
ENDIF
IF "C" $ ::cOptions
AAdd( acOptions, "Consulta" )
ENDIF
IF "E" $ ::cOptions
AAdd( acOptions, "Exclui" )
ENDIF
IF "P" $ ::cOptions
AAdd( acOptions, "Primeiro" )
ENDIF
IF "-" $ ::cOptions
AAdd( acOptions, "Anterior" )
ENDIF
IF "+" $ ::cOptions
AAdd( acOptions, "Seguinte" )
ENDIF
IF "U" $ ::cOptions
AAdd( acOptions, "Último" )
ENDIF
IF "G" $ ::cOptions
AAdd( acOptions, "Grafico" )
ENDIF
AAdd( acOptions, "Sair" )
FOR nCont = 1 TO 10
AAdd( acOptions, "test" + Ltrim( Str( nCont ) ) )
NEXT
nCol := 10
nRow := 10
FOR EACH cCaption IN acOptions
DO CASE
CASE cCaption == "Consulta"; cIcon := "icoSearch" ; bCode := { || ::Consulta() }
CASE cCaption == "Inclui"; cIcon := "icoPlus" ; bCode := { || ::Inclui() }
CASE cCaption == "Altera"; cIcon := "icoEdit" ; bCode := { || ::Altera() }
CASE cCaption == "Exclui"; cIcon := "icoTrash" ; bCode := { || ::Exclui() }
CASE cCaption == "Primeiro"; cIcon := "icoGoFirst" ; bCode := { || ::Primeiro() }
CASE cCaption == "Último"; cIcon := "icoGoLast" ; bCode := { || ::Ultimo() }
CASE cCaption == "Seguinte"; cIcon := "icoGoRight" ; bCode := { || ::Seguinte() }
CASE cCaption == "Anterior"; cIcon := "icoGoLeft" ; bCode := { || ::Anterior() }
CASE cCaption == "Grafico"; cIcon := "icoChart" ; bCode := { || ::Grafico() }
CASE cCaption == "Sair"; cIcon := "icoDoor" ; bCode := { || ::Sair() }
OTHERWISE ; cIcon := "AppIcon" ; bCode := { || Nil }
ENDCASE
@ nCol, nRow OWNERBUTTON oBtn OF ::oFrm SIZE 80, 80 ;
ON CLICK bCode ;
BITMAP HICON():AddResource( cIcon, 60, 60 ) COORDINATES 5, 5, 60, 60 ;
TEXT cCaption COORDINATES 5, 61, 75, 5 ;
Tooltip cCaption
oBtn:aStyle := ze_StyleBtn()
//@ nCol, nRow ICON IconFromCaption( cCaption ) ;
// FROM RESOURCE ;
// SIZE 55, 55 ;
// ON CLICK bCode ;
// TOOLTIP cCaption
//@ nCol, nRow BUTTONEX cCaption ;
// SIZE 55,55 ;
// ICON Atail( ::aIconList ) ;
// TRANSPARENT
IF nRowLine == 1 .AND. nCol > AppWindowRect( 3 ) - AppWindowRect( 1 ) - 10 - 85
nRowLine += 1
nRow += 85
nCol := AppWindowRect( 3 ) - AppWindowRect( 1 ) - 10
ENDIF
nCol += iif( nRowLine == 1, 85, -85 )
NEXT
RETURN Nil
METHOD TelaCreate() CLASS FrmClass
LOCAL oElement, nRow, nCol, aEdit, oControl, nCont
::hEditList := dbStruct()
FOR EACH oElement IN ::hEditList
aSize( oElement, 6 )
oElement[ HEDIT_VALUE ] := &( ::cFileDbf )->( FieldGet( oElement:__EnumIndex ) )
NEXT
nRow := Int( ::nFontSize * 11 )
nCol := Int( ::nFontSize / 2 )
FOR EACH aEdit IN ::hEditList
IF nCol + Int( ::nFontSize * 5 ) + aEdit[ DBS_LEN ] * int( ::nFontSize * 1.2 ) + Int( ::nFontSize * 5 ) > AppWindowRect( 3 ) - AppWindowRect( 1 ) - ::nFontSize * 2
nCol := Int( ::nFontSize / 2 )
nRow += Int( ::nFontSize * 2.5 )
ENDIF
@ nCol, nRow SAY aEdit[ DBS_NAME ] SIZE Int( ::nFontSize * 10 ), Int( ::nFontSize * 2 ) TRANSPARENT
@ nCol + Int( ::nFontSize * 11 ), nRow GET oControl VAR aEdit[ HEDIT_VALUE ] SIZE aEdit[ DBS_LEN ] * Int( ::nFontSize * 1.2 ), Int( ::nFontSize * 2 ) ;
STYLE iif( aEdit[ DBS_TYPE ] == "N", ES_RIGHT, ES_LEFT ) ;
MAXLENGTH aEdit[ DBS_LEN ]
aEdit[ HEDIT_CONTROL ] := oControl
IF aEdit:__EnumIndex < 5
nCol += 5000
ELSE
nCol += Int( ::nFontSize * 10 ) + aEdit[ DBS_LEN ] * Int( ::nFontSize * 1.2 ) + Int( ::nFontSize * 5 )
ENDIF
NEXT
FOR nCont = 1 TO Len( ::oFrm:aControls )
IF ::oFrm:aControls[ nCont ]:winClass == "EDIT"
::oFrm:aControls[ nCont ]:Enabled := .F.
ENDIF
NEXT
RETURN Nil
METHOD TelaUpdate() CLASS frmClass
LOCAL aEdit, nCont
FOR EACH aEdit IN ::hEditList
aEdit[ HEDIT_CONTROL ]:Value( &( ::cFileDbf )->( FieldGet( aEdit:__EnumIndex ) ) )
NEXT
FOR nCont = 1 TO Len( ::oFrm:aControls )
IF ::oFrm:aControls[ nCont ]:winClass == "EDIT"
::oFrm:aControls[ nCont ]:Enabled := .F.
ENDIF
NEXT
RETURN Nil
Código: Selecionar todos
AAdd( acOptions, "ControlList" )
Código: Selecionar todos
CASE cCaption == "ControlList" ; cIcon := "AppIcon" ; bCode := { || ::ControlList() }
Código: Selecionar todos
METHOD ControlList() CLASS frmClass
LOCAL oControl, cTxt := "", cTxtTmp := ""
FOR EACH oControl IN ::oFrm:aControls
IF Len( cTxtTmp ) > 500
cTxt += cTxtTmp + hb_Eol()
cTxtTmp := ""
ENDIF
cTxtTmp += oControl:winClass + Ltrim( Str( oControl:id ) ) + " "
NEXT
cTxt += cTxtTmp
hwg_MsgInfo( cTxt )
RETURN Nil
Código: Selecionar todos
AAdd( acOptions, "Sair" )
AAdd( acOptions, "ControlList" )
FOR nCont = 1 TO 10
AAdd( acOptions, "test" + Ltrim( Str( nCont ) ) )
NEXT
Código: Selecionar todos
IF "test" $ cCaption
oBtn:lEnabled := .F.
ENDIF
Código: Selecionar todos
OTHERWISE ; cIcon := "AppIcon" ; bCode := { || hwg_MsgInfo( cCaption ) }