Page 1 of 1
interceptar X de DIALOG
Posted: Fri Apr 03, 2020 3:08 pm
by mgsoft
Hola,
Me gustaría interceptar la X de un REDEFINE DIALOG para llamar a una función, pero no he visto el codeblock.
Muchas gracias por adelantado. Saludos
Re: interceptar X de DIALOG
Posted: Fri Apr 03, 2020 4:36 pm
by ronaldo
ACTIVATE VALID()
OU
bValid
Re: interceptar X de DIALOG
Posted: Fri Apr 03, 2020 5:43 pm
by mgsoft
Muchas gracias, pero me temo que no funciona. Aquí he preparado un ejemplo:
Code: Select all
// Our first DialogBox sample
#include "FiveWin.ch"
function main()
local oWnd
DEFINE WINDOW oWnd TITLE "Test " + FWVERSION from 1,1 to 600,600 pixel
ACTIVATE WINDOW oWnd MAXIMIZED on init dlg()
return nil
function dlg()
local oDlg, oIco, cTest := "Hello world! "
local nRet := .f.
DEFINE ICON oIco FILE "..\icons\fivewin.ico"
DEFINE DIALOG oDlg TITLE "I am a DialogBox" COLOR "W+/B" ;
ICON oIco
@ 1, 3 GET cTest
@ 3, 5 BUTTON "&Ok" SIZE 40, 12 ;
ACTION (MsgInfo( "Any action here!" ), oDlg:End()) DEFAULT
@ 3, 16 BUTTON "&Cancel" SIZE 40, 12 ACTION ( XBROWSE(ODLG), oDlg:End())
oDlg:bValid := {|| msginfo("AA"), oDlg:end(), .f. }
ACTIVATE DIALOG oDlg CENTERED
?nret
return nil
Re: interceptar X de DIALOG
Posted: Fri Apr 03, 2020 6:17 pm
by karinha
Code: Select all
#include "FiveWin.ch"
STATIC oWnd, lSalida := .F.
FUNCTION Main()
DEFINE WINDOW oWnd TITLE "Test " + FWVERSION from 1,1 to 600,600 pixel
ACTIVATE WINDOW oWnd MAXIMIZED ON INIT( Dlg_Salida() )
oWnd:End()
RETURN NIL
FUNCTION Dlg_Salida()
local oDlg, oIco, cTest := "Hello world! "
DEFINE ICON oIco FILE "..\icons\fivewin.ico"
DEFINE DIALOG oDlg TITLE "I am a DialogBox" COLOR "W+/B" ;
ICON oIco
@ 1, 3 GET cTest
@ 3, 5 BUTTON "&Ok" SIZE 40, 12 ;
ACTION( lSalida := .T., oDlg:End() ) DEFAULT
@ 3, 16 BUTTON "&Cancel" SIZE 40, 12 ;
ACTION ( lSalida := .F., oDlg:End() ) CANCEL
ACTIVATE DIALOG oDlg CENTERED VALID( lSalida )
lSalida := .F.
RETURN NIL
Regards, saludos.
Re: interceptar X de DIALOG
Posted: Fri Apr 03, 2020 6:34 pm
by mgsoft
Muchas gracias, pero no me sirve, porque al pinchar en la x antes de cerrar el diálogo, o incluso después, tengo que llamar a una función.
Re: interceptar X de DIALOG
Posted: Fri Apr 03, 2020 6:37 pm
by karinha
Usas Resource?
Re: interceptar X de DIALOG
Posted: Fri Apr 03, 2020 7:04 pm
by karinha
Usando Recurso/Resource:
Code: Select all
// TESTE.PRG
#include "fivewin.ch"
FUNCTION main()
LOCAL oWnd
LOCAL oMenu
MENU oMenu
// MenuItem "From Code" action FromCode( oWnd )
MenuItem "From Resource" action FromrES( oWnd )
endmenu
define window oWnd title "Test Button Get Transparent" MENU oMenu pixel
activate window oWnd MAXIMIZED
RETURN oWnd
FUNCTION FromRes( oWnd )
LOCAL oDlg
LOCAL oGet1, oGet2, oGet3, oGet4
LOCAL cVar1, cVar2, cVar3, cVar4
LOCAL lActive := .F., oSalida
cVar1 := 0
cVar2 := 0
cVar3 := 0
cVar4 := 0
define dialog oDlg resource "fromres" of oWnd
redefine GET oGet1 var cVar1 id 100 bitmap "on" action( msginfo( "With Transparent" ) ) of oDlg
redefine GET oGet2 var cVar2 id 101 bitmap "on" action( msginfo( "Without Transparent" ) ) of oDlg
redefine GET oGet3 var cVar3 id 102 bitmap "chkyes" action( msginfo( "With Adjust-Transparent" ) );
COLOR CLR_BLACK, CLR_CYAN of oDlg
redefine GET oGet4 var cVar4 id 103 bitmap "chkyes" ;
action( if( lActive,oGet3:disable(),oGet3:enable() ), lActive := !lActive, oDlg:update() ) of oDlg
oGet1:lBtnTransparent := .T. // transparent button get oGet1
oGet3:disable()
oGet3:lBtnTransparent := .T. // transparent button get oGet3
oGet3:lAdjustBtn := .T. // Button Get Adjust Witdh oGet3
oGet3:lDisColors := .F. // Deactive disable color
oGet3:nClrTextDis := CLR_WHITE // Color text disable status
oGet3:nClrPaneDis := CLR_BLUE // Color Pane disable status
oGet4:lAdjustBtn := .T.
REDEFINE BUTTON oSalida ID 301 OF oDlg ;
ACTION ( lActive := .T., oDlg:End() ) CANCEL
activate dialog oDlg centered
RETURN nil
// TESTE.RC
/*
#ifndef __64__
1 24 "winxp\WindowsXP.Manifest"
#endif
#ifdef __64__
1 24 "winxp\WindowsXP.Manifest64"
#endif
FROMRES DIALOG 231, 77, 150, 150
STYLE DS_ABSALIGN | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
{
EDITTEXT 100, 11, 10, 80, 15, ES_AUTOHSCROLL
EDITTEXT 101, 10, 40, 80, 15, ES_AUTOHSCROLL
EDITTEXT 102, 9, 70, 129, 17, ES_AUTOHSCROLL
EDITTEXT 103, 10, 100, 130, 14, ES_AUTOHSCROLL
PUSHBUTTON "&Salida", 301, 50, 131, 50, 14
}
ON BITMAP "..\bitmaps\on.bmp"
CHKYES BITMAP "..\bitmaps\chkyes.bmp"
*/
Saludos.
Re: interceptar X de DIALOG
Posted: Fri Apr 03, 2020 7:59 pm
by mgsoft
Hola,
No me he explicado bien, necesito que al hacer click sobre la X del diálogo llamar a una función, como sucede si pinchamos en ?.
Gracias por intentarlo.
Re: interceptar X de DIALOG
Posted: Sat Apr 04, 2020 10:07 am
by Enrico Maria Giordano
Intenta asì:
Code: Select all
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
DEFINE DIALOG oDlg
ACTIVATE DIALOG oDlg;
VALID MYFUNC()
RETURN NIL
STATIC FUNCTION MYFUNC()
? "MYFUNC()"
RETURN .T.
EMG
Re: interceptar X de DIALOG
Posted: Sun Apr 05, 2020 11:14 am
by mgsoft
¡Muchas gracias Enrico!