Hi,

> I need to be able to set and read the minutes and seconds for a date time
> control, but from the XS code it looks like this is not possible (!?).

    Yes, Win32::GUI::DateTime by default only work with date.
    You can turn it to a time control by adding DTS_TIMEFORMAT (0x0009)
style.

> Could sending messages to the control work? I’ve tried it, but didn’t get
> anywhere fast…

    Yes, you can but you need to use a Win32::API because
Win32::GUI::SendMessage handle LPARAM as a numeric value.
    See Attached file, for a sample. With last Win32::API, you can use
Win32::API::Struct instead pack/unpack.

> But…I’ve never built win::gui from scratch, nor played with XS. I must
admit
> that I am daunted at the prospect! I am desperate, so am willing to go
> through the learning curve and would be grateful for any pointers to where
I
> should start.

    If you want build Win32::GUI from scratch.
    You must have Visual C++ 6.
    I'm not 100% sure but with ActiveState you need a specific service pack
depending perl version.
        - for ActivePerl 5.6 and 5.8 => SP6
        - for ActivePerl 5.005       => SP4

    I suppose you have VC and perl in your path and all is working ok.

    1) Open a dos/cmd sonsole
    2) Go to Bin directory of your Visual C++, and run VCVARS32.bat.
    3) Go to Win32::GUI directory.
        perl MakeFile.pl              <-- make a makefile for build
Win32::GUI
        nmake                         <-- build Win32::GUI
        nmake install                 <-- install Win32::GUI in perl
directory.

    If all Work, you can modify GUI.XS and rebuild (nmake) and install
(nmake install).
    For learn XS programming, take a look to perlxs documentation.
    You have perlxstut for build a xs from scratch.

    Call simple function is not very difficult if you have some C knowlege.
    You can look to GUI.xs for different code samples

    See below for what you can do for set and get date&time information.
    (I have not test this code but i think it's ok)

Laurent.


###########################################################################
# (@)METHOD:GetDateTime()
# (preliminary) Returns the date and time in the DateTime control in a three
# elements array (year, month, day, dayofweek, hour, minute, second,
millisecond).

void
GetDateTime(handle)
     HWND handle
PREINIT:
     SYSTEMTIME st;
PPCODE:
 if(DateTime_GetSystemtime(handle, &st) == GDT_VALID) {
         EXTEND(SP, 8)
         XST_mIV(0, st.wYear);
         XST_mIV(1, st.wMonth);
         XST_mIV(2, st.wDay);
         XST_mIV(3, st.wDayOfWeek);
         XST_mIV(4, st.wHour);
         XST_mIV(5, st.wMinute);
         XST_mIV(6, st.wSecond);
         XST_mIV(7, st.wMilliseconds);
         XSRETURN(8);
     } else {
         XSRETURN_UNDEF;
     }

###########################################################################
# (@)METHOD:SetDateTime(YEAR,MOn, DAY, HOUR, MIN, SEC, [MSEC=0])
# (preliminary) Sets the date in the DateTime control
BOOL
SetDateTime(handle, year, mon, day, hour, min, sec, msec=0)
     HWND handle
     int year
     int mon
     int day
     int hour
     int min
     int sec
     int msec
PREINIT:
     SYSTEMTIME st;
CODE:
 ZeroMemory(&st, sizeof(SYSTEMTIME));
 st.wYear   = year;
 st.wDay    = day;
 st.wMonth  = mon;
 st.wHour   = hour;
 st.wMinute = min;
 st.wSecond = sec;
 st.wMilliseconds = msec;

 RETVAL = DateTime_SetSystemtime(handle, GDT_VALID, &st);
OUTPUT:
  RETVAL
##############################

<<attachment: DateTime.zip>>

Reply via email to