FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour how lpressed works?
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
how lpressed works?
Posted: Thu May 25, 2017 04:05 PM
hi to all, I have this code:
Code (fw): Select all Collapse
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 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Re: how lpressed works?
Posted: Thu May 25, 2017 07:31 PM
Please try :
Code (fw): Select all Collapse
#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
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: how lpressed works?
Posted: Fri May 26, 2017 06:51 AM

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

ciao

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: how lpressed works?
Posted: Fri May 26, 2017 07:03 AM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: how lpressed works?
Posted: Fri May 26, 2017 07:06 AM

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
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Re: how lpressed works?
Posted: Fri May 26, 2017 07:22 AM
damianodec wrote:thank you Fafi, but how can I to check in "static function Hello" if BtnEsc was pressed ?

ciao

Code (fw): Select all Collapse
#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
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: how lpressed works?
Posted: Fri May 26, 2017 02:54 PM

thank you fafi and Antonio

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)

Continue the discussion