/*
 * This file was generated automatically by ExtUtils::ParseXS version 3.51 from the
 * contents of MonthCal.xs. Do not edit this file, edit MonthCal.xs instead.
 *
 *    ANY CHANGES MADE HERE WILL BE LOST!
 *
 */

#line 1 "MonthCal.xs"
    /*
    ###########################################################################
    # (@)PACKAGE:Win32::GUI::MonthCal
    #
    # $Id: MonthCal.xs,v 1.2 2006/06/23 18:35:33 robertemay Exp $
    #
    ###########################################################################
    */

#include "GUI.h"


void 
MonthCal_onPreCreate(NOTXSPROC LPPERLWIN32GUI_CREATESTRUCT perlcs) {

    perlcs->cs.lpszClass = MONTHCAL_CLASS;
    perlcs->cs.style = WS_CHILD | WS_VISIBLE;
}

BOOL
MonthCal_onParseOption(NOTXSPROC char *option, SV* value, LPPERLWIN32GUI_CREATESTRUCT perlcs) {

    BOOL retval = TRUE;

           if BitmaskOptionValue("-daystate",      perlcs->cs.style, MCS_DAYSTATE)
    } else if BitmaskOptionValue("-multiselect",   perlcs->cs.style, MCS_MULTISELECT )
    } else if BitmaskOptionValue("-notoday",       perlcs->cs.style, MCS_NOTODAY )
    } else if BitmaskOptionValue("-notodaycircle", perlcs->cs.style, MCS_NOTODAYCIRCLE )
    } else if BitmaskOptionValue("-weeknumber",    perlcs->cs.style, MCS_WEEKNUMBERS )
    } else retval = FALSE;

    return retval;
}

void
MonthCal_onPostCreate(NOTXSPROC HWND myhandle, LPPERLWIN32GUI_CREATESTRUCT perlcs) {

    if(perlcs->clrBackground != CLR_INVALID) {
        MonthCal_SetColor(myhandle, MCSC_BACKGROUND, perlcs->clrBackground);
        perlcs->clrBackground = CLR_INVALID;  // Don't store  
    }
    if(perlcs->clrForeground != CLR_INVALID) {
        MonthCal_SetColor(myhandle, MCSC_TEXT, perlcs->clrForeground);
        perlcs->clrForeground = CLR_INVALID;  // Don't store  
    }
}

BOOL
MonthCal_onParseEvent(NOTXSPROC char *name, int* eventID) {

    BOOL retval = TRUE;

         if Parse_Event("SelChange",   PERLWIN32GUI_NEM_CONTROL1)
    else if Parse_Event("Select",      PERLWIN32GUI_NEM_CONTROL2)
    else if Parse_Event("DayState",    PERLWIN32GUI_NEM_CONTROL3)
    else retval = FALSE;

    return retval;
}

int
MonthCal_onEvent (NOTXSPROC LPPERLWIN32GUI_USERDATA perlud, UINT uMsg, WPARAM wParam, LPARAM lParam) {

    int PerlResult = 1;

    if ( uMsg == WM_NOTIFY ) {

        LPNMSELCHANGE sel = (LPNMSELCHANGE) lParam;
        switch(sel->nmhdr.code) {

        case MCN_SELCHANGE:
            /*
             * (@)EVENT:SelChange(YEARMIN,MONTMIN,DAYMIN,YEARMAX,MONTMAX,DAYMAX)
             * Sent by a month calendar control when the currently selected date or range of dates changes.
             * (@)APPLIES_TO:MonthCal
             */
            PerlResult = DoEvent(NOTXSCALL perlud, PERLWIN32GUI_NEM_CONTROL1, "SelChange",
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelStart.wYear,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelStart.wMonth,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelStart.wDay,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelEnd.wYear,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelEnd.wMonth,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelEnd.wDay,
                                 -1 );
            break;

        case MCN_SELECT:
            /*
             * (@)EVENT:Select(YEARMIN,MONTMIN,DAYMIN,YEARMAX,MONTMAX,DAYMAX)
             * Sent by a month calendar control when the user makes an explicit date selection within a month calendar control.
             * (@)APPLIES_TO:MonthCal
             */
            PerlResult = DoEvent(NOTXSCALL perlud, PERLWIN32GUI_NEM_CONTROL2, "Select",
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelStart.wYear,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelStart.wMonth,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelStart.wDay,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelEnd.wYear,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelEnd.wMonth,
                                 PERLWIN32GUI_ARGTYPE_INT, sel->stSelEnd.wDay,
                                 -1 );
            break;

        case MCN_GETDAYSTATE:
            /*
             * (@)EVENT:DayState(YEAR,MONTH,DAY,MAXMONTH,MONTHDAYSTATELIST)
             * Sent by a month calendar control to request information about how individual days should be displayed.
             *
             * MONTHDAYSTATELIST is array reference.
             * Each MONTHDAYSTATELIST items are an MONTHDAYSTATE.
             * The MONTHDAYSTATE type is a bit field, where each bit (1 through 31) 
             * represents the state of a day in a month. If a bit is on, the corresponding
             * day will be displayed in bold; otherwise it will be displayed with no emphasis.
             * (@)APPLIES_TO:MonthCal
             */
            {
                #define lpnmDS ((NMDAYSTATE *)lParam)

                AV* av = newAV();
                av_fill(av, lpnmDS->cDayState); 

                MONTHDAYSTATE mds[12];
                ZeroMemory(mds, sizeof(MONTHDAYSTATE) * 12);
                lpnmDS->prgDayState = mds;

                PerlResult = DoEvent(NOTXSCALL perlud, PERLWIN32GUI_NEM_CONTROL3, "DayState",
                                     PERLWIN32GUI_ARGTYPE_INT, lpnmDS->stStart.wYear,
                                     PERLWIN32GUI_ARGTYPE_INT, lpnmDS->stStart.wMonth,
                                     PERLWIN32GUI_ARGTYPE_INT, lpnmDS->stStart.wDay,
                                     PERLWIN32GUI_ARGTYPE_INT, lpnmDS->cDayState,
                                     PERLWIN32GUI_ARGTYPE_SV,  sv_2mortal(newRV((SV*) av)),
                                     -1 );            

                for (int i = 0; i < av_len(av); i++) {
                    SV** sv = av_fetch(av, i, 0);
                    if (sv && SvIOK(*sv))
                        lpnmDS->prgDayState[i] = SvIV(*sv);
                }
                SvREFCNT_dec(av);
            }
            break;
        }
    }

    return PerlResult;
}



#line 159 "MonthCal.c"
#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#endif

#ifndef dVAR
#  define dVAR		dNOOP
#endif


/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
#  define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
#  define PERL_DECIMAL_VERSION \
	  PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
#  define PERL_VERSION_GE(r,v,s) \
	  (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
#  define PERL_VERSION_LE(r,v,s) \
	  (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif

/* XS_INTERNAL is the explicit static-linkage variant of the default
 * XS macro.
 *
 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
 * "STATIC", ie. it exports XSUB symbols. You probably don't want that
 * for anything but the BOOT XSUB.
 *
 * See XSUB.h in core!
 */


/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
#  undef XS_EXTERNAL
#  undef XS_INTERNAL
#  if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
#    define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
#    define XS_INTERNAL(name) STATIC XSPROTO(name)
#  endif
#  if defined(__SYMBIAN32__)
#    define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
#    define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
#  endif
#  ifndef XS_EXTERNAL
#    if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
#      define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
#      define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
#    else
#      ifdef __cplusplus
#        define XS_EXTERNAL(name) extern "C" XSPROTO(name)
#        define XS_INTERNAL(name) static XSPROTO(name)
#      else
#        define XS_EXTERNAL(name) XSPROTO(name)
#        define XS_INTERNAL(name) STATIC XSPROTO(name)
#      endif
#    endif
#  endif
#endif

/* perl >= 5.10.0 && perl <= 5.15.1 */


/* The XS_EXTERNAL macro is used for functions that must not be static
 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
 * macro defined, the best we can do is assume XS is the same.
 * Dito for XS_INTERNAL.
 */
#ifndef XS_EXTERNAL
#  define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
#  define XS_INTERNAL(name) XS(name)
#endif

/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
 * internal macro that we're free to redefine for varying linkage due
 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
 */

#undef XS_EUPXS
#if defined(PERL_EUPXS_ALWAYS_EXPORT)
#  define XS_EUPXS(name) XS_EXTERNAL(name)
#else
   /* default to internal */
#  define XS_EUPXS(name) XS_INTERNAL(name)
#endif

#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)

/* prototype to pass -Wmissing-prototypes */
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params);

STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params)
{
    const GV *const gv = CvGV(cv);

    PERL_ARGS_ASSERT_CROAK_XS_USAGE;

    if (gv) {
        const char *const gvname = GvNAME(gv);
        const HV *const stash = GvSTASH(gv);
        const char *const hvname = stash ? HvNAME(stash) : NULL;

        if (hvname)
	    Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
        else
	    Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
    } else {
        /* Pants. I don't think that it should be possible to get here. */
	Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
    }
}
#undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE

#define croak_xs_usage        S_croak_xs_usage

#endif

/* NOTE: the prototype of newXSproto() is different in versions of perls,
 * so we define a portable version of newXSproto()
 */
#ifdef newXS_flags
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
#else
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
#endif /* !defined(newXS_flags) */

#if PERL_VERSION_LE(5, 21, 5)
#  define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
#else
#  define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
#endif

#line 303 "MonthCal.c"
#pragma message( "*** PACKAGE Win32::GUI::MonthCal..." )

XS_EUPXS(XS_Win32__GUI__MonthCal_GetColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetColor)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, iColor");
    {
	HWND	handle;
	int	iColor = (int)SvIV(ST(1))
;
	COLORREF	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 172 "MonthCal.xs"
    RETVAL = MonthCal_GetColor(handle, iColor);
#line 330 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV) RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetCurSel); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetCurSel)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
#line 184 "MonthCal.xs"
    SYSTEMTIME st;
#line 350 "MonthCal.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 186 "MonthCal.xs"
    if(MonthCal_GetCurSel(handle, &st)) {
        EXTEND(SP, 4);
        XST_mIV(0, st.wYear);
        XST_mIV(1, st.wMonth);
        XST_mIV(2, st.wDay);
        XST_mIV(3, st.wDayOfWeek);
        XSRETURN(4);
    } else {
        XSRETURN_UNDEF;
    }
#line 372 "MonthCal.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetFirstDayOfWeek); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetFirstDayOfWeek)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
	DWORD	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 204 "MonthCal.xs"
    RETVAL = MonthCal_GetFirstDayOfWeek(handle);
#line 401 "MonthCal.c"
	XSprePUSH;
	PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetMaxSelCount); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetMaxSelCount)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
	DWORD	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 215 "MonthCal.xs"
    RETVAL =  MonthCal_GetMaxSelCount(handle);
#line 431 "MonthCal.c"
	XSprePUSH;
	PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetMaxTodayWidth); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetMaxTodayWidth)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
	DWORD	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 226 "MonthCal.xs"
    RETVAL =  MonthCal_GetMaxTodayWidth(handle);
#line 461 "MonthCal.c"
	XSprePUSH;
	PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetMinReqRect); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetMinReqRect)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
#line 237 "MonthCal.xs"
    RECT myRect;
#line 481 "MonthCal.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 239 "MonthCal.xs"
    if(MonthCal_GetMinReqRect(handle, &myRect)) {
        EXTEND(SP, 4);
        XST_mIV(0, myRect.left);
        XST_mIV(1, myRect.top);
        XST_mIV(2, myRect.right);
        XST_mIV(3, myRect.bottom);
        XSRETURN(4);
    } else {
        XSRETURN_UNDEF;
    }
#line 503 "MonthCal.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetMonthDelta); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetMonthDelta)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
	int	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 259 "MonthCal.xs"
    RETVAL =  MonthCal_GetMonthDelta(handle);
#line 532 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetMonthRange); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetMonthRange)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "handle, flag=GMR_DAYSTATE");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
	DWORD	flag;
#line 273 "MonthCal.xs"
    SYSTEMTIME st[2];
#line 553 "MonthCal.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;

	if (items < 2)
	    flag = GMR_DAYSTATE;
	else {
	    flag = (DWORD)SvUV(ST(1))
;
	}
#line 275 "MonthCal.xs"
    MonthCal_GetMonthRange(handle, flag, &st);
    EXTEND(SP, 8);
    XST_mIV(0, st[0].wYear);
    XST_mIV(1, st[0].wMonth);
    XST_mIV(2, st[0].wDay);
    XST_mIV(3, st[0].wDayOfWeek);
    XST_mIV(4, st[1].wYear);
    XST_mIV(5, st[1].wMonth);
    XST_mIV(6, st[1].wDay);
    XST_mIV(7, st[1].wDayOfWeek);
    XSRETURN(8);
#line 583 "MonthCal.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetRange); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetRange)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
#line 294 "MonthCal.xs"
    SYSTEMTIME st[2];
    DWORD ret;
