Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - Vb6 CalendarEventLabel  help!
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Vb6 CalendarEventLabel help!

 Post Reply Post Reply
Author
Message
Jaymeister View Drop Down
Groupie
Groupie
Avatar

Joined: 27 April 2009
Status: Offline
Points: 32
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jaymeister Quote  Post ReplyReply Direct Link To This Post Topic: Vb6 CalendarEventLabel help!
    Posted: 13 May 2009 at 6:27am
can anyone post an example vb6 sub of setting an events color?
I've googled around and it seems to be based on
using CalendarEventLabel but cannot find example of its usage in vb6
I tried...

sub SetEventColor(TimeObject As CalendarEvent, byval R%, byval G%, byval B%)
  Dim eLabel As CalendarEventLabel
  eLabel.Color = RGB(R%,G%,B%)
  set TimeObject.Label = eLabel
end sub

...can anone help?
Back to Top
Jaymeister View Drop Down
Groupie
Groupie
Avatar

Joined: 27 April 2009
Status: Offline
Points: 32
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jaymeister Quote  Post ReplyReply Direct Link To This Post Posted: 13 May 2009 at 6:57am
Tried this NO errors - still no color changes - any ideas???

Sub SetEventColor(TimeObject As CalendarEvent, ByVal R%, ByVal G%, ByVal B%)
  Dim eLabel As CalendarEventLabel
  'step through labels to see if this color exists - if not create it
  For Index% = 1 To frmMain.CalendarControl.DataProvider.LabelList.Count
    If frmMain.CalendarControl.DataProvider.LabelList.Item(Index% - 1).Color = RGB(R%, G%, B%) Then
      ColorExists% = True
      Exit For
    End If
  Next Index%
 
  If ColorExists% Then
    TimeObject.Label = Index% - 1
  Else
    Index% = frmMain.CalendarControl.DataProvider.LabelList.Count + 1
    frmMain.CalendarControl.DataProvider.LabelList.AddLabel Index%, RGB(R%, G%, B%), "color" + Str$(Index%)
    TimeObject.Label = Index% - 1
  End If
End Sub
 
Back to Top
Jaymeister View Drop Down
Groupie
Groupie
Avatar

Joined: 27 April 2009
Status: Offline
Points: 32
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jaymeister Quote  Post ReplyReply Direct Link To This Post Posted: 13 May 2009 at 6:59am
WORKING - the index specified when adding a label starts from 0 - DOH!

Sub SetEventColor(TimeObject As CalendarEvent, ByVal R%, ByVal G%, ByVal B%)
  Dim eLabel As CalendarEventLabel
  'step through labels to see if this color exists - if not create it
  For Index% = 1 To frmMain.CalendarControl.DataProvider.LabelList.Count
    If frmMain.CalendarControl.DataProvider.LabelList.Item(Index% - 1).Color = RGB(R%, G%, B%) Then
      ColorExists% = True
      Exit For
    End If
  Next Index%
 
  If ColorExists% Then
    TimeObject.Label = Index% - 1
  Else
    Index% = frmMain.CalendarControl.DataProvider.LabelList.Count + 1
    frmMain.CalendarControl.DataProvider.LabelList.AddLabel Index% - 1, RGB(R%, G%, B%), "color" + Str$(Index%)
    TimeObject.Label = Index% - 1
  End If
End Sub
 
Back to Top
DataFlowJoe View Drop Down
Groupie
Groupie


Joined: 30 October 2007
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote DataFlowJoe Quote  Post ReplyReply Direct Link To This Post Posted: 15 May 2009 at 4:49am

Hi JayMeister,

I've written a routine that reads the colour codes in from a table. These colours can be set by the administartor using the colour picker which is part of the windows common dialog. The routine is called when the calendar form is loading.

'=============================================
Private Sub SetLabels()
On Error Resume Next
    Dim rs1 As Recordset, strSQL As String
    strSQL = "SELECT tblLabelColours.* FROM tblLabelColours;"
    Set rs1 = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
   
    Me.CalendarControl1.HideToolTip
    With CalendarControl1.DataProvider.LabelList
    .RemoveAll
        Do Until rs1.EOF
        .AddLabel rs1![ID], rs1![Colour], rs1![Label]
            rs1.MoveNext
        Loop
    End With
   
End Sub
'=============================================
 
The problem I've got now is to set the corresponding text in a contrasting colour. Getting a contrasting colour is simple with the following function....
 
'=========================================
Public Function GetContrastColor(lngParamColor) As Long
On Error Resume Next
    GetContrastColor = Not lngParamColor And &HFFFFFF
End Function
'=========================================
 
I don't know how to set the colour of the text from the default black to my prefered contrast.
 
I've tried the BeforeDrawThemeObject Event but I can't get it to fire in my code for some reason.....
Have you got any ideas, maybe we could collaborate a bit.
 
Thanks
 
 
 
He is no fool who gives what he cannot keep to gain what he cannot lose. (Jim Elliott)
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 15 May 2009 at 9:26am
please refer

https://forum.codejock.com/forum_posts.asp?TID=11448&KW=
Back to Top
Jaymeister View Drop Down
Groupie
Groupie
Avatar

Joined: 27 April 2009
Status: Offline
Points: 32
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jaymeister Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2009 at 3:42am
Color wise I chose label colors that were not dark, so the default black font would work,
but if you are letting users choose at runtime then, yep, someone is gonna choose rgb(0,0,0) :)

looking at the link, font forecolor seems to be set (the sample code is c code - I think) with

COLORREF clrTxt = RGB(255,0,0);

GetCalendarCtrl().GetPaintManager()->GetMonthViewEventPart()->m_clrTextHighLightColor = clrTxt;

...Oh how I wish they would give some good ol vb6 samples, anyone?

Back to Top
DataFlowJoe View Drop Down
Groupie
Groupie


Joined: 30 October 2007
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote DataFlowJoe Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2009 at 4:41am
Thanks for that but it might just as well be chinese for me, I don't know anything about C++.
Are there any examples for changing the font color using VB6, surely this should be the most basic of functions.
The other issue is the BeforeDrawThemeObject Event doesn't seem to fire in my code, I've also checked the sample vb6 code that comes with codejock and it's not firing there either. What am I missing?
He is no fool who gives what he cannot keep to gain what he cannot lose. (Jim Elliott)
Back to Top
Jaymeister View Drop Down
Groupie
Groupie
Avatar

Joined: 27 April 2009
Status: Offline
Points: 32
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jaymeister Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2009 at 7:19am
I've coded some ansi c (and even some objective c on the mac)
the problem isn't code comprehension, as any programmer should be able to read most programming languages (write is another thing)
the problem is whats exposed to the vb6 programmer...

I tend to type a controls name followed by a dot "." and use the drop-down list of options to work out what should come next
for example I wanted to turn off the calendar's "click to add" message...
  in C++ its...
  GetCalendarCtrl().GetCalendarOptions()->bEnableAddNewTooltip = FALSE;
 
  but in VB6 its...
  CalendarControl.Options.EnableAddNewTooltip = False

your forecolor issue is now a hunt the VB6 method that in C++ is...
  GetCalendarCtrl().GetPaintManager()->GetMonthViewEventPart()->m_clrTextHighLightColor = clrTxt;

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.156 seconds.