Month Calendar BOLD days: Success!

new topic     » topic index » view thread      » older message » newer message

Well, thanks Jonas & Al!  :)

I think I answered my own questions, mostly.

By cutting & pasting from your example code, & looking at your explanations,
& trying whatever I could think of that might work, I (finally) got the
Month Calendar control to work for setting BOLD days:
1.  it sets all odd days BOLD (as a test),
2.  shows those bold days on "entry"  (well, it "flashes" original
(sometimes?) before it shows odd days bold)

What I did follows; if anyone sees any "bad things" with it, (like, "you
shouldn't do that here, do it there instead", etc), I'd appreciate having it
(them) pointed out, and any other useful comments, too.   :)

Dan Moyer
<code follows>
-------------------------------------------------------
--  code generated by Win32Lib IDE v0.18.9e


include Win32Lib.ew
without warning

----------------------------------------------------------------------------
----
--  Window Window1
constant Window1 = createEx( Window, "Window1", 0, Default, Default, 400,
300, 0, 0 )
constant MonthCalendar2 = createEx( MonthCalendar, "MonthCalendar2",
Window1, 108, 56, 248, 200, or_all({MCS_DAYSTATE}), 0 )
---------------------------------------------------------
----------------------------------------------------------------------------
----
include Words.e

object void

atom day_statesx
day_statesx  = allocate(31*4*3)  -- 31 days per month, 3 months, 4 bits per
day?
----------------------------------------------------------------------------
----
procedure Window1_onClose (integer self, integer event, sequence
params)--params is ()
  free(day_statesx)
end procedure
setHandler( Window1, w32HClose, routine_id("Window1_onClose"))
----------------------------------------------------------------------------
----
-- this makes the calendar show bold days just after the app opens:
procedure Window1_onActivate (integer self, integer event, sequence params)
--params is ()
object dummy
sequence wrk_states
atom daystates

wrk_states= {{},{},{}}
-- make a test sequence to set the dates, every odd day bold:
for m = 1 to 3 do
  for n = 1 to 31 do
    if remainder(n*3,2) then
       wrk_states[m] &= 1
    else
       wrk_states[m] &= 0
    end if
  end for
end for

-- Now convert the sequences to atoms and poke into memory
for i = 0 to 3 -1 do --cDayState-1 do
   daystates = bits_to_int(wrk_states[i+1])
   poke4(day_statesx+(i*4),daystates)
end for

   dummy = sendMessage(MonthCalendar2, MCM_SETDAYSTATE, 3, day_statesx)


end procedure
setHandler( Window1, w32HActivate, routine_id("Window1_onActivate"))
----------------------------------------------------------------------------
----
-- hopefully a routine to make some test days bold:

-- 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
integer dummy

-- 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,  "day state routine!\n")

wrk_states= {{},{},{}}
-- make a test sequence to set the dates, every odd day bold:
for m = 1 to 3 do
  for n = 1 to 31 do
    if remainder(n*3,2) then
       wrk_states[m] &= 1
    else
       wrk_states[m] &= 0
    end if
  end for

end for

-- Now convert the sequences to atoms and poke into memory
for i = 0 to 3 -1 do --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"))
----------------------------------------------------------------------------
----
procedure MonthCalendar2_onChange (integer self, integer event, sequence
params)--params is ()
  puts(1, "in: onChange routine\n")
end procedure
setHandler( MonthCalendar2, w32HChange,
routine_id("MonthCalendar2_onChange"))


WinMain( Window1,Normal )


new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu