Page 1 of 1

how lpressed works?

Posted: Thu May 25, 2017 4:05 pm
by damianodec
hi to all, I have this code:

Code: Select all

DEFINE DIALOG oDlg RESOURCE "CHGCLS" FONT oFont TITLE "Title"

REDEFINE GET o_f1 VAR m_f1 ID 101 OF oDlg COLOR CLR_BLACK,CLR_GET ;
    PICTURE "@ !!!!!!!!!!!!!!!"
    o_get[01]:setfocus()
o_get[01]:bLostFocus := { || ( subr01(@m_f1,@o_f1,@m_f2,@o_f2, @BtnEsc) )}

REDEFINE GET o_f2 VAR m_f2 ID 102 OF oDlg COLOR CLR_BLACK,CLR_GET ;
    PICTURE "@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

REDEFINE BTNBMP BtnEsc ID 2 OF oDlg FILE "C:\chiudi.BMP"  2007         ;
    ACTION (oDlg:End())

ACTIVATE DIALOG oDlg ;
    CENTERED
...

FUNCTION subr01(m_f1,o_f1,m_f2,o_f2, BtnEsc)

if .not. BtnEsc:lPressed
    msginfo("run this function")
endif

Return Nil
 
I would like that when user press TAB and exit from GET m_f1 process goes to FUNCTION subr01 and show msginfo when user do not press BtnEsc BUTTON

I try BtnEsc:lPressed but it is always FALSE

any help is appreciated
thank you

FiveWin for xHarbour 12.01 - Jan. 2012 xHarbour development power
(c) FiveTech, 1993-2012 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7

Re: how lpressed works?

Posted: Thu May 25, 2017 7:31 pm
by fafi
Please try :

Code: Select all

#include "FiveWin.ch"

function main()
local oDlg,cGet := space(20), oGet , cGet1 := spac(20), oGet1

define dialog oDlg from 1,1 to 200,200 pixel title "Test"

@ 1,20 get oGet  var cGet  size 60,12 of oDlg pixel valid ( Hello(cGet), .t. )

@20,20 get oGet1 var cGet1 size 60,12 of oDlg pixel

@35,20 button oBtnCancel prompt "Exit" action oDlg:End() pixel

activate dialog oDlg centered

return nil    

static function Hello(cGet)
?"Hello "+cGet
return nil
 
Best Regards
Fafi

Re: how lpressed works?

Posted: Fri May 26, 2017 6:51 am
by damianodec
thank you Fafi, but how can I to check in "static function Hello" if BtnEsc was pressed ?

ciao

Re: how lpressed works?

Posted: Fri May 26, 2017 7:03 am
by Antonio Linares
declare a lPressed := .F. variable then do

REDEFINE BTNBMP BtnEsc ID 2 OF oDlg FILE "C:\chiudi.BMP" 2007 ;
ACTION ( lPressed := .T., oDlg:End())

Re: how lpressed works?

Posted: Fri May 26, 2017 7:06 am
by Antonio Linares
You can also check oDlg:nResult:

activate dialog oDlg centered

MsgInfo( oDlg:nResult )

and you can also disable Esc to close dialogs:

SetDialogEsc( .F. )

Re: how lpressed works?

Posted: Fri May 26, 2017 7:22 am
by fafi
damianodec wrote:thank you Fafi, but how can I to check in "static function Hello" if BtnEsc was pressed ?

ciao

Code: Select all

#include "FiveWin.ch"

static lExit

function main()

local oDlg,cGet := space(20), oGet , cGet1 := spac(20), oGet1

lExit := .f.

define dialog oDlg from 1,1 to 200,200 pixel title "Test"

@ 1,20 get oGet  var cGet  size 60,12 of oDlg pixel valid ( Hello(cGet), .t. )

@20,20 get oGet1 var cGet1 size 60,12 of oDlg pixel

@35,20 button oBtnCancel prompt "Exit" action ToExit(oDlg) pixel

activate dialog oDlg centered valid lExit

return nil    

static function Hello(cGet)
if !empty(cGet)
   ?"Hello "+cGet
endif   
return nil

static function ToExit(oDlg)

lExit := .t.

oDlg:End()

return nil
 
Fafi

Re: how lpressed works?

Posted: Fri May 26, 2017 2:54 pm
by damianodec
thank you fafi and Antonio