End dialogue when lost focus

Post Reply
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

End dialogue when lost focus

Post by hua »

Code: Select all | Expand


     DEFINE DIALOG oDlg FROM 0,0 TO nDlgHei, nDlgWid                ;
        STYLE nOr(WS_POPUP, WS_VISIBLE) ;
        COLOR CLR_BLACK, nRgb(255,255,238) ;
        TRANSPARENT ;
        FONT oFnt PIXEL

 ACTIVATE DIALOG oDlg NOWAIT CENTERED                                  ;
        ON INIT oDlg:bLostFocus := {|| oDlg:end()}
 


I expect this code to end the dialogue box if I click anywhere outside the dialogue box but it doesn't.
Why?

TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
Natter
Posts: 1244
Joined: Mon May 14, 2007 9:49 am

Re: End dialogue when lost focus

Post by Natter »

ACTIVATE DIALOG oDlg NOWAIT CENTERED ;
ON INIT oDlg:bNcActivate:={|lOnOff|iif(lOnOff,, oDlg:End())}
User avatar
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: End dialogue when lost focus

Post by cnavarro »

Code: Select all | Expand


#include "Fivewin.ch"

Function Main()

   local oDlg

     DEFINE DIALOG oDlg FROM 0,0 TO 300, 600               ;
        STYLE WS_POPUP ;
        COLOR CLR_BLACK, nRgb(255,255,238) ;
        PIXEL TRUEPIXEL TRANSPARENT

     oDlg:bLostFocus := {|| oDlg:end()}
     ACTIVATE DIALOG oDlg /*NOWAIT*/ CENTERED

Return nil

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: End dialogue when lost focus

Post by hua »

Thanks Natter and Cristobal.
I got the effect that I want by including oDlg:bNcActivate := {| lOnOff | iif (lOnOff ,, oDlg: End ())}

Once that's included I could remove the NOWAIT clause
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
Posts: 1077
Joined: Fri Oct 28, 2005 2:27 am
Has thanked: 1 time
Been thanked: 1 time

Re: End dialogue when lost focus

Post by hua »

To continue, I tie the code to display the dialog box to xBrowse's right click,

Code: Select all | Expand

:aCols[4]:bRClickData := {||  ud_msginfo( cDescription) }
.

Now if I right click a row on xBrowse, the dialogue appears with the message. If I left-click anywhere outside the dialogue, it is closed. Perfect.

But if when the dialogue appears and I immediately right click on a different row, I wish the current dialogue box is closed and reshown with message of the new row, how to achieve that? Now the 2st right click opens the dialog, 2nd right click closes it, at 3rd right click only will it reopens the dialgue box

TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
Post Reply