Hello,
try this
#include "fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg, g, d := DATE()
DEFINE DIALOG oDlg FROM 10,10 To 20,20
@ 1,1 GET g VAR d ACTION calendar(self)
g:lKeepFocus := .F.
ACTIVATE DIALOG oDlg
RETURN NIL
FUNCTION calendar( oGet )
//------------------------------------------------------------------------------
LOCAL oWnd, oCal, aRect, w, h, x, y, cps
//LOCAL fecha := IF( isFecha(oGet:cText()), CTOD( oGet:cText() ), DATE() )
LOCAL fecha := DATE()
LOCAL dHoy := fecha, lOk := .F., lLostFocus := .F., n := 0
IF isAppthemed()
w := 224; h := 159
ELSE
w := 174; h := 150
ENDIF
aRect := getWndRect( oGet:hWnd )
y := aRect[1] + oGet:nHeight
x := aRect[2]
DEFINE WINDOW oWnd OF oGet:oWnd FROM y, x TO y + h, x + w PIXEL STYLE nOR( WS_CHILD, WS_POPUP, WS_VISIBLE )
@ 0, 0 CALENDAR oCal VAR dHoy OF oWnd PIXEL size h,w DBLCLICK ( lOk := .T., oWnd:end() ) //87,75
oWnd:oClient := oCal
oCal:bKeyDown := {|nkey| IF( nKey = 13 .OR. nKey = 32, ( lOk := .T., oWnd:end() ), ) }
oWnd:bKeyDown := {|nkey| IF( GetKeyState( VK_ESCAPE ), ( lLostFocus := .T., oWnd:end() ), ) }
oCal:bLostFocus := {|| oWnd:END() }
ACTIVATE WINDOW oWnd;
ON INIT ( oWnd:move(aRect[1] + oGet:nHeight ,aRect[2] ),;
oCal:setFocus() ) ;
VALID IF( ! lLostFocus .AND. lOk .AND. ! GetKeyState( VK_ESCAPE ), ;
( oGet:cText := dHoy, oGet:refresh(), oGet:setfocus(), .T. ),;
( oGet:setFocus(), .T. ) )
RETURN NIL
But in order to this sample works, you need to have the last added feature to the GET class, "lKeepFocus" if you don't have the last FWH, you can modify it, following this message http://forums.fivetechsupport.com/viewtopic.php?f=22&t=24697 and if you implement the ON INIT feature, then the code is simplest and clear
FUNCTION MAIN()
LOCAL oDlg, g, d := DATE()
DEFINE DIALOG oDlg FROM 10,10 To 20,20
@ 1,1 GET g VAR d ACTION calendar(self) ON INIT ::lKeepFocus := .F.
ACTIVATE DIALOG oDlg
RETURN NIL
http://forums.fivetechsupport.com/viewtopic.php?f=22&t=9676&start=15