Page 1 of 1

TCalendar

Posted: Sun Sep 16, 2012 3:49 pm
by David Williams
Hi All

When I put a TCalendar control on a window it defaults to one month but when I place it on a dialog it defaults to four months. How can I set it to one month on a dialog. I have only found ::GetVisibleMonths() not ::SetVisibleMonths().

Can anyone help?
David

Re: TCalendar

Posted: Sun Sep 16, 2012 3:57 pm
by Eoeo
Also I ask this features last week but I not had messages and helps!!!

Re: TCalendar

Posted: Sun Sep 16, 2012 5:52 pm
by ukoenig
There is still another Solution ( doesn't use TCalendar )
Samples : Calendar.prg

Image

I started with a embedded xBrowse-solution :

Image

Best Regards
Uwe :lol:

Re: TCalendar

Posted: Mon Sep 17, 2012 12:57 am
by Marcelo Via Giglio
Hello,

try this

Code: Select all

#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/viewt ... 22&t=24697 and if you implement the ON INIT feature, then the code is simplest and clear

Code: Select all

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/viewt ... 6&start=15

Re: TCalendar

Posted: Mon Sep 17, 2012 5:10 am
by ShumingWang
REDEFINE GET DATE1 ID 102 OF odlg;
ACTION cal( DATE1, self )



FUNCTION cal( date1, oGet )
LOCAL odlg, oCal, aRect
LOCAL lOk := .f.

aRect := getWndRect( oGet:hWnd )

DEFINE DIALOG odlg FROM 0,0 TO 145,265 PIXEL STYLE nor( WS_POPUP,WS_VISIBLE,WS_BORDER)
//150, 174
@-10,-10 CALENDAR oCal VAR date1 OF odlg PIXEL DAYSTATE SIZE 150,89 DBLCLICK (lok:=.t.,odlg:end())
// 155,160
//87,75
oCal:bKeyDown := {|nkey| IF( nKey = 13 .OR. nKey = 32, (lok:=.t.,odlg:end()), ) }
odlg:oClient := oCal

ACTIVATE DIALOG odlg ON INIT (ocal:show(),odlg:move(aRect[1] + oGet:nHeight ,aRect[2])) ;
VALID IF( lOk .AND. ! GetKeyState( VK_ESCAPE ), (oGet:cText := date1, oGet:refresh(), .T. ), .t. )

RETURN NIL

Re: TCalendar

Posted: Mon Sep 17, 2012 5:13 pm
by Eoeo
on win seven crash!!!

Re: TCalendar

Posted: Tue Sep 18, 2012 7:13 am
by Uwe.Diemer
Thanks for this usefull post and the detailed Informations about the Crash

try another username with more than 4 Letters "Eoeo""Fasi" perhaps 5 Letters like "IDI.T"

Re: TCalendar

Posted: Tue Sep 18, 2012 9:05 am
by Eoeo
Uwe.Diemer wrote:Thanks for this usefull post and the detailed Informations about the Crash

try another username with more than 4 Letters "Eoeo""Fasi" perhaps 5 Letters like "IDI.T"

Uwe,
For me this help is important, the test crash on Win Seven then....
I not understood Antonio give YOU the authorization to offend allways my personal freedom!!!
I am on the gap for a long time while there are people as YOU who make smart and have just started to use Fivewin !!!!

eoeo is the name of my website www.eoeo.it

Re: TCalendar

Posted: Tue Sep 18, 2012 10:31 am
by David Williams
Thank you all for your suggestions. I opted for Shuming's code and I have now developed the calendar for my application.

OT. Has anyone developed a Golf Tee Booking System or has there been an update on Daniel García Gil's Outlook Appointments?

Many thanks
David