Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Scroll hor. to a given day
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Scroll hor. to a given day

 Post Reply Post Reply
Author
Message
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Topic: Scroll hor. to a given day
    Posted: 09 January 2008 at 11:26am
Hello
 
is it possible to scroll programmatically to a given day in day view that is outside the actual view (like with the scrollbar manually)?
 
thanks in advance
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 09 January 2008 at 1:56pm

.DayView.ShowDays(ActualDate, ActualDate + X)
.Populate


--
WBR,
Serge
Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 10 January 2008 at 8:28am
Hello Serge
 
thanks for your reply. But that is not exactly what I am searching for but it is the first part of the story:
 
With .Showdays I can direct a dayview to show days from - let me say - Jan. 7 to Jan 18. But now the second part: because the for instance the 16.  is not shown on screen I should move the dayview horizontally so that the the 16. was shown but the user shoud be still able to move back with the scroll bar to the 7...
 
Any idea? Thanks
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 17 January 2008 at 1:42am
Hi all
 
 
Really no solution for this...
 
 
Thanks in advance
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 31 January 2008 at 11:08am
Is this really not possible???
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 19 February 2008 at 11:28am
I should have a method like:
 
dayView.EnsureVisibleDay(d as Date)
 
Eventually possible for V12?
 
Thanks in advance
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2008 at 6:22am
As I checked feature list for v12, there is still no possibility to move the calendar in day view to a given day? Simply missing in list or missing feature. If anybody has som time please implement this method!!!
 
Thanks
Fabian
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2008 at 11:10am
Hello,
 
You can test this subroutine to do the job:
 
Sub GotoDate(Dt As Date)
Dim ViewTp As CalendarViewType
    Screen.MousePointer = vbHourglass
    With Calendar
    ViewTp = .ViewType
    LockWindowUpdate .hwnd
    Select Case ViewTp
        Case xtpCalendarMonthView
            .MonthView.ShowDay Dt, True
        Case xtpCalendarDayView
            .DayView.ShowDay Dt, True
        Case xtpCalendarWorkWeekView
            .DayView.ShowDay Dt, True
            .ViewType = ViewTp
        Case xtpCalendarWeekView
            .WeekView.ShowDay Dt, True
    End Select
    LockWindowUpdate 0
    Screen.MousePointer = vbDefault
End Sub
 
 
I use LockWindowUpdate Api to prevent flickering, in CalendarWorkWeelView Mode, so we must put the declaration line below in the beginning of the code: 
Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
 
 
I hope that it is what you are looking for.
 
 
 
Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2008 at 12:11pm
Hi Dentor
 
thanks for thinking about this problem but your idea doesn't work as I expect. I must show e.g. 10 days in dayview but only 4 are visible. So it should be possible to scroll programmatically to day 6, like a method CalendarControl.EnsureVisible(d as Date).
 
thanks again
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2008 at 12:43pm
Hi Fabian,

Can you explain how you've set up your calendar in a bit more detail? I've tried using Me.CalendarControl1.DayView.ShowDays "Jan 7, 2008", "Jan 18, 2008" and it shows every day from Jan 7 to Jan 18, no scrolling required (when in DayView). You mention that your view doesn't show Jan 16, so I'm wondering how you have your control set up.
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2008 at 1:23pm
Ok, I see.
 
Just another subroutine that can do the trick:
 
Sub EnsureVisibleDate(Dt As Date)
Dim LastDay As Long
    With Calendar
        ' *** How many days in Dayview
        LastDay = .DayView.DaysCount - 1
        ' *** Date below or above dayview
        If Dt < .DayView(0).Date Then
            .DayView.ShowDays Dt, Dt + LastDay
        ElseIf Dt > .DayView(LastDay).Date Then
            .DayView.ShowDays Dt - LastDay, Dt
        End If
    End With
End Sub
 
 
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 23 March 2008 at 2:14pm
Hi Fabian,

I've re-examined your posts, and I *think* I understand what you want to do:

1) Only allow the user to scroll over a range of dates (for example, 10 days from today)
2) Only show the user a subset of those dates (for example, 4 days on-screen at once) in DayView

I've put together a sample that can fulfil those requirements. The form requires a Codejock ScrollBar control (ScrollBar1) and a Codejock CalendarControl (CalendarControl1).

It may be buggy since I haven't tested it extensively, but it should illustrate the principles:


Option Explicit

Private Const mclngViewableDays As Long = 4   ' Days to show on-screen at once
Private Const mclngScrollableDays As Long = 10  ' Allowable days to scroll around DayView

Private mlngScrollDirection As Long

Private Sub CalendarControl1_KeyDown(KeyCode As Integer, Shift As Integer)
   ' To move the scrollbar on right/left arrow keys at edge of view
   Select Case KeyCode
   Case vbKeyRight
      ' Right arrow key
      If Me.ScrollBar1.Value < Me.ScrollBar1.Max Then
         ' There are hidden future dates
         If Fix(Me.CalendarControl1.DayView.Selection.End) = Fix(Me.CalendarControl1.DayView.Days(VisibleViewDays).Date) Then
            ' We are at the right-most visible date
            ' So scroll right
            mlngScrollDirection = 1 ' Right
            Me.ScrollBar1.Value = Me.ScrollBar1.Value + 1
         End If
      End If
   Case vbKeyLeft
      ' Left arrow key
      If Me.ScrollBar1.Value > Me.ScrollBar1.Min Then
         ' There are hidden past dates
         If Fix(Me.CalendarControl1.DayView.Selection.Begin) = Fix(Me.CalendarControl1.DayView.Days(0).Date) Then
            ' We are at the left-most visible date
            ' so scroll left
            mlngScrollDirection = -1   ' Left
            Me.ScrollBar1.Value = Me.ScrollBar1.Value - 1
         End If
      End If
   End Select
End Sub

Private Sub CalendarControl1_ViewChanged()
   ' Reset the selected position after scrolling in the KeyDown event
   ' because KeyUp pushes the selection an extra day left/right
   Dim datStart As Date
  
   With Me.CalendarControl1.DayView
      datStart = .Selection.Begin - mlngScrollDirection
     
      On Error Resume Next
      If Fix(datStart) >= Fix(.Days(0).Date) And Fix(datStart) <= Fix(.Days(VisibleViewDays).Date) Then
         If Err.Number = 0 Then
            .Selection.Begin = datStart
            .Selection.End = .Selection.Begin + (.TimeScale / 60 / 24)  ' add 1 timescale unit to the end selection
         End If
      End If
   End With
End Sub

Private Sub Form_Load()
   With Me.CalendarControl1
      .ViewType = xtpCalendarDayView
      .DayView.EnableHScroll False  ' Don't let the user scroll horizontally using the keyboard
   End With
  
   Me.ScrollBar1.Max = (mclngScrollableDays - 1) \ mclngViewableDays
   ScrollBar1_Scroll
End Sub

Private Function VisibleViewDays() As Long
   Dim lngViewableDays As Long
  
   If Me.ScrollBar1.Value < Me.ScrollBar1.Max Then
      lngViewableDays = mclngViewableDays - 1
   Else
      lngViewableDays = mclngScrollableDays Mod mclngViewableDays - 1
      If lngViewableDays < 0 Then
         lngViewableDays = mclngViewableDays - 1
      End If
   End If
  
   VisibleViewDays = lngViewableDays
End Function

Private Sub ScrollBar1_Change()
   ScrollBar1_Scroll
End Sub

Private Sub ScrollBar1_Scroll()
   Dim datStart As Date
  
   datStart = Now + (mclngViewableDays * Me.ScrollBar1.Value)
   With Me.CalendarControl1.DayView
      .ShowDays datStart, datStart + VisibleViewDays
   End With
End Sub

Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2008 at 4:27am
Thanks for your effort
 
But my problem can not been solved with the current version, so I cried for a new method:
 
I use
 
DayView.EnableHScroll
DayView.ShowDays(Date1, Date2)
 
Because I allow hor. scrolling, not all days are shown in my window. The user can scroll horizontally to view all events of all days. But I have built in a search function, that finds the next free time. If this time was outside the actual shown days I will .EnsureVisible(Date):
                            ¦ Window border
                            ¦
|Day1|Day2|Day3|Day4|day5
                            ¦
 
Day1 to 3 are visible but I wish to scroll so e.g. day1 vanishes and day4 was shown.
 
hope this clarifies my problem and I hope CJ has an ear for me
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2008 at 4:51am
Hello Fabian,
 
Did you test the EnsureVisibleDate subroutine showed above. I think it make a response for your problem to show the date in the calendar after your search routine.
 
 
Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2008 at 5:45am
Hello Dentor
 
Yes your code goes in the right direction. But because we have no indication if a day is visible or not I always scroll the given day around. So what I expect from CJ is a simple method .EnsureVisibleDate(Date) (like the allready present method .EnsureVisible(Viewevent)). It sould move the day into view if necessary.
 
Thanks a lot for your help
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2008 at 6:05am
Hello Fabian,
 
If you watch the code, you'll see that if the day is visible, the subroutine do nothing.
 
I agree with you, it will be better if CJ make an intrinsec method EnsureVisible to do the job. Meanwhile, I think it's a good workaround.
 
Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2008 at 9:16am
Hi dentor
 
I am not shure if you are rigth. How do you know how much days are visible?
 
I enable horizontal scrolling with .EnableHScroll True and I thought DaysCount returns the total number of days in a day view not only the visible ones...
 
Am I wrong???
 
 
Product: Xtreme SuitePro (ActiveX) version 16.2.3

Platform: Windows 7 (32bit)

Language: Visual Basic 6.0 / SP6
Back to Top
dentor View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2005
Location: France
Status: Offline
Points: 102
Post Options Post Options   Thanks (0) Thanks(0)   Quote dentor Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2008 at 9:42am
Apparently, the Dayview.Daycount return only the number of visible days (not the invisible days), even if Dayview.EnableHscroll is turn to True.
 
So we can know how many days are visible.
 
Did you try the code?
 
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 24 March 2008 at 12:36pm
Just out of curiosity, how do you show the horizontal scrollbar? When I use this code:


   With Me.CalendarControl1
        .ViewType = xtpCalendarDayView
        .DayView.EnableHScroll True
        .DayView.ShowDays Now, Now + 10
   End With


It shows all 10 days squished into the view with no horizontal scrollbar. On my computer EnableHScroll only seems to apply to horizontal scrolling using the keyboard.

Is there another setting requried to show the horizontal scrollbar?
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.