Glenn,

Below are two new methods (GetDateTime and SetDateTime) for the datetime control. They allow the setting and reading of the time component. I've also included a simple example. I'll update the online documentation when you have released the new build.

I tried to find the fix for the splitter control but couldn't find any code, although found this mail from Trevor Garside:

Splitter Auto-Size
I made some changes to the Splitter code to make it to auto-resize as it is being dragged. If you are interested in it, I can send it. This was the first bit of code I edited, and at that point I had no idea how XS worked. Now that I am more familiar with it,
I want to re-code it and make it a switch-enabled option.

I've emailed him to see if he is prepaired to send the code to this list.

Cheers,

jez.

###########################################################################
# (@)METHOD:GetDateTime()
# (preliminary) Returns the date and time in the DateTime control in a eight
# elements array (year, month, day, dayofweek, hour, minute, second, millisecond).
# Based on code from Laurent Rocher
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 time in the DateTime control
# Based on code from Laurent Rocher
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
###############################

An example using the new methods:

use strict;
use Win32::GUI;

# main Window
my $Window = new Win32::GUI::Window (
   -name     => "Window",
   -title    => "Test",
   -pos      => [100, 100],
   -size     => [400, 400],
) or die "new Window";

# Date time control
my $DateTime = new Win32::GUI::DateTime (
   -parent   => $Window,
   -name     => "DateTime",
   -pos      => [10, 10],
   -size     => [180, 20],
);

$DateTime->Format('dd-MMM-yyyy HH:mm:ss');

# Test Buttons
my $Button = $Window->AddButton  (
   -name     => "Gettime",
   -text     => "Get the time",
   -pos      => [100, 100],
   -size     => [100, 100],
);

my $Button1 = $Window->AddButton  (
   -name     => "Settime",
   -text     => "Set the time",
   -pos      => [205, 100],
   -size     => [100, 100],
);

# Event loop
$Window->Show();
Win32::GUI::Dialog();

# Main window event handler
sub Window_Terminate {
return -1;
}

# Button events
sub Gettime_Click {
my ($mday, $mon, $year, undef, $hour, $min,$sec) = $DateTime->GetDateTime();
print "Year $year Month $mon Day $mday Hour $hour Min $min Sec $sec \n";

}
sub Settime_Click {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 $year += 1900;
 $DateTime->SetDateTime($year, $mon, $mday, $hour,$min, $sec);
}

_________________________________________________________________
On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile


Reply via email to