Using T Calendar 10.04

Using T Calendar 10.04

Postby TimStone » Fri Apr 30, 2010 1:05 am

I have a couple of questions after viewing the sample code for tCalendar.

1) Do you have a sample for a "redefine" of a resource including the setup of the .RC control ?

2) Is it possible to display dates that correlate to a database, ie. if I have appointments, I want to color the dates on which they are set ?

3) I see the Calendar is a DISPLAY but I would have to use the date picker to set the current calendar date. I noted clicking on a date could trigger a function, but I'm thinking clicking on a date should somehow change the display and focus ( current date ) of the calendar.

4) In the previous thread, I noticed Otto had a display of a calendar. Is he willing to share how that was constructed ?

Thanks all.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Using T Calendar 10.04

Postby Otto » Fri Apr 30, 2010 9:53 am

Hello Tim,

>Is he willing to share how that was constructed ?


Sure. But I have to release our new ECR software (PC and PPC) next week. Afterwards I will continue to make the “Wellnessplaner” a class.
At the moment all is hard coded.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: Using T Calendar 10.04

Postby frose » Fri Apr 30, 2010 10:09 am

Hello Otto,

wishing that all things are running well with your ECR software, so you'll find time for the new class “Wellnessplaner” soon ;-)
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: Using T Calendar 10.04

Postby Daniel Garcia-Gil » Fri Apr 30, 2010 1:08 pm

Hello Tim

TimStone wrote:1) Do you have a sample for a "redefine" of a resource including the setup of the .RC control ?

i fixed a little bug in tcalendar, only change this method, very soon will publish new release with this change

Code: Select all  Expand view

METHOD Initiate( hDlg ) Class TCalendar
   local oSelf := Self
   LOCAL nStyle

   Super:Initiate( hDlg )

   nStyle           = GetWindowLong( ::hWnd, GWL_STYLE )
   ::lWeekNumbers   = lAnd( nStyle, MCS_WEEKNUMBERS )
   ::lNoTodayCircle = lAnd( nStyle, MCS_NOTODAYCIRCLE )
   ::lNoToday       = lAnd( nStyle, MCS_NOTODAY )
   ::lDayState      = lAnd( nStyle, MCS_DAYSTATE )
   ::lMultiselect   = ::lMultiselect .OR. lAnd( nStyle, MCS_MULTISELECT )
   
   if ::lMultiselect
      ::dDateEnd  = Eval(::bSetGet2)
      ::SetDateRange( ::dDate, ::dDateEnd )
   else
      ::SetDate(::dDate)
   endif  


   ::aDayState = Array( ::GetVisibleMonths(), 31 )
   
   ::GetDate()
   
   DEFINE TIMER ::oTimerDbl INTERVAL ::nDelay OF ::oWnd;
          ACTION ( oSelf:lDblClick := .F., oSelf:oTimerDbl:Deactivate() )

RETURN NIL
 


sample with resource
PRG FILE
Code: Select all  Expand view


#include "FiveWin.ch"
#include "dtpicker.ch"
#include "calendar.ch"
#include "wcolors.ch"

