Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Handling MCN_GETDAYSTATE from month calendar
Message
 
 
To
05/06/2008 22:40:50
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01321939
Message ID:
01322064
Views:
26
Hi Carlos,

I would store AnuallyBoldedDates and MonthlyBoldedDates as an array/collection and also MONTHDAYSTATE values using _Access/_Assign. This way you'll have only build MONTHDAYSTATE when values change which'll happen less often compare to the number of calls to bold dates.
I'm not sure if you can optimize storage of BoldedDates.



>
>Thank you very much for taking some time to look into this. My problem was trying to make 'the array of MONTHDAYSTATE values' part of the structure, now I understand better, and it works as expected.
>
>I allocate a memory buffer of 32 bits * 14 months / 8 = 56 bytes. Since the month calendar can display a maximum of 12 months + 1 preceding + 1 trailing partially visible months, that makes a possible maximum of 14 months.
>
>I found out that when the control instantiates, it does not send the MCN_GETDAYSTATE message, so I use MCM_SETDAYSTATE. That works great.
>
>When handling the MCN_GETDAYSTATE message, I just call my _GetBoldedDates() procedure and then set the address of the buffer to prgDayState in the NMDAYSTATE Structure. That works great too.
>
>So the problem is solved! Thank you very much. I can´t believe how complicated this little details are.
>
>By the way, I looked at the C code you mentioned, but the truth is that for me, reading C code is like trying to read in a foreign language. I did not have the chance to learn it when I was young(er), so it´s rather uphill for me.
>
>Since you already had to dig into this, will you be kind to spend ten more minutes and tell me what do you think of the best way to "maintain" and update the day states array?
>
>So what I have right now is this:
>
>
>*!* _GetBoldedDates()
>
>*!* 32 bits * 14 months = 448 bits
>*!* 32 bits * 14 months / 8 bytes = 56 bytes
>
>Lparameters pdStartDate As Date, pnMonths As Integer
>
>Local ;
>	lcDayStates As String
>
>*!* Allocate the buffer for the daystates array if not yet allocated:
>If This._DayStatesPointer = 0 Then
>	This._DayStatesPointer = apiHeapAlloc(apiGetProcessHeap(), HEAP_ZERO_MEMORY, 56)
>Endif
>
>*!* Here update the daystates array
>m.lcDayStates = Replicate(0hff, 56)
>
>*!* Write array back to memory pointer:
>Sys(2600, This._DayStatesPointer, 56, m.lcDayStates)
>
>
>
>As you can see, right now the "update" method, just for testing, bolds all dates:
>
>m.lcMonthDayState = Replicate(0hff, 56)
>
>Since this class tries to emulate the equivalent NET classes, there will be 3 arrays or collections:
>
>AnuallyBoldedDates
>MonthlyBoldedDates
>BoldedDates
>
>AnuallyBoldedDates are dates that should be bolded in all displayed years, i.e. july 4th
>MonthlyBoldedDates are dates that should be bolded every month, i.e the 15th
>BoldedDates are dates that should be bolded, i.e. 10 october 2008
>
>So with the parameters of startdate and number of months, what do you think could be the best way to update the day states 'array' every time the control asks for it?
>
>Carlos
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform