How to create a Dialog by clicking outside it closes?

How to create a Dialog by clicking outside it closes?

Postby emotta_no » Tue Jan 21, 2014 2:29 pm

I need to create a dialog, when user to click outside it closes.

Thanks
emotta_no
 
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: How to create a Dialog by clicking outside it closes?

Postby FranciscoA » Tue Jan 21, 2014 3:16 pm

Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2114
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: How to create a Dialog by clicking outside it closes?

Postby emotta_no » Tue Jan 21, 2014 4:40 pm

this topic not helped...
emotta_no
 
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: How to create a Dialog by clicking outside it closes?

Postby FranciscoA » Tue Jan 21, 2014 6:08 pm

Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2114
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: How to create a Dialog by clicking outside it closes?

Postby emotta_no » Tue Jan 21, 2014 7:11 pm

It isn't working. This is code:

Code: Select all  Expand view

#include "fivewin.ch"

Function u_Teste2()
Local oDlg

msgstop(GetFocus())

DEFINE DIALOG oDlg Title "Selecione o Ambiente" FROM 0,0 TO 500,500 PIXEL

@ 01,01 button "teste" action msgstop("1") Size 20,20 Of oDlg
ACTIVATE DIALOG oDlg On Init(DlgEndOnLostFocus(oDlg))




   
Return





    //-------------------------------------------------------------------------//
    STATIC FUNCTION DlgEndOnLostFocus(oDlg)
    Local nI, o
    Local bLost, aAllControls:= {}
   
    CollectControls(oDlg, @aAllControls)

    #Define lFOCUS_APPLICATION ( oWndFromHwnd(GetFocus()) != NIL )
    #Define lFOCUS_NOT_DIALOG  ( AScan(aAllControls, {|o| o:hWnd == GetFocus()}) == 0 )
    #Define ON_FOCUS_LOST      If(lFOCUS_APPLICATION .AND. lFOCUS_NOT_DIALOG, oDlg:End(), NIL)

    FOR nI:= 1 to len(aAllControls)

       o:= aAllControls[nI]
       IF O:bLostFocus != NIL
          bLost:= o:bLostFocus
          o:bLostFocus:= {|x1, x2, x3, x| x:= Eval(bLost, x1, x2, x3),;
                                          ON_FOCUS_LOST,;
                                          x}
       ELSE
          o:bLostFocus:= {|x1, x2, x3, x| x:= NIL,;
                                          ON_FOCUS_LOST,;
                                          x}

       ENDIF

    NEXT
    RETURN NIL

    *
    //-------------------------------------------------------------------------//
    FUNCTION CollectControls(oDlg , aAllControls)
    LOCAL nI, nJ, Obj1 , Obj2

    Aadd(aAllControls, ODLG)

    FOR nI:= 1 TO Len(oDlg:aControls)
       Obj1:= oDlg:aControls[nI]
       Aadd(aAllControls, Obj1)
       IF Obj1:ClassName == "TFOLDER"
          FOR nJ:= 1 TO Len(Obj1:aDialogs)
             Obj2:= Obj1:aDialogs[nJ]
             CollectControls(Obj2 , @aAllControls)
          NEXT
       ENDIF
    NEXT
    RETURN
 
emotta_no
 
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: How to create a Dialog by clicking outside it closes?

Postby Antonio Linares » Tue Jan 21, 2014 9:28 pm

Here you have a working example:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg

   DEFINE DIALOG oDlg

   oDlg:bStart = { || SetCapture( oDlg:hWnd ) }

   ACTIVATE DIALOG oDlg CENTERED ;
      ON CLICK oDlg:End()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to create a Dialog by clicking outside it closes?

Postby Marcelo Via Giglio » Tue Jan 21, 2014 11:03 pm

Hello,

with previous version of FW (10.12) was possible to do

Code: Select all  Expand view

oDlg:bLostFocus := {|| oDlg:end() }
 


but with actual version it isn't possible, you can try to add a control and put the focus in it at start the dialog, and when lost the focus from this control, you can close the dialog. In this way I implement my self calendar

I hope this is what you are searching

regards

Marcelo
Marcelo Via Giglio
 
Posts: 1051
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: How to create a Dialog by clicking outside it closes?

Postby emotta_no » Wed Jan 22, 2014 10:44 am

Antonio, thanks but

It didn't work. When I click in the dialog is closed. I need

I need to DIALOG be closed only if I click off.
emotta_no
 
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm

Re: How to create a Dialog by clicking outside it closes?

Postby Antonio Linares » Wed Jan 22, 2014 12:42 pm

Here you have it:

Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg

   DEFINE DIALOG oDlg

   oDlg:bStart = { || SetCapture( oDlg:hWnd ) }

   ACTIVATE DIALOG oDlg CENTERED ;
      ON CLICK If( nRow < 0 .or. nCol < 0 .or. ;
                   nRow > oDlg:nHeight - 30 .or. nCol > oDlg:nWidth,;
                   oDlg:End(),)
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to create a Dialog by clicking outside it closes?

Postby emotta_no » Wed Jan 22, 2014 1:03 pm

Great Antonio, it worked...

Thanks maestro...
emotta_no
 
Posts: 33
Joined: Thu Jul 04, 2013 9:28 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 31 guests

cron