FUNCTION Main()
   LOCAL oDlg, oCal, oDtp1, oDtp2, oDtp3, oDtp4, oCbx
   LOCAL oSayClr
   LOCAL nColor
   LOCAL dDate1, dDate2, dDate3, dDate4, dDate5, dDate6
   LOCAL cItemClr
   LOCAL lWeekNumbers   := .F.
   LOCAL lNoTodayCircle := .F.
   LOCAL lNoToday       := .F.
   LOCAL lDayState      := .F.
   LOCAL oRange3, aRanges2 := { , }
   LOCAL oRange4
   LOCAL aColorItems    := { "MCSC_BACKGROUND  " ,;
                             "MCSC_TEXT        " ,;
                             "MCSC_TITLEBK     " ,;
                             "MCSC_TITLETEXT   " ,;
                             "MCSC_MONTHBK     " ,;
                             "MCSC_TRAILINGTEXT" }
   LOCAL oDayOfWeek, cDayOfWeek:="Monday", aDayOfWeek:={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}                          
   
   LOCAL oCal2
   LOCAL oRange1, aRanges := { , }
   LOCAL oRange2
   LOCAL oMax, nMax
   LOCAL lSunday   := .T.
   LOCAL lSaturday := .T.
   LOCAL cMDisp



     SET DATE TO BRITISH
     SET EPOCH TO 1980  
   dDate1 = Date()
   dDate2 = Date()
   dDate3 = Date()
   dDate4 = Date() + 7
   dDate5 = Date()
   dDate6 = Date()
 
   DEFINE DIALOG oDlg TITLE "Test Calendar" RESOURCE "CALENDAR" TRANSPARENT
 
   // Start Calendar 1
 
 
   REDEFINE CALENDAR oCal VAR dDate1 OF oDlg ID 2001 ;
              DBLCLICK MsgInfo( oCal:GetDate() );
              ON CHANGE oDtp2:cText := oCal:GetDate();
              ACTION( MsgInfo( "ok" ) )
             
   REDEFINE BUTTON ID 1000 OF oDlg ACTION oDtp1:cText := oCal:GetToday()
   REDEFINE BUTTON ID 1001 OF oDlg ACTION oCal:SetToday( dDate1 )
   REDEFINE DTPICKER oDtp1 VAR dDate1 ID 2000OF oDlg
   REDEFINE BUTTON ID 1002 OF oDlg ACTION( oSayClr:SetColor( CLR_BLACK, oCal:GetColors( oCbx:nAt - 1 ) ), oSayClr:Refresh() )
   REDEFINE BUTTON ID 1003 OF oDlg ACTION( nColor := ChooseColor(), ;
                                           oCal:SetColor( oCbx:nAt - 1, nColor ), ;
                                           oSayClr:SetColor( CLR_BLACK, nColor ),;
                                           oSayClr:Refresh() )
                                                                     
   REDEFINE COMBOBOX oCbx VAR cItemClr PROMPTS aColorItems ID 3000 OF oDlg
   REDEFINE SAY oSayClr VAR "        " ID 4000 OF oDlg
   
   REDEFINE BUTTON ID 1004 OF oDlg ACTION( cDayofWeek := aDayOfWeek[ oCal:GetFirstDayOfWeek() + 1 ], oDayOfWeek:Refresh() )
   REDEFINE BUTTON ID 1005 OF oDlg ACTION( oCal:SetFirstDayOfWeek( oDayOfWeek:FindString( cDayOfWeek ) - 1 ) )
   
   REDEFINE COMBOBOX oDayOfWeek VAR cDayofWeek ITEMS aDayOfWeek ID 3001 OF oDlg

   REDEFINE BUTTON ID 1006 OF oDlg ACTION Msginfo( oCal:GetDate() )
   REDEFINE BUTTON ID 1007 OF oDlg ACTION oCal:SetDate( dDate2 )
   REDEFINE DTPICKER oDtp2 VAR dDate2 ID 2002 OF oDlg

   REDEFINE BUTTON ID 1008 OF oDlg ;
              ACTION( aRanges2 := oCal:GetRange(), oRange3:Refresh(), oRange4:Refresh() )
   REDEFINE GET oRange3 VAR aRanges2[ 1 ] ID 4001 OF oDlg
   REDEFINE GET oRange4 VAR aRanges2[ 2 ] ID 4002 OF oDlg

   REDEFINE BUTTON ID 1009 OF oDlg ACTION oCal:SetRange( dDate5, dDate6 )
   REDEFINE DTPICKER oDtp3 VAR dDate5 ID 2003 OF oDlg
   REDEFINE DTPICKER oDtp4 VAR dDate6 ID 2004 OF oDlg
   
   REDEFINE CHECKBOX oCal:lWeekNumbers ID 5000 OF oDlg ;
              ON CHANGE  oCal:SetWeekNumbers( oCal:lWeekNumbers )
   
   REDEFINE CHECKBOX oCal:lNoTodayCircle ID 5001 OF oDlg ;
              ON CHANGE  oCal:SetNoTodayCircle( oCal:lNoTodayCircle )
             
   REDEFINE CHECKBOX oCal:lNoToday ID 5002 OF oDlg ;
              ON CHANGE  oCal:SetNoToday( oCal:lNoToday )

     oCal:bGotFocus  := {|| oCal:SetTitleBk( CLR_YELLOW ) }
     oCal:bLostFocus := {|| oCal:SetTitleBk( GetSysColor( COLOR_ACTIVECAPTION ) ) }
   
   // Start Calendar 2
             
   REDEFINE CALENDAR oCal2 VAR dDate3, dDate4 ID 2005 OF oDlg;
              DBLCLICK MsgInfo( oCal2:GetDate() ) COLOR CLR_BLACK, CLR_HRED MULTISELECT

   REDEFINE SAY PROMPT "MONTHS DISPLAYED: " + StrZero( ocal2:GetVisibleMonths(), 2 ) ID 4003 OF oDlg

   REDEFINE BUTTON ID 1010 OF oDlg ;
              ACTION( aRanges := oCal2:GetDateRange(), oRange1:Refresh(), oRange2:Refresh() )
   REDEFINE GET oRange1 VAR aRanges[ 1 ] OF oDlg ID 4004
   REDEFINE GET oRange2 VAR aRanges[ 2 ] OF oDlg ID 4005

     oCal2:bGotFocus  := {|| oCal2:SetTitleBk( CLR_YELLOW ) }
     oCal2:bLostFocus := {|| oCal2:SetTitleBk( CLR_HRED ) }

   nMax = oCal2:GetMaxSelCount()
   
   REDEFINE BUTTON ID 1011 OF oDlg ;
              ACTION( oCal2:SetMaxSelCount( nMax ) )
             
   REDEFINE GET oMax VAR nMax ID 4006 OF oDlg SPINNER MIN 1 MAX 60
             
   REDEFINE CHECKBOX oCal2:lDayState ID 5003 OF oDlg ;
              ON CHANGE( oCal2:SetDayStateStyle( oCal2:lDayState ), ;
                        If( oCal2:lDayState, ( OnGetState( oCal2, lSunday, lSaturday ), oCal2:SetDayState() ), ) )

   REDEFINE CHECKBOX lSunday ID 5004 OF oDlg

   REDEFINE CHECKBOX lSaturday ID 5005 OF oDlg
   
   
   ACTIVATE DIALOG oDlg ON INIT InitState( oCal2, lSunday, lSaturday )

 