#line 603 "MonthCal.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 297 "MonthCal.xs"
    ret = MonthCal_GetRange(handle, &st);
    if (GIMME == G_ARRAY) {
        EXTEND(SP, 8);
        XST_mIV(0, st[0].wYear);
        XST_mIV(1, st[0].wMonth);
        XST_mIV(2, st[0].wDay);
        XST_mIV(3, st[0].wDayOfWeek);
        XST_mIV(4, st[1].wYear);
        XST_mIV(5, st[1].wMonth);
        XST_mIV(6, st[1].wDay);
        XST_mIV(7, st[1].wDayOfWeek);
        XSRETURN(8);
    } else {
        EXTEND(SP, 1);
        XST_mIV(0, ret);
        XSRETURN(1);
    }
#line 632 "MonthCal.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetSelRange); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetSelRange)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
#line 324 "MonthCal.xs"
    SYSTEMTIME st[2];
#line 651 "MonthCal.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 326 "MonthCal.xs"
    if (MonthCal_GetSelRange(handle, &st) ) {
        EXTEND(SP, 8);
        XST_mIV(0, st[0].wYear);
        XST_mIV(1, st[0].wMonth);
        XST_mIV(2, st[0].wDay);
        XST_mIV(3, st[0].wDayOfWeek);
        XST_mIV(4, st[1].wYear);
        XST_mIV(5, st[1].wMonth);
        XST_mIV(6, st[1].wDay);
        XST_mIV(7, st[1].wDayOfWeek);
        XSRETURN(8);
    } else {
        XSRETURN_UNDEF;
    }
#line 677 "MonthCal.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetToday); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetToday)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
#line 349 "MonthCal.xs"
    SYSTEMTIME st;
#line 696 "MonthCal.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 351 "MonthCal.xs"
    if(MonthCal_GetToday(handle, &st)) {
        EXTEND(SP, 4);
        XST_mIV(0, st.wYear);
        XST_mIV(1, st.wMonth);
        XST_mIV(2, st.wDay);
        XST_mIV(3, st.wDayOfWeek);
        XSRETURN(4);
    } else {
        XSRETURN_UNDEF;
    }
#line 718 "MonthCal.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetUnicodeFormat); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetUnicodeFormat)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    {
	HWND	handle;
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 369 "MonthCal.xs"
    RETVAL =  MonthCal_GetUnicodeFormat(handle);
#line 747 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_HitTest); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_HitTest)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "handle, x, y");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
	int	x = (int)SvIV(ST(1))
;
	int	y = (int)SvIV(ST(2))
;
#line 382 "MonthCal.xs"
    MCHITTESTINFO ht;
    DWORD flag;
#line 772 "MonthCal.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 385 "MonthCal.xs"
    ZeroMemory(&ht, sizeof(MCHITTESTINFO));
    ht.cbSize = sizeof(MCHITTESTINFO);
    ht.pt.x = x;
    ht.pt.y = y;
    flag = MonthCal_HitTest(handle, &ht);

    if(GIMME == G_ARRAY) {
        EXTEND(SP, 10);
        XST_mPV(0, "-flag");
        XST_mIV(1, flag);
        XST_mPV(2, "-year");
        XST_mIV(3, ht.st.wYear);
        XST_mPV(4, "-month");
        XST_mIV(5, ht.st.wMonth);
        XST_mPV(6, "-day");
        XST_mIV(7, ht.st.wDay);
        XST_mPV(8, "-dayofweek");
        XST_mIV(9, ht.st.wDayOfWeek);
        XSRETURN(10);
    } else {
        EXTEND(SP, 1);
        XST_mIV(0, flag);
        XSRETURN(1);
    }
#line 808 "MonthCal.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetColor)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "handle, iColor, Color");
    {
	HWND	handle;
	int	iColor = (int)SvIV(ST(1))
;
	COLORREF    Color = SvCOLORREF(NOTXSCALL ST(2))
;
	COLORREF	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 428 "MonthCal.xs"
    RETVAL = MonthCal_SetColor(handle, iColor, Color);
#line 841 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV) RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetCurSel); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetCurSel)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "handle, year, mon, day");
    {
	HWND	handle;
	int	year = (int)SvIV(ST(1))
;
	int	mon = (int)SvIV(ST(2))
;
	int	day = (int)SvIV(ST(3))
;
#line 442 "MonthCal.xs"
    SYSTEMTIME st;
#line 865 "MonthCal.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 444 "MonthCal.xs"
    ZeroMemory(&st, sizeof(SYSTEMTIME));
    st.wYear   = year;
    st.wDay    = day;
    st.wMonth  = mon;

    RETVAL = MonthCal_SetCurSel(handle, &st);
#line 885 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetDayState); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetDayState)
{
    dVAR; dXSARGS;
    if (items < 1)
       croak_xs_usage(cv,  "handle, ...");
    {
	HWND	handle;
#line 465 "MonthCal.xs"
    MONTHDAYSTATE mds[12];
    int iMax;
#line 904 "MonthCal.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 468 "MonthCal.xs"
    ZeroMemory(mds, sizeof(MONTHDAYSTATE)*12);    
    iMax = MonthCal_GetMonthRange(handle, GMR_DAYSTATE, NULL);

    if (items > 1) {
        for (int i = 1; i < iMax; i++) {
            if (i < items)
                mds[i-1] = (MONTHDAYSTATE) SvIV(ST(i));
            else
                mds[i-1] = (MONTHDAYSTATE) SvIV(ST(items-1));
        }
    }

    RETVAL = MonthCal_SetDayState(handle, iMax, mds);
#line 931 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetFirstDayOfWeek); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetFirstDayOfWeek)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, iDay");
    {
	HWND	handle;
	int	iDay = (int)SvIV(ST(1))
;
	DWORD	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 492 "MonthCal.xs"
    RETVAL = MonthCal_SetFirstDayOfWeek(handle, iDay);
#line 963 "MonthCal.c"
	XSprePUSH;
	PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetMaxSelCount); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetMaxSelCount)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, iMax");
    {
	HWND	handle;
	int	iMax = (int)SvIV(ST(1))
;
	DWORD	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 504 "MonthCal.xs"
    RETVAL =  MonthCal_SetMaxSelCount(handle, iMax);
#line 995 "MonthCal.c"
	XSprePUSH;
	PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetMonthDelta); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetMonthDelta)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, iDelta");
    {
	HWND	handle;
	int	iDelta = (int)SvIV(ST(1))
;
	DWORD	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 518 "MonthCal.xs"
    RETVAL =  MonthCal_SetMonthDelta(handle, iDelta);
#line 1027 "MonthCal.c"
	XSprePUSH;
	PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetRange); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetRange)
{
    dVAR; dXSARGS;
    if (items != 7)
       croak_xs_usage(cv,  "handle, yearmin, monmin, daymin, yearmax, monmax, daymax");
    {
	HWND	handle;
	int	yearmin = (int)SvIV(ST(1))
;
	int	monmin = (int)SvIV(ST(2))
;
	int	daymin = (int)SvIV(ST(3))
;
	int	yearmax = (int)SvIV(ST(4))
;
	int	monmax = (int)SvIV(ST(5))
;
	int	daymax = (int)SvIV(ST(6))
;
#line 535 "MonthCal.xs"
    SYSTEMTIME st[2];
#line 1057 "MonthCal.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 537 "MonthCal.xs"
    ZeroMemory(&st, sizeof(SYSTEMTIME) * 2);
    st[0].wYear   = yearmin;
    st[0].wDay    = daymin;
    st[0].wMonth  = monmin;
    st[1].wYear   = yearmax;
    st[1].wDay    = daymax;
    st[1].wMonth  = monmax;

    RETVAL = MonthCal_SetRange(handle, GDTR_MIN|GDTR_MAX, &st);
#line 1080 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetSelRange); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetSelRange)
{
    dVAR; dXSARGS;
    if (items != 7)
       croak_xs_usage(cv,  "handle, yearmin, monmin, daymin, yearmax, monmax, daymax");
    {
	HWND	handle;
	int	yearmin = (int)SvIV(ST(1))
;
	int	monmin = (int)SvIV(ST(2))
;
	int	daymin = (int)SvIV(ST(3))
;
	int	yearmax = (int)SvIV(ST(4))
;
	int	monmax = (int)SvIV(ST(5))
;
	int	daymax = (int)SvIV(ST(6))
;
#line 562 "MonthCal.xs"
    SYSTEMTIME st[2];
#line 1110 "MonthCal.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 564 "MonthCal.xs"
    ZeroMemory(&st, sizeof(SYSTEMTIME) * 2);
    st[0].wYear   = yearmin;
    st[0].wDay    = daymin;
    st[0].wMonth  = monmin;
    st[1].wYear   = yearmax;
    st[1].wDay    = daymax;
    st[1].wMonth  = monmax;

    RETVAL = MonthCal_SetSelRange(handle, &st);
#line 1133 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetToday); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetToday)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "handle, year, mon, day");
    {
	HWND	handle;
	int	year = (int)SvIV(ST(1))
;
	int	mon = (int)SvIV(ST(2))
;
	int	day = (int)SvIV(ST(3))
;
#line 586 "MonthCal.xs"
    SYSTEMTIME st;
#line 1157 "MonthCal.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 588 "MonthCal.xs"
    ZeroMemory(&st, sizeof(SYSTEMTIME));
    st.wYear   = year;
    st.wDay    = day;
    st.wMonth  = mon;

    RETVAL = MonthCal_SetToday(handle, &st);
#line 1177 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetUnicodeFormat); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetUnicodeFormat)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "handle, fUnicode");
    {
	HWND	handle;
	BOOL	fUnicode = (BOOL)SvIV(ST(1))
;
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 605 "MonthCal.xs"
    RETVAL =  MonthCal_SetUnicodeFormat(handle, fUnicode);
#line 1209 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_BackColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_BackColor)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "handle, color=(COLORREF) -1");
    {
	HWND	handle;
	COLORREF	color;
	COLORREF	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;

	if (items < 2)
	    color = (COLORREF) -1;
	else {
    color = SvCOLORREF(NOTXSCALL ST(1))
;
	}
#line 621 "MonthCal.xs"
    if(items == 2) {
        RETVAL = MonthCal_SetColor(handle, MCSC_BACKGROUND, color);
    } else
        RETVAL = MonthCal_GetColor(handle, MCSC_BACKGROUND);
#line 1250 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV) RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_BackMonthColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_BackMonthColor)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "handle, color=(COLORREF) -1");
    {
	HWND	handle;
	COLORREF	color;
	COLORREF	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;

	if (items < 2)
	    color = (COLORREF) -1;
	else {
    color = SvCOLORREF(NOTXSCALL ST(1))
;
	}
#line 636 "MonthCal.xs"
    if(items == 2) {
        RETVAL = MonthCal_SetColor(handle, MCSC_MONTHBK, color);
    } else
        RETVAL = MonthCal_GetColor(handle, MCSC_MONTHBK);
#line 1291 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV) RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_BackTitleColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_BackTitleColor)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "handle, color=(COLORREF) -1");
    {
	HWND	handle;
	COLORREF	color;
	COLORREF	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;

	if (items < 2)
	    color = (COLORREF) -1;
	else {
    color = SvCOLORREF(NOTXSCALL ST(1))
;
	}
#line 651 "MonthCal.xs"
    if(items == 2) {
        RETVAL = MonthCal_SetColor(handle, MCSC_TITLEBK, color);
    } else
        RETVAL = MonthCal_GetColor(handle, MCSC_TITLEBK);
#line 1332 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV) RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_TextColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_TextColor)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "handle, color=(COLORREF) -1");
    {
	HWND	handle;
	COLORREF	color;
	COLORREF	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;

	if (items < 2)
	    color = (COLORREF) -1;
	else {
    color = SvCOLORREF(NOTXSCALL ST(1))
;
	}
#line 666 "MonthCal.xs"
    if(items == 2) {
        RETVAL = MonthCal_SetColor(handle, MCSC_TEXT, color);
    } else
        RETVAL = MonthCal_GetColor(handle, MCSC_TEXT);
#line 1373 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV) RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_TitleTextColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_TitleTextColor)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "handle, color=(COLORREF) -1");
    {
	HWND	handle;
	COLORREF	color;
	COLORREF	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;

	if (items < 2)
	    color = (COLORREF) -1;
	else {
    color = SvCOLORREF(NOTXSCALL ST(1))
;
	}
#line 681 "MonthCal.xs"
    if(items == 2) {
        RETVAL = MonthCal_SetColor(handle, MCSC_TITLETEXT, color);
    } else
        RETVAL = MonthCal_GetColor(handle, MCSC_TITLETEXT);
#line 1414 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV) RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_TrailingTextColor); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_TrailingTextColor)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "handle, color=(COLORREF) -1");
    {
	HWND	handle;
	COLORREF	color;
	COLORREF	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;

	if (items < 2)
	    color = (COLORREF) -1;
	else {
    color = SvCOLORREF(NOTXSCALL ST(1))
;
	}
#line 698 "MonthCal.xs"
    if(items == 2) {
        RETVAL = MonthCal_SetColor(handle, MCSC_TRAILINGTEXT, color);
    } else
        RETVAL = MonthCal_GetColor(handle, MCSC_TRAILINGTEXT);
#line 1455 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV) RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetRangeMin); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetRangeMin)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
#line 712 "MonthCal.xs"
    SYSTEMTIME st[2];
    DWORD ret;
#line 1476 "MonthCal.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 715 "MonthCal.xs"
    ret = MonthCal_GetRange(handle, &st);
    if(GIMME == G_ARRAY) {
        if (ret & GDTR_MIN) {
            EXTEND(SP, 4);
            XST_mIV(0, st[0].wYear);
            XST_mIV(1, st[0].wMonth);
            XST_mIV(2, st[0].wDay);
            XST_mIV(3, st[0].wDayOfWeek);
            XSRETURN(4);
        }
        else {
            XSRETURN_UNDEF;
        }
    } else {
        EXTEND(SP, 1);
        XST_mIV(0, ret & GDTR_MIN);
        XSRETURN(1);
    }
#line 1506 "MonthCal.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__MonthCal_GetRangeMax); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_GetRangeMax)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "handle");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
	HWND	handle;
#line 741 "MonthCal.xs"
    SYSTEMTIME st[2];
    DWORD ret;
#line 1526 "MonthCal.c"

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 744 "MonthCal.xs"
    ret = MonthCal_GetRange(handle, &st);
    if(GIMME == G_ARRAY) {
        if (ret & GDTR_MAX) {
            EXTEND(SP, 4);
            XST_mIV(0, st[1].wYear);
            XST_mIV(1, st[1].wMonth);
            XST_mIV(2, st[1].wDay);
            XST_mIV(3, st[1].wDayOfWeek);
            XSRETURN(4);
        }
        else {
            XSRETURN_UNDEF;
        }
    } else {
        EXTEND(SP, 1);
        XST_mIV(0, ret & GDTR_MAX);
        XSRETURN(1);
    }
#line 1556 "MonthCal.c"
	PUTBACK;
	return;
    }
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetRangeMin); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetRangeMin)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "handle, yearmin, monmin, daymin");
    {
	HWND	handle;
	int	yearmin = (int)SvIV(ST(1))
;
	int	monmin = (int)SvIV(ST(2))
;
	int	daymin = (int)SvIV(ST(3))
;
#line 773 "MonthCal.xs"
    SYSTEMTIME st[2];
#line 1579 "MonthCal.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 775 "MonthCal.xs"
    ZeroMemory(&st, sizeof(SYSTEMTIME) * 2);
    st[0].wYear   = yearmin;
    st[0].wDay    = daymin;
    st[0].wMonth  = monmin;
    RETVAL = MonthCal_SetRange(handle, GDTR_MIN, &st);
#line 1598 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Win32__GUI__MonthCal_SetRangeMax); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Win32__GUI__MonthCal_SetRangeMax)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "handle, yearmax, monmax, daymax");
    {
	HWND	handle;
	int	yearmax = (int)SvIV(ST(1))
;
	int	monmax = (int)SvIV(ST(2))
;
	int	daymax = (int)SvIV(ST(3))
;
#line 793 "MonthCal.xs"
    SYSTEMTIME st[2];
#line 1622 "MonthCal.c"
	BOOL	RETVAL;
	dXSTARG;

    if(SvROK(ST(0))) {
        SV** out=hv_fetch((HV*)SvRV(ST(0)), "-handle", 7, 0);
        if(out != NULL)
            handle = INT2PTR(HWND,SvIV(*out));
        else
            handle = NULL;
    } else
       handle = INT2PTR(HWND,SvIV(ST(0)))
;
#line 795 "MonthCal.xs"
    ZeroMemory(&st, sizeof(SYSTEMTIME) * 2);
    st[1].wYear   = yearmax;
    st[1].wDay    = daymax;
    st[1].wMonth  = monmax;

    RETVAL = MonthCal_SetRange(handle, GDTR_MAX, &st);
#line 1642 "MonthCal.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#ifdef __cplusplus
extern "C" {
#endif
XS_EXTERNAL(boot_Win32__GUI__MonthCal); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Win32__GUI__MonthCal)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
    char* file = __FILE__;
#else
    const char* file = __FILE__;
#endif

    PERL_UNUSED_VAR(file);

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5)
    XS_VERSION_BOOTCHECK;
#  ifdef XS_APIVERSION_BOOTCHECK
    XS_APIVERSION_BOOTCHECK;
#  endif
#endif

        newXS_deffile("Win32::GUI::MonthCal::GetColor", XS_Win32__GUI__MonthCal_GetColor);
        newXS_deffile("Win32::GUI::MonthCal::GetCurSel", XS_Win32__GUI__MonthCal_GetCurSel);
        newXS_deffile("Win32::GUI::MonthCal::GetFirstDayOfWeek", XS_Win32__GUI__MonthCal_GetFirstDayOfWeek);
        newXS_deffile("Win32::GUI::MonthCal::GetMaxSelCount", XS_Win32__GUI__MonthCal_GetMaxSelCount);
        newXS_deffile("Win32::GUI::MonthCal::GetMaxTodayWidth", XS_Win32__GUI__MonthCal_GetMaxTodayWidth);
        newXS_deffile("Win32::GUI::MonthCal::GetMinReqRect", XS_Win32__GUI__MonthCal_GetMinReqRect);
        newXS_deffile("Win32::GUI::MonthCal::GetMonthDelta", XS_Win32__GUI__MonthCal_GetMonthDelta);
        newXS_deffile("Win32::GUI::MonthCal::GetMonthRange", XS_Win32__GUI__MonthCal_GetMonthRange);
        newXS_deffile("Win32::GUI::MonthCal::GetRange", XS_Win32__GUI__MonthCal_GetRange);
        newXS_deffile("Win32::GUI::MonthCal::GetSelRange", XS_Win32__GUI__MonthCal_GetSelRange);
        newXS_deffile("Win32::GUI::MonthCal::GetToday", XS_Win32__GUI__MonthCal_GetToday);
        newXS_deffile("Win32::GUI::MonthCal::GetUnicodeFormat", XS_Win32__GUI__MonthCal_GetUnicodeFormat);
        newXS_deffile("Win32::GUI::MonthCal::HitTest", XS_Win32__GUI__MonthCal_HitTest);
        newXS_deffile("Win32::GUI::MonthCal::SetColor", XS_Win32__GUI__MonthCal_SetColor);
        newXS_deffile("Win32::GUI::MonthCal::SetCurSel", XS_Win32__GUI__MonthCal_SetCurSel);
        newXS_deffile("Win32::GUI::MonthCal::SetDayState", XS_Win32__GUI__MonthCal_SetDayState);
        newXS_deffile("Win32::GUI::MonthCal::SetFirstDayOfWeek", XS_Win32__GUI__MonthCal_SetFirstDayOfWeek);
        newXS_deffile("Win32::GUI::MonthCal::SetMaxSelCount", XS_Win32__GUI__MonthCal_SetMaxSelCount);
        newXS_deffile("Win32::GUI::MonthCal::SetMonthDelta", XS_Win32__GUI__MonthCal_SetMonthDelta);
        newXS_deffile("Win32::GUI::MonthCal::SetRange", XS_Win32__GUI__MonthCal_SetRange);
        newXS_deffile("Win32::GUI::MonthCal::SetSelRange", XS_Win32__GUI__MonthCal_SetSelRange);
        newXS_deffile("Win32::GUI::MonthCal::SetToday", XS_Win32__GUI__MonthCal_SetToday);
        newXS_deffile("Win32::GUI::MonthCal::SetUnicodeFormat", XS_Win32__GUI__MonthCal_SetUnicodeFormat);
        newXS_deffile("Win32::GUI::MonthCal::BackColor", XS_Win32__GUI__MonthCal_BackColor);
        newXS_deffile("Win32::GUI::MonthCal::BackMonthColor", XS_Win32__GUI__MonthCal_BackMonthColor);
        newXS_deffile("Win32::GUI::MonthCal::BackTitleColor", XS_Win32__GUI__MonthCal_BackTitleColor);
        newXS_deffile("Win32::GUI::MonthCal::TextColor", XS_Win32__GUI__MonthCal_TextColor);
        newXS_deffile("Win32::GUI::MonthCal::TitleTextColor", XS_Win32__GUI__MonthCal_TitleTextColor);
        newXS_deffile("Win32::GUI::MonthCal::TrailingTextColor", XS_Win32__GUI__MonthCal_TrailingTextColor);
        newXS_deffile("Win32::GUI::MonthCal::GetRangeMin", XS_Win32__GUI__MonthCal_GetRangeMin);
        newXS_deffile("Win32::GUI::MonthCal::GetRangeMax", XS_Win32__GUI__MonthCal_GetRangeMax);
        newXS_deffile("Win32::GUI::MonthCal::SetRangeMin", XS_Win32__GUI__MonthCal_SetRangeMin);
        newXS_deffile("Win32::GUI::MonthCal::SetRangeMax", XS_Win32__GUI__MonthCal_SetRangeMax);
#if PERL_VERSION_LE(5, 21, 5)
#  if PERL_VERSION_GE(5, 9, 0)
    if (PL_unitcheckav)
        call_list(PL_scopestack_ix, PL_unitcheckav);
#  endif
    XSRETURN_YES;
#else
    Perl_xs_boot_epilog(aTHX_ ax);
#endif
}

#ifdef __cplusplus
}
#endif
