How to create a Dialog by clicking outside it closes?
How to create a Dialog by clicking outside it closes?
I need to create a dialog, when user to click outside it closes.
Thanks
Thanks
- FranciscoA
- Posts: 2164
- Joined: Fri Jul 18, 2008 1:24 am
- Location: Chinandega, Nicaragua, C.A.
Re: How to create a Dialog by clicking outside it closes?
Maybe this post can helps.
viewtopic.php?f=6&t=24795&p=134564&hilit=al+dar+click+fuera#p134564
viewtopic.php?f=6&t=24795&p=134564&hilit=al+dar+click+fuera#p134564
Francisco J. Alegría P.
Chinandega, Nicaragua.
Fwxh-MySql-TMySql
Chinandega, Nicaragua.
Fwxh-MySql-TMySql
- FranciscoA
- Posts: 2164
- Joined: Fri Jul 18, 2008 1:24 am
- Location: Chinandega, Nicaragua, C.A.
Re: How to create a Dialog by clicking outside it closes?
Francisco J. Alegría P.
Chinandega, Nicaragua.
Fwxh-MySql-TMySql
Chinandega, Nicaragua.
Fwxh-MySql-TMySql
Re: How to create a Dialog by clicking outside it closes?
It isn't working. This is code:
Code: Select all | Expand
#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
- Antonio Linares
- Site Admin
- Posts: 42650
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 62 times
- Been thanked: 94 times
- Contact:
Re: How to create a Dialog by clicking outside it closes?
Here you have a working example:
Code: Select all | Expand
#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
-
- Posts: 1079
- Joined: Fri Oct 07, 2005 3:33 pm
- Location: Cochabamba - Bolivia
- Has thanked: 1 time
- Been thanked: 1 time
Re: How to create a Dialog by clicking outside it closes?
Hello,
with previous version of FW (10.12) was possible to do
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
with previous version of FW (10.12) was possible to do
Code: Select all | Expand
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
Re: How to create a Dialog by clicking outside it closes?
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.
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.
- Antonio Linares
- Site Admin
- Posts: 42650
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 62 times
- Been thanked: 94 times
- Contact:
Re: How to create a Dialog by clicking outside it closes?
Here you have it:
Code: Select all | Expand
#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
Re: How to create a Dialog by clicking outside it closes?
Great Antonio, it worked...
Thanks maestro...
Thanks maestro...