RE: Win32lib: smaller monthcalendar

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

akusaya at gmx.net wrote:
> 
> 
> Is it possible to have a smaller monthcalendar? Because I see in some
> apllication it have smaller monthcalendar.
> 
> Thank you.
> 
> 
Yes, the trick is changing the font of the calendar.  Here is a code 
sample.

--begin code

include win32lib.ew
without warning

constant win = create(Window, "Win", 0, Center, Center, 600, 500, 0)

integer large_calendar_id
integer small_calendar_id

constant
	RECT_left   = allot(Long),
	RECT_top    = allot(Long),
	RECT_right  = allot(Long),
	RECT_bottom = allot(Long),
	SIZEOF_RECT = allotted_size(),
	RECT_STRUCT = allocate(SIZEOF_RECT)

procedure createCalendars(integer self, integer event, sequence parms)
	integer width, height

	large_calendar_id = create(MonthCalendar, "", win, 0, 0,
			0, 0, --resize it later
			0)

	setFont(large_calendar_id, "Arial", 18, Normal)

	if sendMessage(large_calendar_id, MCM_GETMINREQRECT, 0, RECT_STRUCT) = 
0 then
		abortErr("Error using MonthCal_GetMinReqRect!")
	end if

	width  = fetch(RECT_STRUCT, RECT_right ) - fetch(RECT_STRUCT, 
RECT_left)
	height = fetch(RECT_STRUCT, RECT_bottom) - fetch(RECT_STRUCT, RECT_top)

	setCtlSize(large_calendar_id, width, height)

	--small calendar

	small_calendar_id = create(MonthCalendar, "", win, 400, 0,
			0, 0, --resize it later
			0)

	setFont(small_calendar_id, "Arial", 5, Normal)

	if sendMessage(small_calendar_id, MCM_GETMINREQRECT, 0, RECT_STRUCT) = 
0 then
		abortErr("Error using MonthCal_GetMinReqRect!")
	end if

	width  = fetch(RECT_STRUCT, RECT_right ) - fetch(RECT_STRUCT, 
RECT_left)
	height = fetch(RECT_STRUCT, RECT_bottom) - fetch(RECT_STRUCT, RECT_top)

	setCtlSize(small_calendar_id, width, height)
end procedure
setHandler(win, w32HActivate, routine_id("createCalendars"))

WinMain(win, Normal)

--end code

Also, you might be interested in this note included in Microsoft's 
Platform SDK Documentation:

The rectangle returned by MCM_GETMINREQRECT does not include the width 
of the "Today" string, if it is present. If the MCS_NOTODAY style is not 
set, your application should also retrieve the rectangle that defines 
the "Today" string width by sending a MCM_GETMAXTODAYWIDTH message. Use 
the larger of the two rectangles to ensure that the "Today" string is 
not clipped.

Hope this helps,

Phil
http://www16.brinkster.com/philip1987

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

Search



Quick Links

User menu

Not signed in.

Misc Menu