End dialogue when lost focus

End dialogue when lost focus

Postby hua » Wed Dec 01, 2021 3:36 am

Code: Select all  Expand view

     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
hua
 
Posts: 1070
Joined: Fri Oct 28, 2005 2:27 am

Re: End dialogue when lost focus

Postby Natter » Wed Dec 01, 2021 4:19 pm

ACTIVATE DIALOG oDlg NOWAIT CENTERED ;
ON INIT oDlg:bNcActivate:={|lOnOff|iif(lOnOff,, oDlg:End())}
Natter
 
Posts: 1182
Joined: Mon May 14, 2007 9:49 am

Re: End dialogue when lost focus

Postby cnavarro » Wed Dec 01, 2021 7:55 pm

Code: Select all  Expand view

#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
User avatar
cnavarro
 
Posts: 6520
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: End dialogue when lost focus

Postby hua » Thu Dec 02, 2021 2:18 am

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: 1070
Joined: Fri Oct 28, 2005 2:27 am

Re: End dialogue when lost focus

Postby hua » Thu Dec 02, 2021 2:44 am

To continue, I tie the code to display the dialog box to xBrowse's right click,
Code: Select all  Expand view
: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
hua
 
Posts: 1070
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests