Importing Windows Control << Back



There are many native Windows controls that are not wrapped for VDF consumption. One of them is called the Date/Time picker Let's focus on the time portion of the Date/Time picker.

Use UI

Struct SYSTEMTIME
	UShort wYear
	UShort wMonth
	UShort wDayOfWeek
	UShort wDay
	UShort wHour
	UShort wMinute
	UShort wSecond
	UShort wMilliseconds
End_Struct // SYSTEMTIME

Define DTM_FIRST			For |CI$1000
Define DTS_TIMEFORMAT		For |CI$9
Define DTM_GETSYSTEMTIME	For (DTM_FIRST + 1)
Define DTM_SETSYSTEMTIME	For (DTM_FIRST + 2)
Define DTM_SETFORMAT		For (DTM_FIRST + 5)
Define GDT_VALID     		For 0

External_Function GetLocalTime "GetLocalTime" KERNEL32.DLL Address lpSystemTime Returns Integer

Class cTimePicker is a DfBaseControl
	Procedure Construct_Object
		Forward Send Construct_Object
		Set External_Class_Name "cTimePicker" to "SysDateTimePick32"
		Set Window_Style DTS_TIMEFORMAT to DTS_TIMEFORMAT
	End_Procedure // Construct_Object
	Procedure Page_Object Integer iPage
		String sFormat
		Forward Send Page_Object iPage
		Move "HH:mm" to sFormat
		Send Windows_Message DTM_SETFORMAT 0 (AddressOf(sFormat))
	end_Procedure // Page_Object
	Function TimeValue Returns Integer
		SYSTEMTIME timeValue
		Send Windows_Message DTM_GETSYSTEMTIME 0 (AddressOf(timeValue))
		Function_Return (timeValue.wHour * 100 + timeValue.wMinute)
	End_Function // TimeValue
	Procedure Set TimeValue Integer iTime
		SYSTEMTIME timeValue
		Move (GetLocalTime(AddressOf(timeValue))) to WindowIndex
		Move (iTime / 100) to timeValue.wHour
		Move (Mod(iTime, 100)) to timeValue.wMinute
		Send Windows_Message DTM_SETSYSTEMTIME GDT_VALID (AddressOf(timeValue))
	End_Procedure // TimeValue
End_Class // cTimePicker

The note-worthy part is the use of External_Class_Name and Window_Style to get the control up and running. The rest is to getting/setting value from/to the control. This is not meant to be a full-blown totally customizable user control. This example is to show you the minimal amount of VDF code in order to import a Windows control.






Free Web Hosting