1. Month Calendar BOLD days: Success!

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 message » categorize

2. Re: Month Calendar BOLD days: Success!

Hi again dan,

I looked over your code and noticed a few problems.

The demo posted allows you to set various aspects of the months
already, such as every year, every month, and random days in any year, so
for a faster path to getting there copy and paste all the sequences
and the notify handler into your own application.  You'll have to change
the name of some of the control id's and whatever.  You'll also have
to copy and paste the code that scans the sequences that are set by
the user.
You'll notice the demo is simply a modification of the MonthCalendar
demo that came with the winlib lib.  Any code that appears there
will be the code that's required in your app too.



Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu