#INCLUDE "PROTHEUS.CH"
#INCLUDE "TRYEXCEPTION.CH"
/*/
Funcao: U_TContainer()
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
User Function TContainer()
Local bWindowInit
Local cTitle := "The Container"
Local nVarNameLen := SetVarNameLen( 100 ) //Redefino para poder usar Nomes Longos
Local oBmpNaraku
IF !( Type( "oMainWnd" ) == "O" )
Private oMainWnd
bWindowInit := { || Pandora() , oMainWnd:End() }
DEFINE WINDOW oMainWnd FROM 001,001 TO 400,500 TITLE OemToAnsi( cTitle )
@ 0,0 BITMAP oBmpNaraku RESNAME "NARAKU" OF oMainWnd SIZE 0,0 NOBORDER WHEN .F. PIXEL
oBmpNaraku:lAutoSize := .T.
oBmpNaraku:lStretch := .T.
oBmpNaraku:Align := CONTROL_ALIGN_ALLCLIENT
ACTIVATE WINDOW oMainWnd MAXIMIZED ON INIT Eval( bWindowInit )
Else
Pandora()
EndIF
SetVarNameLen( nVarNameLen ) //Restauro o Padrao
Return( NIL )
/*/
Funcao: Pandora
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function Pandora()
Local aButtons := {}
Local aAdvSize := MsAdvSize( NIL , .F. )
Local aInfoAdvSize := { aAdvSize[1] , aAdvSize[2] , aAdvSize[3] , aAdvSize[4] , 0 , 0 }
Local aObjCoords := { { 000 , 000 , .T. , .T. } }
Local aMsObjSize := MsObjSize( aInfoAdvSize , aObjCoords )
Local bSet15 := { || oDlg:End() }
Local bSet24 := { || oDlg:End() }
Local bInitDlg := { || EnchoiceBar( @oDlg , @bSet15 , @bSet24 , NIL , @aButtons ) }
Local oDlg
Local oBtnWally
Local oHideEBar
Local oShowEBar
Private cAcesso := "" //humpf... EnchoiceBar() necessita Disso...
DEFINE MSDIALOG oDlg TITLE "Pandora" FROM aAdvSize[7],0 TO aAdvSize[6],aAdvSize[5]/1.3 OF GetWndDefault() PIXEL
@ 0,0 BITMAP oBmpPandora RESNAME "PANDORA" OF oDlg SIZE 0,0 NOBORDER WHEN .F. PIXEL
oBmpPandora:lAutoSize := .T.
oBmpPandora:lStretch := .T.
oBmpPandora:Align := CONTROL_ALIGN_ALLCLIENT
@ ( aMsObjSize[1,1] ) + 005 , ( aMsObjSize[1,2] ) BUTTON oBtnWally PROMPT OemToAnsi( "Onde Está Wally?" ) OF oDlg SIZE 150,13 PIXEL ACTION ShowWally()
@ ( aMsObjSize[1,1] ) + 020 , ( aMsObjSize[1,2] ) BUTTON oHideEBar PROMPT OemToAnsi( "Esconda a Enchoice Bar" ) OF oDlg SIZE 150,13 PIXEL ACTION HideEnchoiceBar()
@ ( aMsObjSize[1,1] ) + 035 , ( aMsObjSize[1,2] ) BUTTON oShowEBar PROMPT OemToAnsi( "Apresente a Enchoice Bar" ) OF oDlg SIZE 150,13 PIXEL ACTION ShowEnchoiceBar()
@ ( aMsObjSize[1,1] ) + 050 , ( aMsObjSize[1,2] ) BUTTON oHideEBar PROMPT OemToAnsi( "Esconda Botão Ok da Enchoice Bar" ) OF oDlg SIZE 150,13 PIXEL ACTION HideBOKEnchoiceBar()
@ ( aMsObjSize[1,1] ) + 065 , ( aMsObjSize[1,2] ) BUTTON oShowEBar PROMPT OemToAnsi( "Apresente Botão Ok da Enchoice Bar" ) OF oDlg SIZE 150,13 PIXEL ACTION ShowBOKEnchoiceBar()
@ ( aMsObjSize[1,1] ) + 080 , ( aMsObjSize[1,2] ) BUTTON oHideEBar PROMPT OemToAnsi( "Esconda Botão Cancel da Enchoice Bar" ) OF oDlg SIZE 150,13 PIXEL ACTION HideBCancelEnchoiceBar()
@ ( aMsObjSize[1,1] ) + 095 , ( aMsObjSize[1,2] ) BUTTON oShowEBar PROMPT OemToAnsi( "Apresente Botão Cancel da Enchoice Bar" ) OF oDlg SIZE 150,13 PIXEL ACTION ShowBCancelEnchoiceBar()
@ ( aMsObjSize[1,1] ) + 110 , ( aMsObjSize[1,2] ) BUTTON oHideEBar PROMPT OemToAnsi( "Esconda Todos os Botões da Enchoice Bar" ) OF oDlg SIZE 150,13 PIXEL ACTION HideAllButtonsEnchoiceBar()
@ ( aMsObjSize[1,1] ) + 125 , ( aMsObjSize[1,2] ) BUTTON oShowEBar PROMPT OemToAnsi( "Apresente Todos os Botões da Enchoice Bar" ) OF oDlg SIZE 150,13 PIXEL ACTION ShowAllButtonsEnchoiceBar()
ACTIVATE DIALOG oDlg CENTERED ON INIT Eval( bInitDlg )
Return( NIL )
/*/
Funcao: ShowWally
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function ShowWally()
Local aBitMap := FindMsObject( "TBITMAP" )
Local aButtons := FindMsObject( "TBUTTON" )
Local aMsDialg := FindMsObject( "MSDIALOG" )
Local oDlg := aMsDialg[ aScan( aMsDialg , { |oObj| ( oObj:cCaption == OemToAnsi( "Pandora" ) ) } ) ]
Local oBtnWally := GetOctlFocus()
Local oDlgWally
Local oBmpWally
Local oHideWally
TRYEXCEPTION
oBmpWally := aBitMap[ aScan( aBitMap , { |oObj| ( oObj:cResName == OemToAnsi( "WALLY" ) ) } ) ]
ENDEXCEPTION
TRYEXCEPTION
oHideWally := aButtons[ aScan( aButtons , { |oObj| ( oObj:cCaption == OemToAnsi( "Olá, eu Sou Wally. Clique aqui e me esconda" ) ) } ) ]
ENDEXCEPTION
TRYEXCEPTION
oDlgWally := aButtons[ aScan( aButtons , { |oObj| ( oObj:cCaption == OemToAnsi( "Ou, aqui, me Mostre em uma Nova Dialog" ) ) } ) ]
ENDEXCEPTION
IF ( oBtnWally:cCaption == "Se Escondeu a ele, Apresente-o Clicando aqui" )
oHideWally := aButtons[ aScan( aButtons , { |oObj| ( oObj:cCaption == OemToAnsi( "Olá, eu Sou Wally. Clique aqui e me esconda" ) ) } ) ]
oBmpWally := aBitMap[ aScan( aBitMap , { |oObj| ( oObj:HWND == 4020 ) } ) ]
EndIF
IF !( ValType( oBmpWally ) == "O" )
@ 015,170 BITMAP oBmpWally RESNAME "WALLY" OF oDlg SIZE 500,500 NOBORDER WHEN .F. PIXEL MESSAGE OemToAnsi( "Olá, eu Sou Wally?" )
Else
oBmpWally:Show()
EndIF
IF !( ValType( oHideWally ) == "O" )
@ 175,170 BUTTON oHideWally PROMPT OemToAnsi( "Olá, eu Sou Wally. Clique aqui e me esconda" ) OF oDlg SIZE 180,13 PIXEL ACTION HideWally()
Else
oHideWally:Show()
EndIF
IF !( ValType( oDlgWally ) == "O" )
@ 190,170 BUTTON oDlgWally PROMPT OemToAnsi( "Ou, aqui, me Mostre em uma Nova Dialog" ) OF oDlg SIZE 180,13 PIXEL ACTION ShowNewWally()
Else
oDlgWally:Show()
EndIF
oBtnWally:bAction := { || MsgInfo( "Já Me Encontrou" , "WALLY" ) }
Return( .T. )
/*/
Funcao: HideWally
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function HideWally()
Local aBitMap := FindMsObject( "TBITMAP" )
Local aButtons := FindMsObject( "TBUTTON" )
Local oDlgWally := aButtons[ aScan( aButtons , { |oObj| ( oObj:cCaption == OemToAnsi( "Ou, aqui, me Mostre em uma Nova Dialog" ) ) } ) ]
Local oBmpWally := aBitMap[ aScan( aBitMap , { |oObj| ( oObj:cResName == OemToAnsi( "WALLY" ) ) } ) ]
Local oBtnWally := aButtons[ aScan( aButtons , { |oObj| ( oObj:cCaption == OemToAnsi( "Onde Está Wally?" ) ) } ) ]
Local oHideWally := GetOctlFocus()
Local oShowWally
IF ( oHideWally:cCaption == "Esconda o Meu Parente" )
oHideWally := aButtons[ aScan( aButtons , { |oObj| ( oObj:cCaption == OemToAnsi( "Olá, eu Sou Wally. Clique aqui e me esconda" ) ) } ) ]
oHideWally:Hide()
oBmpWally := aBitMap[ aScan( aBitMap , { |oObj| ( oObj:HWND == 4020 ) } ) ]
oBmpWally:Hide()
oDlgWally:Hide()
oShowWally := aButtons[ aScan( aButtons , { |oObj| ( oObj:cCaption == OemToAnsi( "Se Escondeu a ele, Apresente-o Clicando aqui" ) ) } ) ]
oShowWally:bAction := { || ShowWally() }
Else
oHideWally:Hide()
oBmpWally:Hide()
oBtnWally:bAction := { || ShowWally() }
oDlgWally:Hide()
EndIF
Return( .T. )
/*/
Funcao: ShowNewWally
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function ShowNewWally()
Local aButtons := {}
Local aAdvSize := MsAdvSize( .F. , .F. )
Local aInfoAdvSize := { aAdvSize[1] , aAdvSize[2] , aAdvSize[3] , aAdvSize[4] , 0 , 0 }
Local aObjCoords := { { 000 , 000 , .T. , .T. } }
Local aMsObjSize := MsObjSize( aInfoAdvSize , aObjCoords )
Local bInitDlg := { || .T. }
Local oDlg
Local oBmpWally
Local oBtnWally
Local oBtnHideWSelf
Local oBtnShowWSelf
Local oBtnHideWParent
Local oBtnShowWParent
DEFINE MSDIALOG oDlg TITLE "Wally" FROM aAdvSize[7],0 TO aAdvSize[6],aAdvSize[5]/2.8 OF GetWndDefault() PIXEL
@ ( aMsObjSize[1,1] ) + 005 , ( aMsObjSize[1,2] ) BITMAP oBmpWally RESNAME "WALLY" OF oDlg SIZE 500,500 NOBORDER WHEN .F. PIXEL MESSAGE OemToAnsi( "Olá, eu Sou Wally?" )
@ ( aMsObjSize[1,1] ) + 160 , ( aMsObjSize[1,2] ) BUTTON oBtnWally PROMPT OemToAnsi( "Quantos Wally´s?" ) OF oDlg SIZE 180,13 PIXEL ACTION CountWally()
@ ( aMsObjSize[1,1] ) + 175 , ( aMsObjSize[1,2] ) BUTTON oBtnHideWSelf PROMPT OemToAnsi( "Clique aqui e Me Esconda" ) OF oDlg SIZE 180,13 PIXEL ACTION HideWallySelf()
@ ( aMsObjSize[1,1] ) + 190 , ( aMsObjSize[1,2] ) BUTTON oBtnShowWSelf PROMPT OemToAnsi( "Se me Escondeu, Apresente-me Clicando aqui" ) OF oDlg SIZE 180,13 PIXEL ACTION MsgInfo( "Já Estou Visível" , "WAlly" )
@ ( aMsObjSize[1,1] ) + 205 , ( aMsObjSize[1,2] ) BUTTON oBtnHideWSelf PROMPT OemToAnsi( "Esconda o Meu Parente" ) OF oDlg SIZE 180,13 PIXEL ACTION HideWally()
@ ( aMsObjSize[1,1] ) + 220 , ( aMsObjSize[1,2] ) BUTTON oBtnShowWSelf PROMPT OemToAnsi( "Se Escondeu a ele, Apresente-o Clicando aqui" ) OF oDlg SIZE 180,13 PIXEL ACTION ShowWally()
ACTIVATE DIALOG oDlg ON INIT Eval( bInitDlg )
Return( .T. )
/*/
Funcao: CountWally
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function CountWally()
Local aBitMap := FindMsObject( "TBITMAP" )
Local nWallyCount := 0
aEval( aBitMap , { |oObj| IF( oObj:cResName == OemToAnsi( "WALLY" ) , ++nWallyCount , NIL ) } )
Return( MsgInfo( nWallyCount ) )
/*/
Funcao: HideWallySelf
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function HideWallySelf()
Local aBitMap := FindMsObject( "TBITMAP" )
Local aButtons := FindMsObject( "TBUTTON" )
Local oBmpWally := aBitMap[ aScan( aBitMap , { |oObj| ( oObj:cResName == OemToAnsi( "WALLY" ) ) } ) ]
Local oBtnWally := aButtons[ aScan( aButtons , { |oObj| ( oObj:cCaption == OemToAnsi( "Se me Escondeu, Apresente-me Clicando aqui" ) ) } ) ]
oBmpWally:Hide()
oBtnWally:bAction := { || ShowWallySelf() }
Return( .T. )
/*/
Funcao: ShowWallySelf
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function ShowWallySelf()
Local aBitMap := FindMsObject( "TBITMAP" )
oBmpWally := aBitMap[ aScan( aBitMap , { |oObj| ( oObj:cResName == OemToAnsi( "WALLY" ) ) } ) ]
oBmpWally:Show()
Return( .T. )
/*/
Funcao: HideEnchoiceBar
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function HideEnchoiceBar()
Local aEBar := FindMsObject( "TBAR" )
aEBar[1]:Hide()
Return( .T. )
/*/
Funcao: ShowEnchoiceBar
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function ShowEnchoiceBar()
Local aEBar := FindMsObject( "TBAR" )
aEBar[1]:Show()
Return( .T. )
/*/
Funcao: HideBOKEnchoiceBar
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function HideBOKEnchoiceBar()
Local aBtnBmp := FindMsObject( "TBTNBMP" )
Local oBtnOk := aBtnBmp[ aScan( aBtnBmp , { |oObj| ( oObj:cCaption == OemToAnsi( "OK" ) ) } ) ]
oBtnOk:Hide()
Return( .T. )
/*/
Funcao: ShowBOKEnchoiceBar
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function ShowBOKEnchoiceBar()
Local aBtnBmp := FindMsObject( "TBTNBMP" )
Local oBtnOk := aBtnBmp[ aScan( aBtnBmp , { |oObj| ( oObj:cCaption == OemToAnsi( "OK" ) ) } ) ]
oBtnOk:Show()
Return( .T. )
/*/
Funcao: HideBCancelEnchoiceBar
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function HideBCancelEnchoiceBar()
Local aBtnBmp := FindMsObject( "TBTNBMP" )
Local oBtnCancel := aBtnBmp[ aScan( aBtnBmp , { |oObj| ( oObj:cCaption == OemToAnsi( "Cancelar" ) ) } ) ]
oBtnCancel:Hide()
Return( .T. )
/*/
Funcao: ShowBCancelEnchoiceBar
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function ShowBCancelEnchoiceBar()
Local aBtnBmp := FindMsObject( "TBTNBMP" )
Local oBtnCancel := aBtnBmp[ aScan( aBtnBmp , { |oObj| ( oObj:cCaption == OemToAnsi( "Cancelar" ) ) } ) ]
oBtnCancel:Show()
Return( .T. )
/*/
Funcao: HideAllButtonsEnchoiceBar
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function HideAllButtonsEnchoiceBar()
Local aBtnBmp := FindMsObject( "TBTNBMP" )
aEval( aBtnBmp , { |oObj| oObj:Hide() } )
Return( .T. )
/*/
Funcao: ShowAllButtonsEnchoiceBar
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Demostrar a Manipulacao de Objetos Visuais do Protheus
/*/
Static Function ShowAllButtonsEnchoiceBar()
Local aBtnBmp := FindMsObject( "TBTNBMP" )
aEval( aBtnBmp , { |oObj| oObj:Show() } )
Return( .T. )
/*/
Funcao: FindMsObject
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Retornar Array com os Objetos conforme cMsClassName
Sintaxe: StaticCall( RNPLIB016 , FindMsObject , cMsClassName )
/*/
Static Function FindMsObject( cMsClassName , oWnd )
Local aMsObject := {}
Local oException
TRYEXCEPTION
DEFAULT oWnd := GetWndDefault()
IF !( ValType( oWnd ) == "O" )
BREAK
EndIF
IF !( ValType( cMsClassName ) == "C" )
BREAK
EndIF
cMsClassName := Upper( cMsClassName )
aMsObject := FindObject( @oWnd , @cMsClassName )
AddObj( @oWnd , @cMsClassName , @aMsObject )
CATCHEXCEPTION USIONG oException
ENDEXCEPTION
Return( aMsObject )
/*/
Funcao: FindObject
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Retornar Array com os Objetos conforme cMsClassName
/*/
Static Function FindObject( oWnd , cMsClassName , aMsObject )
Local aChild
Local aControls
Local nChild
Local nChilds
Local nControl
Local nControls
Local oChild
DEFAULT aMsObject := {}
BEGIN SEQUENCE
aControls := oWnd:aControls
IF ( aControls == NIL )
AddObj( @oWnd , @cMsClassName , @aMsObject )
oChild := oWnd:oWnd
IF !( oChild == NIL )
AddObj( @oChild , @cMsClassName , @aMsObject )
FindObject( @oChild , @cMsClassName , @aMsObject )
EndIF
BREAK
EndIF
nControls := Len( aControls )
For nControl := 1 To nControls
oChild := aControls[ nControl ]
IF ( oChild == NIL )
Loop
EndIF
AddObj( @oChild , @cMsClassName , @aMsObject )
TRYEXCEPTION
aChild := oChild:aControls
IF !( aChild == NIL )
nChilds := Len( aChild )
For nChild := 1 To nChilds
oChild := aChild[ nChild ]
IF !( oChild == NIL )
IF ( oChild == NIL )
Loop
EndIF
AddObj( @oChild , @cMsClassName , @aMsObject )
FindObject( @oChild , @cMsClassName , @aMsObject )
EndIF
Next nChild
EndIF
ENDEXCEPTION
Next nControl
oChild := oWnd:oWnd
IF !( oChild == NIL )
AddObj( @oChild , @cMsClassName , @aMsObject )
FindObject( @oChild , @cMsClassName , @aMsObject )
EndIF
END SEQUENCE
Return( aMsObject )
/*/
Funcao: AddObj
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Adicionar o Objeto
/*/
Static Function AddObj( oObj , cMsClassName , aMsObject )
Local cClassName := Upper( oObj:ClassName() )
Local lAddObj := .F.
IF ( cClassName == cMsClassName )
IF ( lAddObj := ( aScan( aMsObject , { |oFind| ( oFind == oObj ) } ) == 0 ) )
aAdd( aMsObject , oObj )
EndIF
EndIF
Return( lAddObj )
/*/
Funcao: GetOctlFocus
Autor: Marinaldo de Jesus
Data: 26/06/2011
Uso: Retorna o Objeto Ativo
/*/
Static Function GetOctlFocus()
Local oWnd := GetWndDefault()
Return( oWnd:oCtlFocus )
|
Isso sim eh dominio, parabens naldo!
ResponderExcluir