TCalendar

Post Reply
User avatar
David Williams
Posts: 82
Joined: Fri Mar 03, 2006 6:26 pm
Location: Ireland

TCalendar

Post 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
User avatar
Eoeo
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: TCalendar

Post by Eoeo »

Also I ask this features last week but I not had messages and helps!!!
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TCalendar

Post 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:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
Marcelo Via Giglio
Posts: 1033
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: TCalendar

Post 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
ShumingWang
Posts: 454
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Re: TCalendar

Post 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
User avatar
Eoeo
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: TCalendar

Post by Eoeo »

on win seven crash!!!
User avatar
Uwe.Diemer
Posts: 81
Joined: Mon Aug 09, 2010 11:00 am

Re: TCalendar

Post 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"
User avatar
Eoeo
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: TCalendar

Post 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
User avatar
David Williams
Posts: 82
Joined: Fri Mar 03, 2006 6:26 pm
Location: Ireland

Re: TCalendar

Post 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
Post Reply