how lpressed works?

Post Reply
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

how lpressed works?

Post 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
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
fafi
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: how lpressed works?

Post 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
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: how lpressed works?

Post by damianodec »

thank you Fafi, but how can I to check in "static function Hello" if BtnEsc was pressed ?

ciao
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: how lpressed works?

Post 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())
regards, saludos

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

Re: how lpressed works?

Post 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. )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
fafi
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: how lpressed works?

Post 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
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: how lpressed works?

Post by damianodec »

thank you fafi and Antonio
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Post Reply