Vb6 CalendarEventLabel help! |
Post Reply |
Author | |
Jaymeister
Groupie Joined: 27 April 2009 Status: Offline Points: 32 |
Post Options
Thanks(0)
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? |
|
Jaymeister
Groupie Joined: 27 April 2009 Status: Offline Points: 32 |
Post Options
Thanks(0)
|
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 |
|
Jaymeister
Groupie Joined: 27 April 2009 Status: Offline Points: 32 |
Post Options
Thanks(0)
|
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 |
|
DataFlowJoe
Groupie Joined: 30 October 2007 Status: Offline Points: 12 |
Post Options
Thanks(0)
|
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)
|
|
prashant
Senior Member Joined: 19 February 2007 Location: India Status: Offline Points: 165 |
Post Options
Thanks(0)
|
please refer
https://forum.codejock.com/forum_posts.asp?TID=11448&KW= |
|
Jaymeister
Groupie Joined: 27 April 2009 Status: Offline Points: 32 |
Post Options
Thanks(0)
|
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? |
|
DataFlowJoe
Groupie Joined: 30 October 2007 Status: Offline Points: 12 |
Post Options
Thanks(0)
|
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)
|
|
Jaymeister
Groupie Joined: 27 April 2009 Status: Offline Points: 32 |
Post Options
Thanks(0)
|
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; |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |