FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TCalendar
Posts: 82
Joined: Fri Mar 03, 2006 06:26 PM
TCalendar
Posted: Sun Sep 16, 2012 03:49 PM

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

Posts: 222
Joined: Mon Jun 04, 2012 12:00 PM
Re: TCalendar
Posted: Sun Sep 16, 2012 03:57 PM

Also I ask this features last week but I not had messages and helps!!!

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: TCalendar
Posted: Sun Sep 16, 2012 05:52 PM
There is still another Solution ( doesn't use TCalendar )
Samples : Calendar.prg



I started with a embedded xBrowse-solution :



Best Regards
Uwe :-)
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.
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: TCalendar
Posted: Mon Sep 17, 2012 12:57 AM

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

Code (fw): Select all Collapse
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

Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Re: TCalendar
Posted: Mon Sep 17, 2012 05:10 AM
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
http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 222
Joined: Mon Jun 04, 2012 12:00 PM
Re: TCalendar
Posted: Mon Sep 17, 2012 05:13 PM

on win seven crash!!!

Posts: 99
Joined: Mon Aug 09, 2010 11:00 AM
Re: TCalendar
Posted: Tue Sep 18, 2012 07:13 AM

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"

Posts: 222
Joined: Mon Jun 04, 2012 12:00 PM
Re: TCalendar
Posted: Tue Sep 18, 2012 09:05 AM
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
Posts: 82
Joined: Fri Mar 03, 2006 06:26 PM
Re: TCalendar
Posted: Tue Sep 18, 2012 10:31 AM

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

Continue the discussion