RETURN NIL

FUNCTION InitState( oCal2, lSunday, lSaturday )

   OnGetState( oCal2, lSunday, lSaturday )
   oCal2:SetDayState()
   oCal2:bOnGetState = { | oCal | OnGetState( oCal, lSunday, lSaturday ) }

RETURN NIL


Function OnGetState( oCal, lSun, lSat )
   LOCAL i, imax, j, jmax, nDay, nDayState, nMonth
   LOCAL dStartDate
   LOCAL dCurrentDay := oCal:dDate
 
   oCal:GetMonthRange()
   
   dStartDate = oCal:dDate

   imax   := Len( oCal:aDayState )
   nMonth := Month( dStartDate )


   FOR i:=1 TO imax
      nDayState := 0

      FOR j:=1 TO 31
         nDay := DoW( dStartDate ) - 2
         IF nDay < 0
            nDay += 7
         ENDIF

         IF nDay == 5 .AND. lSat
            oCal:SetArrayDayState( i, j )
         ENDIF

         IF nDay == 6 .AND. lSUN
            oCal:SetArrayDayState( i, j )
         ENDIF
         
         dStartDate ++

         IF Month( dStartDate ) <> nMonth
            EXIT
         ENDIF
      NEXT

      nMonth       := Month( dStartDate )
   NEXT

   oCal:SetDate( dCurrentDay )

return nil
 


RC FILE

Code: Select all  Expand view

