1. Month Calendar control: make dates bold?
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Feb 22, 2005
- 479 views
I'm making use of the Month Calendar control, & I'm pretty sure there's some way to make selected dates show BOLD, but that option is not included in Win32Lib; does anyone know how to make programmatically selected dates show bold on the calendar? Dan Moyer
2. Re: Month Calendar control: make dates bold?
- Posted by Jonas Temple <jtemple at yhti.net> Feb 22, 2005
- 447 views
Dan, If you want to set a single date then use SetSelectedDate() in Win32Lib. If you want to set more than one day then you will need to use sendMessage with MCM_SETDAYSTATE. According to MSDN: lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) MCM_SETDAYSTATE, // message ID (WPARAM) wParam, // = (WPARAM) (int) iMonths; (LPARAM) lParam // = (LPARAM) (LPMONTHDAYSTATE) lpDayStateArray; ); The iMonths says how many elements are in the lpDayStateArray. The lpDayStateArray is basically a DWORD where bits 1-31 relate to a day in the month. If the bit is on, the day is in bold. Jonas Temple http://www.yhti.net/~jktemple
3. Re: Month Calendar control: make dates bold?
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Feb 23, 2005
- 459 views
> posted by: Jonas Temple <jtemple at yhti.net> > > Dan, > > If you want to set a single date then use SetSelectedDate() in Win32Lib. > If you want to set more than one day then you will need to use sendMessage > with MCM_SETDAYSTATE. According to MSDN: > > lResult = SendMessage( // returns LRESULT in lResult > (HWND) hWndControl, // handle to destination control > (UINT) MCM_SETDAYSTATE, // message ID > (WPARAM) wParam, // = (WPARAM) (int) iMonths; > (LPARAM) lParam // = (LPARAM) (LPMONTHDAYSTATE) lpDayStateArray; > ); > > The iMonths says how many elements are in the lpDayStateArray. The > lpDayStateArray is basically a DWORD where bits 1-31 relate to a day > in the month. If the bit is on, the day is in bold. > > Jonas Temple > http://www.yhti.net/~jktemple > Thanks Jonas, I've used the SetSelectedDate() in Win32Lib to move the date around programmatically, but what I'm trying to do is not *set* the date, (as in make the calendar show that date with an ellipse around it), but rather make specified dates show up in bold print (so as to specify "something special" about those dates). I copied a bunch of stuff like what you suggested above from the MS site, including "Processing the MCN_GETDAYSTATE Notification Message", and "MCN_GETDAYSTATE Notification ", "NMDAYSTATE Structure", "NMHDR Structure ", "SYSTEMTIME structure", etc, but I don't know how to translate it all (or even your simpler suggestion) into Euphoria code. Probably this is something that could/should be added to Win32Lib? But in the meantime, any help from anyone in xlating the C stuff into Euphoria would be appreciated. Dan
4. Re: Month Calendar control: make dates bold?
- Posted by Al Getz <Xaxo at aol.com> Feb 23, 2005
- 478 views
Hi there Dan, how ya been? I dont think it's that hard really but there are some structs to deal with. I think you need to process the GETDAYSTATE notification also, where you'll return a pointer to a DAYSTATE struct, that contains one or more MONTHDAYSTATE values. If no one else wants to post working code i'll work something out if you need it. Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's" danielmoyer wrote: > > > > posted by: Jonas Temple <jtemple at yhti.net> > > > > Dan, > > > > If you want to set a single date then use SetSelectedDate() in Win32Lib. > > If you want to set more than one day then you will need to use sendMessage > > with MCM_SETDAYSTATE. According to MSDN: > > > > lResult = SendMessage( // returns LRESULT in lResult > > (HWND) hWndControl, // handle to destination control > > (UINT) MCM_SETDAYSTATE, // message ID > > (WPARAM) wParam, // = (WPARAM) (int) iMonths; > > (LPARAM) lParam // = (LPARAM) (LPMONTHDAYSTATE) > lpDayStateArray; > > ); > > > > The iMonths says how many elements are in the lpDayStateArray. The > > lpDayStateArray is basically a DWORD where bits 1-31 relate to a day > > in the month. If the bit is on, the day is in bold. > > > > Jonas Temple > > <a href="http://www.yhti.net/~jktemple">http://www.yhti.net/~jktemple</a> > > > > Thanks Jonas, > > I've used the SetSelectedDate() in Win32Lib to move the date around > programmatically, but what I'm trying to do is not *set* the date, (as in > make the calendar show that date with an ellipse around it), but rather make > specified dates show up in bold print (so as to specify "something special" > about those dates). > > I copied a bunch of stuff like what you suggested above from the MS site, > including "Processing the MCN_GETDAYSTATE Notification Message", and > "MCN_GETDAYSTATE Notification ", "NMDAYSTATE Structure", "NMHDR Structure ", > "SYSTEMTIME structure", etc, but I don't know how to translate it all (or > even your simpler suggestion) into Euphoria code. > > Probably this is something that could/should be added to Win32Lib? > > But in the meantime, any help from anyone in xlating the C stuff into > Euphoria would be appreciated. > > Dan > >
5. Re: Month Calendar control: make dates bold?
- Posted by Jonas Temple <jtemple at yhti.net> Feb 23, 2005
- 452 views
Dan, Okay, I've figured the MCM_SETDAYSTATE out. Actually, I had created a routine some time ago to do this so it sounded vaguely familiar. To use this routine, you'll need my WIN32EXT.EW file from the contributions page. This include has three routines that you'll need: getDateRange, setDateRange and setDayStates. Here's the example code (and I know it works);)
setSelectedDate(CalendarCC, 2005, 2, 23) setDateRange(CalendarCC, 2005,2,1,2005,2,28) rtn_seq = getDateRange(CalendarCC,GMR_DAYSTATE) range = rtn_seq[7] days = repeat(0,31) dates = repeat(days,range) dates[1][30] = 1 dates[2][1] = 1 dates[2][15] = 1 setDayStates(CalendarCC, dates)
First, I set the selected date to the current date. Then I limit the user to only be able to see the month of February. The getDateRange passing the GMR_DAYSTATE value returns the number of months the calendar control will display. I know, it only displays 1 BUT this includes any days from the prior or next month that might happen to display on the control. The 7th element is the number of months. Elements 1-3 is the from year/month/day and elements 4-6 is the to year/month/day. In this example, the range is 3 since you can see days from January and March on the calendar. This might seem redundant since you set the date range in the prior function but you can't assume the range will be 1. Then I use the setDayStates routine to set how each day is displayed. In order to use this routine you will have to pass a calendar control ID and a sequence that contains one sequence for each month that is displayed. The month sequence then needs to contain a 0 or 1 for each day of the month. For example, since the range was 3: { {0,0,0,0,0,0,0,0,0,...}, {0,0,0,0,0,0,0,0,0,...}, {0,0,0,0,0,0,0,0,0,...} } Then you just set the element that corresponds to the day you want displayed in bold to 1. In the above code example, January 30th, February 1st and February 15th will display in bold. Don't worry about having 31 elements for February, Windows will ignore the extra elements. BTW, WIN32EXT also has setDateRange where you can limit the date range the user can see. Jonas Temple http://www.yhti.net/~jktemple
6. Re: Month Calendar control: make dates bold?
- Posted by Al Getz <Xaxo at aol.com> Feb 23, 2005
- 437 views
Hi again Dan and Jonas, Ok this turned out to be even simpler than i thought. The trick is to set the initial dates after the control is created and to process the notify message. The following code was used with the WinClass library, but it can be easily converted for any other lib. The main idea was to simply not set the leading month, set the present month day #1, and set the trailing month day #2 (etc) for EVERY set of months that appear on the calendar. To coordinate months with the application you'll also have to add SYSTEMTIME processing, which shouldnt be hard. --First set initial days using the previous post's message. atom pDSs --declared and allocated outside of notify function pDSs=allocate(4*12) function onNotify_MC1(atom ID,atom hWnd,atom uMsg, atom wParam, atom lParam) atom code,cDayState code=uMsg --any other lib use: NMHDR[3] if code=MCN_GETDAYSTATE then --note lParam=lpNMDAYSTATE struct cDayState=peek4u(lParam+28) --min number of months that need processing for k=0 to cDayState-1 do poke4(pDSs+k*4,k) --make sure enough space was allocated to handle -- various cases. end for poke4(lParam+32,pDSs)--tell windows where your values are end if return 0 end function MC:AddEvent(onNotify,MC1,routine_id("onNotify_MC1")) --Cleanup routine: procedure Cleanup() free(pDSs) end procedure Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's"
7. Re: Month Calendar control: make dates bold?
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Feb 24, 2005
- 461 views
From: "Dan Moyer" <DANIELMOYER at prodigy.net> > I'm making use of the Month Calendar control, & I'm pretty sure there's some > way to make selected dates show BOLD, but that option is not included in > Win32Lib; does anyone know how to make programmatically selected dates show > bold on the calendar? > > Dan Moyer > <Jonas & Al responed by developing examples, in other posts..> Thanks Jonas & Al, I'm beginning to understand your examples, I think :) Al wrote: >>"Hi there Dan, how ya been?" I've been a bit stressed out, we had to put my dad in a nursing home, things a bit hectic, so hadn't been doing any programming until recently, you guessed it, an appointment book :) >>for k=0 to 2 do >> poke4(pDSs+k*4,k) --None for leading month, day 1 for present month, etc. >>end for Did you mean that to be k = 0 to 12 ?? And does that set up an example set of daystates, setting no day bold in preceding month, day 1 bold in current month, etc, day 12 bold in 12th month (from now?)? Jonas wrote: >>" But in reality, would you really want to set that many >>days states at one time (for multiple months)? " Yes, because the dates I want to show in bold would be for recurrent things, ie, those which would show up in each month, like bills, etc. Thanks again guys, now I'll see what I can do with your examples! :) Dan Moyer
8. Re: Month Calendar control: make dates bold?
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Feb 24, 2005
- 484 views
Some questions: > posted by: Al Getz <Xaxo at aol.com> > > Hi again Dan and Jonas, > > Ok this turned out to be even simpler than i thought. > The trick is to set the initial dates after the control is created > and to process the notify message. > > The following code was used with the WinClass library, but it can > be easily converted for any other lib. The main idea was to simply > not set the leading month, set the present month day #1, and set > the trailing month day #2 (etc) for EVERY set of months that appear on the > calendar. To coordinate months with the application you'll also have > to add SYSTEMTIME processing, which shouldnt be hard. > > > --First set initial days using the previous post's message. > > > atom pDSs --declared and allocated outside of notify function > pDSs=allocate(4*12) > > function onNotify_MC1(atom ID,atom hWnd,atom uMsg, atom wParam, atom lParam) > atom code,cDayState > > code=uMsg --any other lib use: NMHDR[3] > > if code=MCN_GETDAYSTATE then > --note lParam=lpNMDAYSTATE struct > cDayState=peek4u(lParam+28) --min number of months that need processing if lParam+28 is telling min months, where/when was the struc *given* that info? > for k=0 to cDayState-1 do > poke4(pDSs+k*4,k) --make sure enough space was allocated to handle > -- various cases. > end for > poke4(lParam+32,pDSs)--tell windows where your values are > end if > return 0 > end function > MC:AddEvent(onNotify,MC1,routine_id("onNotify_MC1")) What's that MC, and AddEvent?? Using Win32Lib, would I use "setNotifyHandler"? > > --Cleanup routine: > procedure Cleanup() > free(pDSs) > end procedure Call this on close app, or some other time too? I'll have other questions, but maybe not for a couple of days. However, if either/both of you had the time to make a full (Win32Lib) demo, I'm guessing Derek would probably include it as a demo with Win32Lib, which would help anyone else who wanted to use this aspect of MonthCalendar, as well as me. Thanks again, both of you. Dan
9. Re: Month Calendar control: make dates bold?
- Posted by Jonas Temple <jtemple at yhti.net> Feb 24, 2005
- 473 views
danielmoyer wrote: > > Some questions: > > > function onNotify_MC1(atom ID,atom hWnd,atom uMsg, atom wParam, atom > lParam) > > atom code,cDayState > > > > code=uMsg --any other lib use: NMHDR[3] > > > > if code=MCN_GETDAYSTATE then > > --note lParam=lpNMDAYSTATE struct > > cDayState=peek4u(lParam+28) --min number of months that need > processing > > if lParam+28 is telling min months, where/when was the struc *given* that > info? The struc was in the lParam or maybe I don't understand your question. > > MC:AddEvent(onNotify,MC1,routine_id("onNotify_MC1")) > > What's that MC, and AddEvent?? > Using Win32Lib, would I use "setNotifyHandler"? Dan, Here's a working MCN_GETDAYSTATE notifier using Win32Lib:
-------------------------------------------------------------------------------- -- Set day state function CalendarCC_onDayState(integer id, atom hWnd, atom wParam, atom lParam) atom hwndFrom, idFrom, code, cDayState, daystates, year, month, dayofweek, day, hour, minute, second, millisecond sequence wrk_states -- Get the structure data hwndFrom = peek4u(lParam) idFrom = peek4u(lParam+4) code = peek4u(lParam+8) year = peek2u(lParam+12) month = peek2u(lParam+14) dayofweek = peek2u(lParam+16) day = peek2u(lParam+18) hour = peek2u(lParam+20) minute = peek2u(lParam+22) second = peek2u(lParam+24) millisecond = peek2u(lParam+26) cDayState = peek4u(lParam+28) -- Allocate memory for the day states if not yet done if not day_statesx then free(day_statesx) day_statesx = 0 day_statesx = allocate(cDayState*4) end if -- Get a sequence to set the dates wrk_states = getDayStateSeq(CalendarCC) -- Now convert the sequences to atoms and poke into memory for i = 0 to cDayState-1 do daystates = bits_to_int(wrk_states[i+1]) poke4(day_statesx+(i*4),daystates) end for -- Set the return value poke4(lParam+32,day_statesx) return kReturnNow end function void = setNotifyHandler(MCN_GETDAYSTATE, routine_id("CalendarCC_onDayState"))
Note that this routine doesn't set any dates to bold, it just handles the notification. You could, for example, set the 2nd day of the 2nd month to bold by inserting after the call to getDayStates(): wrk_states[2][2] = 1 The getDayStateSeq is a new routine in WIN32EXT.EW that I will upload to the contributions page shortly. What it does is returns a sequence made up of one sequence for every month displayed on a calendar control. > > > > > --Cleanup routine: > > procedure Cleanup() > > free(pDSs) > > end procedure > > Call this on close app, or some other time too? In my example I free/allocate the memory each time. Why? Well, you shouldn't assume that the first allocation of memory is sufficient to subsequent number of months. Although looking at the calendar control, it appears that there is always 3 months displayed, even if the first of the month starts on a Sunday. It starts the month on the second line under this condition. So you could even hard code 3 as the number of cdayStates to allocate (3*4=12). So in my example, you would really need to free() the memory at the end of your prog, like on an onClose event. > > I'll have other questions, but maybe not for a couple of days. However, if > either/both of you had the time to make a full (Win32Lib) demo, I'm guessing > Derek would probably include it as a demo with Win32Lib, which would help > anyone else who wanted to use this aspect of MonthCalendar, as well as me. > If I find the time, I am actually going to use this technique in my timesheet program (available in the archives). I'd like to show the user when they're selecting a from/to date the other from/to date that has been selected. That is, if it's in the visible month. Jonas Temple http://www.yhti.net/~jktemple
10. Re: Month Calendar control: make dates bold?
- Posted by Al Getz <Xaxo at aol.com> Feb 24, 2005
- 488 views
Hi there Dan, I hope this isnt too long of a post, but there was a lot of information even though the basic method of handling this isnt really that complicated. I've included some more info here, but i see now we should probably discuss the aspect of the wrap from the user's (ie the person who will use the code, not the end user of the program) perspective. Since it's entirely possible that the end user will require many dates set, these dates will have to be included in the end user interface and should probably be converted into a sequence something like: sequence Bolds= { { year1,{days for month1}, {days for month2},...,{days for month12} }, { year2,{days for month1}, ... }, ... } as well as a 'constant' sequence for setting every single month: sequence AlwaysBold= {{days for month1}, {days for month2}, ... } In this way the programmer could pass these two sequences to the MC control and that would be that. The code would be responsible for deciding which months get sent to the control within the notification message function based on the SYTEMTIME information. How's that sound? I guess it wouldnt be too hard to wrap that for WinLib too if no one else wants to do it... > >What's that MC, and AddEvent?? >Using Win32Lib, would I use "setNotifyHandler"? In the WinClass library, the MonthCalendar control class is included like: include monthcalendar.ew as MC Then, an instance MC1 of the monthcalendar is created: constant MC1=MC:Create(...parameters like style, size, font, parentwindow, etc...) which creates and possibly draws the month calendar control in the parent window. The line: MC:AddEvent(onNotify,MC1,routine_id("onNotify_MC1")) adds the 'Notify' event to the MC1 control using the function "onNotify_MC1" which is declared earlier. Of course this will eventually be included in the class definition of the MonthCalendar so the programmer will do this: ------------------------------------------------------------------------- constant MC1=MC:Create(...parameters...) MC:SetDynamicBoldMonths(DynBoldMonths) --sequence DynBoldMonths as above MC:SetStaticBoldMonths(StaticBoldMonths) --also sequence as above ------------------------------------------------------------------------- Yes i think you would use 'setNotifyHandler'... wasnt there another post on something like this? I was still waiting for WinLib to settle down a bit before i use it too much so perhaps someone that uses it a bit more can be more help to you there. Here's some details on the notification message used for setting the bold days in each month... The notification MCN_GETDAYSTATE sends a pointer to a NMDAYSTATE struct via the lParam. This means in Euphoria lpNMDayState=lParam. Here's the struct sent: typedef struct tagNMDAYSTATE { NMHDR nmhdr; SYSTEMTIME stStart; int cDayState; //minimum number of months (and MONTHDAYSTATE values needed) LPMONTHDAYSTATE prgDayState; //points to first of N (N=cDayState) MONTHDAYSTATE values } NMDAYSTATE, *LPNMDAYSTATE; This is a variable length struct where... NMHDR contains 3 members 4 bytes each: typedef struct tagNMHDR { HWND hwndFrom; UINT idFrom; UINT code; } NMHDR; SYSTEMTIME contains several word (2 byte) members: typedef struct _SYSTEMTIME { WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME, *PSYSTEMTIME; MONTHDAYSTATE values: One 4 byte DWORD value (32 bits) where bits 1 to 31 correspond to the days of the month for any given month. Since in NMDAYSTATE there could be any number of MONTHDAYSTATE values the pointer LPMONTHDAYSTATE will usually point to at least 3 MONTHDAYSTATE values which means several 4 byte dwords, one for each month that the calendar control will be showing (which is previously determined by Windows according to (i think) the font size and the area of the display window and some built in sizes. Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's"
11. Re: Month Calendar control: make dates bold?
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Feb 26, 2005
- 430 views
Thanks Jonas, two questions (for now), repeated below in your post: > Note that this routine doesn't set any dates to bold, it just handles the > notification. You could, for example, set the 2nd day of the 2nd month > to bold by inserting after the call to getDayStates(): 1. *What* call to getDayStates() ?? I don't see any such call. > The getDayStateSeq is a new routine in WIN32EXT.EW that I will upload to > the contributions page shortly. 2. It's not yet uploaded, can you send me a copy of that routine? Dan Moyer > posted by: Jonas Temple <jtemple at yhti.net> > > danielmoyer wrote: > > > > Some questions: > > > > > function onNotify_MC1(atom ID,atom hWnd,atom uMsg, atom wParam, atom > > lParam) > > > atom code,cDayState > > > > > > code=uMsg --any other lib use: NMHDR[3] > > > > > > if code=MCN_GETDAYSTATE then > > > --note lParam=lpNMDAYSTATE struct > > > cDayState=peek4u(lParam+28) --min number of months that need > > processing > > > > if lParam+28 is telling min months, where/when was the struc *given* that > > info? > > The struc was in the lParam or maybe I don't understand your question. > > > > MC:AddEvent(onNotify,MC1,routine_id("onNotify_MC1")) > > > > What's that MC, and AddEvent?? > > Using Win32Lib, would I use "setNotifyHandler"? > > Dan, > > Here's a working MCN_GETDAYSTATE notifier using Win32Lib: > > }}} <eucode> > -------------------------------------------------------------------------- ------ > -- Set day state > function CalendarCC_onDayState(integer id, atom hWnd, atom wParam, atom lParam) > atom hwndFrom, idFrom, code, cDayState, daystates, > year, month, dayofweek, day, hour, minute, > second, millisecond > sequence wrk_states > > -- Get the structure data > hwndFrom = peek4u(lParam) > idFrom = peek4u(lParam+4) > code = peek4u(lParam+8) > year = peek2u(lParam+12) > month = peek2u(lParam+14) > dayofweek = peek2u(lParam+16) > day = peek2u(lParam+18) > hour = peek2u(lParam+20) > minute = peek2u(lParam+22) > second = peek2u(lParam+24) > millisecond = peek2u(lParam+26) > cDayState = peek4u(lParam+28) > > -- Allocate memory for the day states if not yet done > if not day_statesx then > free(day_statesx) > day_statesx = 0 > day_statesx = allocate(cDayState*4) > end if > > -- Get a sequence to set the dates > wrk_states = getDayStateSeq(CalendarCC) > > -- Now convert the sequences to atoms and poke into memory > for i = 0 to cDayState-1 do > daystates = bits_to_int(wrk_states[i+1]) > poke4(day_statesx+(i*4),daystates) > end for > > -- Set the return value > poke4(lParam+32,day_statesx) > > return kReturnNow > end function > void = setNotifyHandler(MCN_GETDAYSTATE, routine_id("CalendarCC_onDayState")) > </eucode> {{{ > > Note that this routine doesn't set any dates to bold, it just handles the > notification. You could, for example, set the 2nd day of the 2nd month > to bold by inserting after the call to getDayStates(): What call to getDayStates() ?? > > wrk_states[2][2] = 1 > > The getDayStateSeq is a new routine in WIN32EXT.EW that I will upload to > the contributions page shortly. What it does is returns a sequence made > up of one sequence for every month displayed on a calendar control. It's not yet uploaded, can you send me a copy of that routine? > > > > > > --Cleanup routine: > > > procedure Cleanup() > > > free(pDSs) > > > end procedure > > > > Call this on close app, or some other time too? > > In my example I free/allocate the memory each time. Why? Well, you > shouldn't assume that the first allocation of memory is sufficient to > subsequent number of months. Although looking at the calendar control, > it appears that there is always 3 months displayed, even if the first > of the month starts on a Sunday. It starts the month on the second line > under this condition. So you could even hard code 3 as the number of > cdayStates to allocate (3*4=12). > > So in my example, you would really need to free() the memory at the end > of your prog, like on an onClose event. > > > > > I'll have other questions, but maybe not for a couple of days. However, if > > either/both of you had the time to make a full (Win32Lib) demo, I'm guessing > > Derek would probably include it as a demo with Win32Lib, which would help > > anyone else who wanted to use this aspect of MonthCalendar, as well as me. > > > > If I find the time, I am actually going to use this technique in my > timesheet program (available in the archives). I'd like to show the user > when they're selecting a from/to date the other from/to date that has > been selected. That is, if it's in the visible month. > > Jonas Temple > http://www.yhti.net/~jktemple > > > >
12. Re: Month Calendar control: make dates bold?
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Feb 26, 2005
- 488 views
> > posted by: Jonas Temple <jtemple at yhti.net> > > danielmoyer wrote: > > > > Some questions: > > > > > function onNotify_MC1(atom ID,atom hWnd,atom uMsg, atom wParam, atom > > lParam) > > > atom code,cDayState > > > > > > code=uMsg --any other lib use: NMHDR[3] > > > > > > if code=MCN_GETDAYSTATE then > > > --note lParam=lpNMDAYSTATE struct > > > cDayState=peek4u(lParam+28) --min number of months that need > > processing > > > > if lParam+28 is telling min months, where/when was the struc *given* that > > info? > > The struc was in the lParam or maybe I don't understand your question. > > > > MC:AddEvent(onNotify,MC1,routine_id("onNotify_MC1")) > > > > What's that MC, and AddEvent?? > > Using Win32Lib, would I use "setNotifyHandler"? > > Dan, > > Here's a working MCN_GETDAYSTATE notifier using Win32Lib: > > }}} <eucode> > -------------------------------------------------------------------------- ------ > -- Set day state > function CalendarCC_onDayState(integer id, atom hWnd, atom wParam, atom lParam) > atom hwndFrom, idFrom, code, cDayState, daystates, > year, month, dayofweek, day, hour, minute, > second, millisecond > sequence wrk_states > > -- Get the structure data > hwndFrom = peek4u(lParam) > idFrom = peek4u(lParam+4) > code = peek4u(lParam+8) > year = peek2u(lParam+12) > month = peek2u(lParam+14) > dayofweek = peek2u(lParam+16) > day = peek2u(lParam+18) > hour = peek2u(lParam+20) > minute = peek2u(lParam+22) > second = peek2u(lParam+24) > millisecond = peek2u(lParam+26) > cDayState = peek4u(lParam+28) > > -- Allocate memory for the day states if not yet done > if not day_statesx then > free(day_statesx) > day_statesx = 0 > day_statesx = allocate(cDayState*4) > end if > > -- Get a sequence to set the dates > wrk_states = getDayStateSeq(CalendarCC) > > -- Now convert the sequences to atoms and poke into memory > for i = 0 to cDayState-1 do > daystates = bits_to_int(wrk_states[i+1]) > poke4(day_statesx+(i*4),daystates) > end for > > -- Set the return value > poke4(lParam+32,day_statesx) > > return kReturnNow > end function > void = setNotifyHandler(MCN_GETDAYSTATE, routine_id("CalendarCC_onDayState")) > </eucode> {{{ > > Note that this routine doesn't set any dates to bold, it just handles the > notification. You could, for example, set the 2nd day of the 2nd month > to bold by inserting after the call to getDayStates(): > > wrk_states[2][2] = 1 > > The getDayStateSeq is a new routine in WIN32EXT.EW that I will upload to > the contributions page shortly. What it does is returns a sequence made > up of one sequence for every month displayed on a calendar control. > > > > > > --Cleanup routine: > > > procedure Cleanup() > > > free(pDSs) > > > end procedure > > > > Call this on close app, or some other time too? > > In my example I free/allocate the memory each time. Why? Well, you > shouldn't assume that the first allocation of memory is sufficient to > subsequent number of months. Although looking at the calendar control, > it appears that there is always 3 months displayed, even if the first > of the month starts on a Sunday. It starts the month on the second line > under this condition. So you could even hard code 3 as the number of > cdayStates to allocate (3*4=12). > > So in my example, you would really need to free() the memory at the end > of your prog, like on an onClose event. > > > > > I'll have other questions, but maybe not for a couple of days. However, if > > either/both of you had the time to make a full (Win32Lib) demo, I'm guessing > > Derek would probably include it as a demo with Win32Lib, which would help > > anyone else who wanted to use this aspect of MonthCalendar, as well as me. > > > > If I find the time, I am actually going to use this technique in my > timesheet program (available in the archives). I'd like to show the user > when they're selecting a from/to date the other from/to date that has > been selected. That is, if it's in the visible month. > > Jonas Temple > http://www.yhti.net/~jktemple > Jonas, Experimenting with your code, I copied just a skeleton (below) of your "set day state" routine into a stub with the calendar control having the style "MCS_DAYSTATE" ; I did that in part because I couldn't find the function "getDayStateSeq", & I could get the skeleton to at least run. I have these questions/observations (sorry if I'm dense): 1. what kind of variable is "day_statesx", & should it be declared outside the routine? (is it atom, & yes, declare outside the routine?) 2. when I run the skeleton, some days *do* already show up in bold, sort of semi-randomly; as I change months, the same days are in bold for each month, unless I click on the "goto todays date thingy", but then changing months after that they go back to the original set of bold and not bold. (routine picking up random data from some internally defined structure location??) 3. but where is the structure that is being "interrogated" by the routine (or, if more accurate to say, "pointer to structure passed in lParam"?), and where/how is it filled?? (maybe I'm totally confused about that; I know I have to have some "outside" list of days to set up so the routine can know them, so as to them make them bold) 4. and I don't understand "wrk_states"; you say I could for instance set 2nd day of 2nd month as follows: > wrk_states[2][2] = 1 but that's a two-level sequence, and you seem to be treating it as a one level sequence earlier, >bits_to_int(wrk_states[i+1]) here's the "skeleton" of your code that I ran just to have something to experiment with: -- Set day state function CalendarCC_onDayState(integer id, atom hWnd, atom wParam, atom lParam) atom hwndFrom, idFrom, code, cDayState, daystates, year, month, dayofweek, day, hour, minute, second, millisecond sequence wrk_states -- Get the structure data hwndFrom = peek4u(lParam) idFrom = peek4u(lParam+4) code = peek4u(lParam+8) year = peek2u(lParam+12) month = peek2u(lParam+14) dayofweek = peek2u(lParam+16) day = peek2u(lParam+18) hour = peek2u(lParam+20) minute = peek2u(lParam+22) second = peek2u(lParam+24) millisecond = peek2u(lParam+26) cDayState = peek4u(lParam+28) puts(1, "got into day state routine!\n") return kReturnNow end function void = setNotifyHandler(MCN_GETDAYSTATE, routine_id("CalendarCC_onDayState")) Dan Moyer (still confused, but still trying)
13. Re: Month Calendar control: make dates bold?
- Posted by Al Getz <Xaxo at aol.com> Feb 26, 2005
- 445 views
Hi again Dan, I've downloaded the newest WinLib now so i can take a look at the new way of 'handling' events. Plenty of demos, which is nice You never responded as to how you like the idea of putting the dates to be set as bold into sequences with the handler taking care of updating the monthcal as required... Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's"
14. Re: Month Calendar control: make dates bold?
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Feb 26, 2005
- 448 views
> posted by: Al Getz <Xaxo at aol.com> > > Hi again Dan, > > I've downloaded the newest WinLib now so i can take a look at the > new way of 'handling' events. Plenty of demos, which is nice > > You never responded as to how you like the idea of putting the > dates to be set as bold into sequences with the handler taking > care of updating the monthcal as required... > > Take care, > Al > Al, As well as I understand the MC control (which isn't too well!), your idea would be the way I would think to do it, I'm just not sure how "transfer" that data to the routine that handles the MCN_GETDAYSTATE notification. And thanks for all the info previously sent, every little bit (may!) help :) Dan