interceptar X de DIALOG

Post Reply
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

interceptar X de DIALOG

Post 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
Saludos,

Eduardo
User avatar
ronaldo
Posts: 137
Joined: Fri Nov 25, 2005 4:38 pm
Location: brasil
Contact:

Re: interceptar X de DIALOG

Post by ronaldo »

ACTIVATE VALID()

OU

bValid
Ronaldo Minacapelli
Sistemas, Hospedagem e Criação de WebSites
http://www.bazevani.com.br
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: interceptar X de DIALOG

Post 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
Saludos,

Eduardo
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: interceptar X de DIALOG

Post 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.
João Santos - São Paulo - Brasil
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: interceptar X de DIALOG

Post 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.
Saludos,

Eduardo
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: interceptar X de DIALOG

Post by karinha »

Usas Resource?
João Santos - São Paulo - Brasil
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: interceptar X de DIALOG

Post 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.
João Santos - São Paulo - Brasil
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: interceptar X de DIALOG

Post 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.
Saludos,

Eduardo
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: interceptar X de DIALOG

Post 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
User avatar
mgsoft
Posts: 398
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: interceptar X de DIALOG

Post by mgsoft »

¡Muchas gracias Enrico!
Saludos,

Eduardo
Post Reply