CALENDAR DIALOG MOVEABLE PURE LOADONCALL DISCARDABLE 0, 0, 461, 369
STYLE DS_SETFONT |DS_MODALFRAME |WS_POPUP |WS_SYSMENU |WS_CAPTION
CAPTION "DIALOG"
FONT 8, "Microsoft Sans Serif"
LANGUAGE LANG_NEUTRAL, 0
{
  CONTROL "Get Today",1000,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,0,0,74,14
  CONTROL "Set Today",1001,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,0,15,74,14
  CONTROL "Get Color",1002,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,0,31,74,14
  CONTROL "Set Color",1003,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,76,31,74,14
  CONTROL "",2000,"SysDateTimePick32",WS_CHILD |WS_TABSTOP |WS_VISIBLE ,77,7,74,14
  CONTROL "",2001,"SysMonthCal32",WS_CHILD |WS_TABSTOP |WS_VISIBLE ,153,3,169,100
  CONTROL "",3000,"COMBOBOX",CBS_DROPDOWN |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,1,49,149,78
  CONTROL "",4000,"STATIC",SS_LEFT |WS_CHILD |WS_BORDER |WS_GROUP |WS_VISIBLE ,4,67,70,12
  CONTROL "Get 1 Day Week",1004,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,0,88,74,14
  CONTROL "Set 1 Day Week",1005,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,76,88,74,14
  CONTROL "",3001,"COMBOBOX",CBS_DROPDOWN |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,1,106,149,78
  CONTROL "Get Selected Day",1006,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,0,119,74,14
  CONTROL "Set Selected Day",1007,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,0,134,74,14
  CONTROL "",2002,"SysDateTimePick32",WS_CHILD |WS_TABSTOP |WS_VISIBLE ,77,126,74,14
  CONTROL "Get Range",1008,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,154,119,74,14
  CONTROL "Set Range",1009,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,154,134,74,14
  CONTROL "",4001,"EDIT",ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,232,119,73,14
  CONTROL "",4002,"EDIT",ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,307,119,73,14
  CONTROL "",2003,"SysDateTimePick32",WS_CHILD |WS_TABSTOP |WS_VISIBLE ,231,134,74,14
  CONTROL "",2004,"SysDateTimePick32",WS_CHILD |WS_TABSTOP |WS_VISIBLE ,307,134,74,14
  CONTROL "Week Numbers",5000,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,326,10,70,10
  CONTROL "No Today Circle",5001,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,326,23,70,10
  CONTROL "No Today",5002,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,326,35,70,10
  CONTROL "",4003,"STATIC",SS_LEFT |WS_CHILD |WS_BORDER |WS_GROUP |WS_VISIBLE ,1,162,181,11
  CONTROL "",2005,"SysMonthCal32",WS_CHILD |WS_TABSTOP |WS_VISIBLE |0x3,5,178,448,100
  CONTROL "Get Selected Range",1010,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,1,282,74,14
  CONTROL "",4004,"EDIT",ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,80,281,73,14
  CONTROL "",4005,"EDIT",ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,155,282,73,14
  CONTROL "Set Max selected Day",1011,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,1,300,101,14
  CONTROL "Edit4",4006,"EDIT",ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,107,300,47,14
  CONTROL "Day State",5003,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,1,317,70,10
  CONTROL "Bold Sunday",5004,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,1,330,70,10
  CONTROL "Bold Saturday",5005,"BUTTON",BS_CHECKBOX |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,2,342,70,10
}
 


TimStone wrote:2) Is it possible to display dates that correlate to a database, ie. if I have appointments, I want to color the dates on which they are set ?

yes is possible, but window api only accept BOLD dates

SAMPLE, Press ENTER to see list date
Code: Select all  Expand view

#include "FiveWin.ch"
#include "dtpicker.ch"
#include "calendar.ch"

FUNCTION Main()
   LOCAL oWnd, oCal
   LOCAL dDate1
   LOCAL aDates


     SET DATE TO BRITISH
     SET EPOCH TO 1980  
   dDate1 = Date()
   aDates := { Date() - 10,;
               Date() - 3,;
               Date() + 6,;
               Date() + 7,;
               Date() + 17,;
               Date() + 22,;
               Date() + 33,;
               Date() + 38 }
              
   
              
 
   DEFINE WINDOW oWnd TITLE "Test Calendar" FROM 0, 0 TO 300, 300 PIXEL
 
  @ 15, 15 CALENDAR oCal VAR dDate1 OF oWnd PIXEL DAYSTATE ACTION XBROWSE( aDates )
 
    OnGetState( oCal, aDates )
    oCal:SetDayState()
    oCal:bOnGetState = { | oCal | OnGetState( oCal, aDates ) }
 
   
   ACTIVATE WINDOW oWnd

 
RETURN NIL


Function OnGetState( oCal, aDates )
   LOCAL i, imax, j, jmax, nDay, nDayState, nMonth
   LOCAL dStartDate
   LOCAL dCurrentDay := oCal:dDate
 
   oCal:GetMonthRange()
   
   dStartDate = oCal:dDate

   nMonth := Month( dStartDate )

   FOR i = 1 TO Len( aDates )
      nDayState := 0

      IF Month( aDates[ i ] ) == nMonth

         oCal:SetArrayDayState( 1, Day( aDates[ i ] ) )
     
      ENDIF
     
   NEXT

   oCal:SetDate( dCurrentDay )

return nil
 


TimStone wrote:3) I see the Calendar is a DISPLAY but I would have to use the date picker to set the current calendar date. I noted clicking on a date could trigger a function, but I'm thinking clicking on a date should somehow change the display and focus ( current date ) of the calendar.


you can use ::SetDate( MiDate )

> but I'm thinking clicking on a date should somehow change the display and focus

yes, already working, see the samples, if you click in a date the "focus" is changed
in the next image i click over 04/11/2010
Image
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Using T Calendar 10.04

Postby TimStone » Fri Apr 30, 2010 1:59 pm

Thank you. I will work with this today.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Marc Venken, Silvio.Falconi and 106 guests