Hola a todos,
¿Es posible capturar/interceptar la pulsación de la tecla ESC en un DIALOG?
Gracias,
LOCAL nKey := VK_RETURN
REDEFINE BUTTONBMP oSaida ID 302 OF oDlgGrava ;
RESOURCE "154" TEXTRIGHT ;
ACTION( ( nKey := VK_ESCAPE, lGravacao := .F., oDlgGrava:End() ) ) CANCEL
IF nKey = VK_ESCAPE .OR. .NOT. lGravacao // := .F.
SELECT( DBCADPROPO ) // CADASTRO DE PROPOSTAS
SET ORDER TO 01
GO TOP
oLbx:Refresh()
lGravacao := .F.
RETURN NIL
ENDIF
DO CASE
CASE nKey == VK_ESCAPE .OR. GetKeyState( VK_ESCAPE )
lConfirma := .F.
ENDCASE
#define DLGC_WANTALLKEYS 4
REDEFINE BUTTON oBtn[ 1 ] ID 635 OF oMap30;
ACTION( pPR_A_COD := TMP1, ;
TESTE2( oWnd, oAgen, oMap30, pPR_A_COD ) )
oBtn[ 1 ]:bKeyDown := {| nKey | IF( nKey = VK_ESCAPE, ( Ver_Tecla1() ), NIL ) }
oBtn[ 1 ]:nDlgCode := DLGC_WANTALLKEYS
FUNCTION Main()
LOCAL oDlg
DEFINE DIALOG oDlg
ACTIVATE DIALOG oDlg CENTERED VALID SAIDA( oDlg )
FUNCTION SAIDA( oDlg )
IF getkeystate( VK_ESCAPE )
msgstop( "Estou encerrando pela tecla ESC !!!" )
ELSE
MsgInfo( "cerrado de otra forma" )
ENDIF
RETURN .T.
Antonio Linares wrote:Carlos,
ACTIVATE DIALOG oDlg CENTERED
MsgInfo( oDlg:nResult )
nResult vale 2 cuando se ha cancelado el diálogo
#include "FiveWin.ch"
#include "constant.ch"
//----------------------------------------------------------------------------//
function My_MsgList( aData, cTitle, nTop, nLeft, nBottom, nRight, cBtnTitle, nItem, lCancel, cCapCan, oFont )
//LOCAL oFont, 13/07/2021
Local lKillOfont := .F. // 13/07/2021
LOCAL oLst, oBtnClose1, oBtnClose2
LOCAL nCol1, nRow, nCol2, oDlg, nWidth, nHeight
DEFAULT nBottom := 13,;
nRight := 59.5,;
cTitle := "Array list", ;
cBtnTitle := "&OK", ;
cCapCan := "&CANCEL",;
nItem := 1, ;
lCancel := .F.
nWidth = Max( nRight * DLG_CHARPIX_W, 180 )
nHeight = nBottom * DLG_CHARPIX_H
// 13/07/2021
If oFont == nil
DEFINE FONT oFont NAME GetSysFont() SIZE 0, -8
lKillOfont := .T.
EndIF
// 13/07/2021
//DEFINE FONT oFont NAME GetSysFont() SIZE 0, -8 13/07/2021
DEFINE DIALOG oDlg SIZE nWidth, nHeight PIXEL;
TITLE cTitle FONT oFont ;
STYLE nOr(WS_POPUP, WS_CAPTION, WS_BORDER, WS_THICKFRAME, WS_CLIPCHILDREN )
oDlg:lTruePixel := .f.
@ 4, 3 LISTBOX oLst VAR nItem ITEMS aData OF oDlg PIXEL SIZE nWidth / 2 - 4, nHeight / 2 - 20
oLst:bLDblClick := {|| oDlg:End( IDOK ) }
IF lCancel
@ nHeight / 2 - 15, nWidth / 2 - 41 BUTTON oBtnClose1 PROMPT cCapCan SIZE 36, 13 PIXEL ;
ACTION (nItem := 0, oDlg:End()) UPDATE CANCEL OF oDlg
//ACTION (nItem := 0, oDlg:End()) UPDATE 13/07/2021
ENDIF
@ nHeight / 2 - 15, If( lCancel, 5, nWidth / 2 - 41 ) BUTTON oBtnClose2 PROMPT cBtnTitle DEFAULT SIZE 36, 13 PIXEL ;
ACTION oDlg:End( IDOK ) UPDATE OF oDlg
oDlg:bResized = { | nType, nWidth, nHeight | oLst:SetSize( nWidth - 8, nHeight - 40 ),;
nRow := nHeight - 30,;
nCol2 := nWidth - 82,;
If( lCancel,;
( nCol1 := nWidth - 82,;
oBtnClose1:Move( nRow, nCol1 ),;
nCol2 := 10 ), ),;
oBtnClose2:Move( nRow, nCol2 ),;
oLst:Refresh(), oDlg:Refresh() }
ACTIVATE DIALOG oDlg CENTERED
// 13/07/2021
If ValType( oDlg:nResult ) == "N"
If oDlg:nResult = 2
nItem := 0
EndIf
EndIf
// 13/07/2021
// 13/07/2021
If lKillOfont
oFont:End()
EndIf
// 13/07/2021
RETURN nItem
// \SAMPLES\MSGLIST1.PRG
#Include "FiveWin.ch"
FUNCTION Main()
LOCAL aData := {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
LOCAL cTitle, nTop, nLeft, nBottom, nRight, cBtnTitle, cCampo
oaMsgList( aData, cTitle, nTop, nLeft, nBottom, nRight, cBtnTitle, cCampo )
RETURN NIL
FUNCTION oaMsgList( aData, cTitle, nTop, nLeft, nBottom, nRight, cBtnTitle, ;
cCampo )
LOCAL x, nItem := 0, nAlt, nLarg := 0, oFont, oDlg, oLst, oBtnClose
if aData == nil .or. len(aData) == 0
MsgStop("Os parâmetros não foram passados corretamente para o oaMsgList()","Atenção")
RETURN nItem
endif
nAlt:=len( aData )
for x=1 to nAlt
nLarg:=max( nLarg, len( aData[x] ) )
next
// Para limitar a altura da janela.
nAlt := iif( nAlt > 50, 50, nAlt )
DEFAULT cTitle := "Selecione", nTop:=9, nLeft:=9, nBottom:=80+(nAlt*12), ;
nRight := max( (len(cTitle)*12)+50, 50+(nLarg*12) ), ;
cBtnTitle := "&Confirme", cCampo := ""
nItem := IIF( .NOT. Empty( cCampo ), aScan( aData, cCampo ), 1 )
SetBalloon( .T. ) // Balloon shape required for tooltips
SkinButtons()
DEFINE FONT oFont NAME GetSysFont() SIZE 0,-8
DEFINE DIALOG oDlg FROM nTop,nLeft TO nBottom,nRight ;
TITLE cTitle FONT oFont ;
STYLE nOr( WS_POPUP, WS_CAPTION, WS_BORDER, WS_THICKFRAME, ;
WS_MAXIMIZEBOX) COLORS CLR_BLACK, CLR_WHITE ;
TRANSPARENT PIXEL
@ 004,003 LISTBOX oLst VAR nItem ITEMS aData OF oDlg SIZE 100,100 Pixel
oLst:bLDblClick := {|| oDlg:End() }
@ 078,176 BUTTON oBtnClose PROMPT cBtnTitle DEFAULT SIZE 036,013 ;
ACTION oDlg:End() Pixel CANCEL
oDlg:bResized := {|| oLst:SetSize( oDlg:nWidth() - 27, oDlg:nHeight() - iif(LargeFonts(), 89, 79) ),;
oBtnClose:nTop := oDlg:nHeight() - iif(LargeFonts(), 79, 69),;
oBtnClose:nLeft := oDlg:nWidth() - 94,;
oLst:Select(nItem), oDlg:Refresh() }
ACTIVATE DIALOG oDlg CENTERED ON INIT ( Eval(oDlg:bResized) )
oFont:End()
RETURN nItem
// Fin / End
ACTIVATE DIALOG oDlg ;
VALID(!GETKEYSTATE( 27 ))
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 39 guests