Como puedo salir de un control DTPICKER con la tecla VK_ESCAPE,
Dejo aqui un ejemplo :
Codigo PRG
- Code: Select all Expand view
#include "fivewin.ch"
#include "dtpicker.ch"
Function Main()
Local Ofont
Local oDlg
Local h := {=>}
Local oGet := Array(2)
Local oBtn := Array(2)
Local lExit := .F.
h["fecha"] := Date()
h["serial"] := Space(10)
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE DIALOG oDlg RESOURCE "LEE_DATOS" TITLE "Prueba VK_ESCAPE" FONT oFont
REDEFINE SAY ID 100 OF oDlg PROMPT "Fecha :"
REDEFINE SAY ID 101 OF oDlg PROMPT "Serial Fiscal :"
REDEFINE DTPICKER oGet[1] VAR h["fecha"] ID 200 OF oDlg;
VALID ValidaFecha( h )
REDEFINE GET oGet[2] VAR h["serial"] ID 201 OF oDlg;
PICTURE "@!"
REDEFINE BTNBMP oBtn[1] ID 300 OF oDlg 2007;
CENTER;
ACTION (lExit:= .T., lProcess:= .T., oDlg:End())
REDEFINE BTNBMP oBtn[2] ID 301 OF oDlg 2007;
CENTER;
ACTION ( lExit:= .T., lProcess:= .F., oDlg:End() )
oBtn[2]:lCancel = .T.
AEval( oDlg:aControls, {|o| o:bKeydown := {|nKey| bKeydown(nKey, oGet, oBtn)}} )
ACTIVATE DIALOG oDlg;
VALID lExit
oFont:End()
Return Nil
//--------------------------------------//
static Function ValidaFecha( h )
Local lSucess := .T.
if h["fecha"] > Date()
MsgStop("Fecha Invalida", "Error")
lSucess := .F.
endif
Return lSucess
//--------------------------------------//
static Function bKeydown( nKey, oGet, oBtn )
if GetKeyState(VK_ESCAPE)
Eval(oBtn[2]:bAction)
endif
Return Nil
Codigo RC
- Code: Select all Expand view
LEE_DATOS DIALOGEX DISCARDABLE 6, 18, 290, 110
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 10, "MS Shell Dlg"
{
CONTROL "", 4000, "Button", BS_GROUPBOX, 8, 8, 276, 56
CONTROL "FECHA", 100, "Static", WS_GROUP, 16, 24, 68, 8
CONTROL "SERIAL", 101, "Static", WS_GROUP, 16, 40, 68, 8
CONTROL "", 200, "SysDateTimePick32", WS_TABSTOP, 92, 24, 64, 12
CONTROL "Editar", 201, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 92, 40, 160, 12
CONTROL "Ok", 300, "TBtnBmp", WS_TABSTOP|0x00800000, 28, 72, 68, 20
CONTROL "Salir", 301, "TBtnBmp", WS_TABSTOP|0x00800000, 184, 72, 68, 20
}