?? nvo_comctl_datetime.sru
字號:
$PBExportHeader$nvo_comctl_datetime.sru
$PBExportComments$不可視對象,用來控制下拉式時間控件
forward
global type nvo_comctl_datetime from nonvisualobject
end type
end forward
type systemtime from structure
uint wyear
uint wmonth
uint wdayofweek
uint wday
uint whour
uint wminute
uint wsecond
uint wmilliseconds
end type
type initcommoncontrols from structure
ulong dwsize
ulong dwicc
end type
global type nvo_comctl_datetime from nonvisualobject autoinstantiate
end type
type prototypes
// ComCtl32
Function boolean InitCommonControlsEx( Ref INITCOMMONCONTROLS LPINITCOMMONCONTROLS) Library "comctl32.dll"
// Win32 API
Function long CreateWindowExA( ulong dwExStyle, string lpClassName, string lpWindowName, ulong dwStyle, long xPos, long yPos, long nWidth, long nHeight, long hWndParent, long hMenu, long hInstance, long lpParam ) Library "user32"
Function boolean DestroyWindow( long hWnd ) Library "user32"
Function boolean IsWindow( long hWnd ) Library "user32"
Function long SendMessageSystemTime( long hWnd, long uMsg, long wParam, Ref SYSTEMTIME lpst ) Library "user32" Alias For "SendMessageA"
Function long SendMessageSystemTime( long hWnd, long uMsg, long wParam, Ref SYSTEMTIME lpst[2] ) Library "user32" Alias For "SendMessageA"
end prototypes
type variables
// Handle for control
long ilHandle = -1
// DateTime Syles (these are PUBLIC !)
Public Constant Long DTS_UPDOWN = 1 // 0x0001 // use UPDOWN instead of MONTHCAL
Public Constant Long DTS_SHOWNONE = 2 // 0x0002 // allow a NONE selection
Public Constant Long DTS_SHORTDATEFORMAT = 0 // 0x0000 // use the short date format (app must forward WM_WININICHANGE messages)
Public Constant Long DTS_LONGDATEFORMAT = 4 // 0x0004 // use the long date format (app must forward WM_WININICHANGE messages)
Public Constant Long DTS_TIMEFORMAT = 9 // 0x0009 // use the time format (app must forward WM_WININICHANGE messages)
Public Constant Long DTS_APPCANPARSE = 16 // 0x0010 // allow user entered strings (app MUST respond to DTN_USERSTRING)
Public Constant Long DTS_RIGHTALIGN = 32 // 0x0020 // right-align popup instead of left-align it
// MonthCal color constants (for of_GetMColor and of_SetMColor)
Public Constant Long MCSC_BACKGROUND = 0 // the background color (between months)
Public Constant Long MCSC_TEXT = 1 // the dates
Public Constant Long MCSC_TITLEBK = 2 // background of the title
Public Constant Long MCSC_TITLETEXT = 3
Public Constant Long MCSC_MONTHBK = 4 // background within the month cal
Public Constant Long MCSC_TRAILINGTEXT = 5 // the text color of header & trailing days
// Window Classname and control ID
Private Constant String DATETIME_CLASS = "SysDateTimePick32"
Private Constant Long ID_DATETIME = 100
// InitCommonControlsEX constants
Private Constant Long ICC_LISTVIEW_CLASSES = 1 // 0x00000001 - listview, header
Private Constant Long ICC_TREEVIEW_CLASSES = 2 // 0x00000002 - treeview, tooltips
Private Constant Long ICC_BAR_CLASSES = 4 // 0x00000004 - toolbar, statusbar, trackbar, tooltips
Private Constant Long ICC_TAB_CLASSES = 8 // 0x00000008 - tab, tooltips
Private Constant Long ICC_UPDOWN_CLASS = 16 // 0x00000010 - updown
Private Constant Long ICC_PROGRESS_CLASS = 32 // 0x00000020 - progress
Private Constant Long ICC_HOTKEY_CLASS = 64 // 0x00000040 - hotkey
Private Constant Long ICC_ANIMATE_CLASS = 128 // 0x00000080 - animate
Private Constant Long ICC_WIN95_CLASSES = 255 // 0x000000FF - All of the above
Private Constant Long ICC_DATE_CLASSES = 256 // 0x00000100 - month picker, date picker, time picker, updown
Private Constant Long ICC_USEREX_CLASSES = 512 // 0x00000200 - comboex
Private Constant Long ICC_COOL_CLASSES = 1024 // 0x00000400 - rebar (coolbar) control
// Return Values
Private Constant Long GDT_ERROR = -1
Private Constant Long GDT_VALID = 0
Private Constant Long GDT_NONE = 1
// Min/Max constants
Private Constant Long GDTR_MIN = 1
Private Constant Long GDTR_MAX = 2
// DateTime Message Constants
Private Constant Long DTM_FIRST = 4096 // 0x1000
Private Constant Long DTM_GETSYSTEMTIME = (DTM_FIRST + 1)
Private Constant Long DTM_SETSYSTEMTIME = (DTM_FIRST + 2)
Private Constant Long DTM_GETRANGE = (DTM_FIRST + 3)
Private Constant Long DTM_SETRANGE = (DTM_FIRST + 4)
Private Constant Long DTM_SETFORMAT = (DTM_FIRST + 5)
Private Constant Long DTM_SETMCCOLOR = (DTM_FIRST + 6)
Private Constant Long DTM_GETMCCOLOR = (DTM_FIRST + 7)
end variables
forward prototypes
protected function datetime of_getdatetime (readonly systemtime apsystemtime)
protected subroutine of_getsystemtime (datetime adtdatetime, ref systemtime apsystemtime)
public function datetime of_getdatetime ()
public function long of_create (long alparent, long alstyle, long alx, long aly, long alwidth, long alheight)
public function boolean of_destroy ()
public function long of_gethandle ()
public subroutine of_sethandle (long alHandle)
public function long of_getrange (ref datetime adtmin, ref datetime adtmax)
public function boolean of_setrange (datetime adtMin, datetime adtMax)
public function boolean of_setformat (readonly string asformat)
public function boolean of_setmcolor (integer icolor, long lrgb)
public function long of_getmcolor (integer icolor)
public function boolean of_setdatetime (datetime adtdatetime)
end prototypes
protected function datetime of_getdatetime (readonly systemtime apsystemtime);//====================================================================
// Function - of_getdatetime for nvo_comctl_datetime
//--------------------------------------------------------------------
// Description:Converts the SYSTEMTIME structure to a PB DateTime.
//--------------------------------------------------------------------
// Arguments:
//
// systemtime apsystemtime
// Win32 date/time in a SYSTEMTIME structure
//--------------------------------------------------------------------
// Returns: (DATETIME) - PB equivalent of SYSTEMTIME structure
//--------------------------------------------------------------------
// Author: RCSIZER Date: September, 1999
//====================================================================
date ldDate
time ltTime
ldDate = Date( apSystemTime.wYear, apSystemTime.wMonth, apSystemTime.wDay )
ltTime = Time( apSystemTime.wHour, apSystemTime.wMinute, apSystemTime.wSecond )
RETURN DateTime( ldDate, ltTime )
end function
protected subroutine of_getsystemtime (datetime adtdatetime, ref systemtime apsystemtime);//====================================================================
// Function - of_getsystemtime for nvo_comctl_datetime
//--------------------------------------------------------------------
// Description:Converts a PB DateTime into a Win32 SYSTEMTIME
//--------------------------------------------------------------------
// Arguments:
//
// datetime adtDateTime
// PB Datetime variable that must be converted into a SYSTEMTIME
// REF SYSTEMTIME apSystemTime
// Returned SYSTEMTIME structure
//--------------------------------------------------------------------
// Returns: <none>
//--------------------------------------------------------------------
// Author: RCSIZER Date: September, 1999
//====================================================================
SYSTEMTIME lSystemTime
Date ldDate
Time ltTime
// Split DateTime into Date and Time components
ldDate = Date( adtDateTime )
ltTime = Time( adtDateTime )
// Popupate Date structure elements
lSystemTime.wYear = Year( ldDate )
lSystemTime.wMonth = Month( ldDate )
lSystemTime.wDay = Day( ldDate )
// Populate Time structure elements
lSystemTime.wHour = Hour( ltTime )
lSystemTime.wMinute = Minute( ltTime )
lSystemTime.wSecond = Second( ltTime )
// Set reference argument
apSystemTime = lSystemTime
RETURN
end subroutine
public function datetime of_getdatetime ();//====================================================================
// Function - of_getdatetime for nvo_comctl_datetime
//--------------------------------------------------------------------
// Description:Returns the current date/time in the control. If no value
// is selected and the NONE style is allowed, this
// function will return a NULL value.
//--------------------------------------------------------------------
// Returns: (DATETIME) - Date/Time in edit box. NULL if no date entered.
//--------------------------------------------------------------------
// Author: RCSIZER Date: September, 1999
//====================================================================
long llRetVal
datetime ldtSelected
SYSTEMTIME lpSYSTEMTIME
IF IsWindow( This.ilHandle ) THEN
llRetVal = SendMessageSystemTime( This.ilHandle, DTM_GETSYSTEMTIME, 0, lpSYSTEMTIME )
ELSE
llRetVal = GDT_NONE
END IF
CHOOSE CASE llRetVal
CASE GDT_ERROR, GDT_NONE
SetNull( ldtSelected )
CASE GDT_VALID
ldtSelected = This.of_GetDateTime( lpSYSTEMTIME )
END CHOOSE
RETURN ldtSelected
end function
public function long of_create (long alparent, long alstyle, long alx, long aly, long alwidth, long alheight);//===================================================================
// Function - of_create for nvo_comctl_datetime
//-------------------------------------------------------------------
// Description:Creates a DateTime control using the CreateWindowEX API
// function. This allows the user to explicitly set the
// parent.
//
// NOTE: All window co-oridinates (X,Y,Width,Height) are in PIXELS !
// Use the UnitsToPixels() function to convert PB units to
// pixels BEFORE calling this function.
//-------------------------------------------------------------------
// Parameters:
//
// alParent
// Handle to parent or owner window
// alStyle
// DateTime styles. See the DTS_xxx constants
// alX
// X Position relative to the parent window
// alY
// Y Position relative to the parent window
// alWidth
// Width of datetime control
// alHeight
// Height of datetime control
//-------------------------------------------------------------------
// Returns: Returns the window handle if successful.
// Returns 0 if progress bar was not created.
//-------------------------------------------------------------------
// Author: RCSIZER Date: September, 1999
//===================================================================
// Window Style constants
Constant long WS_CHILD = 1073741824
Constant long WS_VISIBLE = 268435456
long llHandle
long llLeft, llTop, llRight, llBottom
// Return current handle is window already exists
IF IsWindow( This.ilHandle ) THEN RETURN This.ilHandle
// Create MonthCal control
llHandle = CreateWindowExA( &
0, /* No extended Styles */ &
DATETIME_CLASS, /* Registered Window ClassName */ &
"", /* No Window Name */ &
WS_CHILD + WS_VISIBLE + alStyle, /* Window Styles. See DTS_xxx constants */ &
alX, alY, alWidth, alHeight, /* Window position */ &
alParent, /* Parent window, can be a window or any other control */ &
ID_DATETIME, /* Control ID */ &
Handle(GetApplication()), /* Application Handle */ &
0 /* Pointer to window-creation data */ )
// Was window created successfully ?
IF IsWindow(llHandle) THEN
// Save window handle
This.ilHandle = llHandle
END IF
// Return result of CreateWindowEX
RETURN llHandle
end function
public function boolean of_destroy ();//====================================================================
// Function - of_destroy for nvo_comctl_datetime
//--------------------------------------------------------------------
// Description:Destroys the window if it was previously created.
//--------------------------------------------------------------------
// Returns: (BOOLEAN) - TRUE = Window was destroyed (or did not exist)
// FALSE = Window was not destroyed.
//--------------------------------------------------------------------
// Author: RCSIZER Date: September, 1999
//====================================================================
boolean lbDestroy = TRUE
IF IsWindow( This.ilHandle ) THEN
lbDestroy = DestroyWindow( This.ilHandle )
END IF
RETURN lbDestroy
end function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -