From: Laurent R. <ro...@cl...> - 2003-10-20 18:10:49
|
Hi, > I need to be able to set and read the minutes and seconds for a date ti= me > 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=92ve tried it, but didn=92= t get > anywhere fast=85 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=85I=92ve never built win::gui from scratch, nor played with XS. I m= ust 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 wh= ere 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 pa= ck depending perl version. - for ActivePerl 5.6 and 5.8 =3D> SP6 - for ActivePerl 5.005 =3D> 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 knowled= ge. 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 th= ree # elements array (year, month, day, dayofweek, hour, minute, second, millisecond). void GetDateTime(handle) HWND handle PREINIT: SYSTEMTIME st; PPCODE: if(DateTime_GetSystemtime(handle, &st) =3D=3D 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=3D0]) # (preliminary) Sets the date in the DateTime control BOOL SetDateTime(handle, year, mon, day, hour, min, sec, msec=3D0) 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 =3D year; st.wDay =3D day; st.wMonth =3D mon; st.wHour =3D hour; st.wMinute =3D min; st.wSecond =3D sec; st.wMilliseconds =3D msec; RETVAL =3D DateTime_SetSystemtime(handle, GDT_VALID, &st); OUTPUT: RETVAL ############################## |