2007-12-30 17:41:49 +01:00
' Gambas class file
2008-04-16 11:30:17 +02:00
Export
Inherits UserControl
'Inherits TextBox
Public Const _Properties As String = "*,-Password,-Text,-Alignment,Type{ValueBox.Date;Identifier;Number;Time}=Number,Allowed,HeightForm=200,WidthForm=300"
2008-07-16 12:12:13 +02:00
'Public Const _DefaultEvent As String = "Change"
2008-04-16 11:30:17 +02:00
Public Const _DefaultSize As String = "30,4"
Public Const _DrawWith As String = "TextBox"
Public Const {Number} As Integer = 0
Public Const {Date} As Integer = 1
Public Const {Time} As Integer = 2
Public Const {Identifier} As Integer = 3
2007-12-30 17:41:49 +01:00
'PUBLIC CONST {Currency} AS Integer = 2
'PUBLIC CONST {MailAddress} AS Integer = 5
'PUBLIC CONST {IPAddress} AS Integer = 6
2008-05-20 10:54:04 +02:00
'Private $hObserver As Observer
2008-04-16 11:30:17 +02:00
Property Value As Variant
Property Type As Integer
Property Read Text As String
Property Allowed As String
Property HeightForm As Integer
Property WidthForm As Integer
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private $iType As Integer
2007-12-30 17:41:49 +01:00
'PRIVATE $bNull AS Boolean
2008-04-16 11:30:17 +02:00
Private $sAllowed As String
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private $sLast As String
Private $sLastGood As String
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Static Private $sDateSep As String
Static Private $sTimeSep As String
Static Private $sDateFormat As String
Static Private $sTimeFormat As String
Static Private $sPointSep As String
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private $hForm As Form
2008-04-21 16:35:14 +02:00
Private $hButton As DrawingArea
2008-04-22 01:15:48 +02:00
Private $bInButton As Boolean
2008-04-16 11:30:17 +02:00
Private $hTextBox As TextBox
Private $hdatechooser As DateChooser
Private $iWidthForm As Integer
Private $iHeightForm As Integer
Private hTimer As Timer
Private $hTimer As Timer
Private IsActivate As Boolean
2008-04-21 16:35:14 +02:00
Private hIcon As Picture
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private $iWarnBackground As Integer
Private $iWarnForeground As Integer
Private $bWarnReadOnly As Boolean
Private $bDelete As Boolean
Static Private Sub GetSeparators()
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If $sDateSep Then Return
2007-12-30 17:41:49 +01:00
$sDateSep = Format$(Now, "/")
$sTimeSep = Format$(Now, ":")
$sPointSep = Left$(Format$(0.1, ".0"))
$sDateFormat = Format(Date(3333, 11, 22), gb.ShortDate)
$sDateFormat = Replace($sDateFormat, "3333", "yyyy")
$sDateFormat = Replace($sDateFormat, "22", "dd")
$sDateFormat = Replace($sDateFormat, "11", "mm")
$sTimeFormat = Format(Time(11, 22, 33), gb.LongTime)
$sTimeFormat = Replace($sTimeFormat, "11", "hh")
$sTimeFormat = Replace($sTimeFormat, "22", "nn")
$sTimeFormat = Replace($sTimeFormat, "33", "ss")
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Public Sub _new()
Dim hPanel, hPanel2 As panel
2007-12-30 17:41:49 +01:00
GetSeparators
2008-04-16 11:30:17 +02:00
hTimer = New timer As "hTimer"
htimer.delay = 100
hPanel2 = New Panel(Me) As "Pan"
hPanel2.Arrangement = Arrange.Horizontal
2008-04-21 10:22:06 +02:00
hPanel2.Border = Border.Sunken
2008-04-16 11:30:17 +02:00
$hTextBox = New TextBox(hPanel2) As "TextBox"
$hTextBox.Expand = True
2008-04-21 10:22:06 +02:00
$hTextBox.Border = Border.None
2008-04-21 16:35:14 +02:00
hIcon = Picture["icon:/small/calendar"]
$hButton = New DrawingArea(hPanel2) As "Button"
2008-04-21 10:22:06 +02:00
$hButton.Width = 24
$hButton.Hide
$hForm = New Form As "LstForm"
$hForm.Arrangement = Arrange.Fill
2008-04-21 16:35:14 +02:00
$hForm.Border = False
2009-03-16 19:20:10 +01:00
' $hForm.Type = Form.Combo
2008-04-21 16:35:14 +02:00
$hForm.Persistent = True
2008-04-21 10:22:06 +02:00
HPanel = New Panel($hForm)
HPanel.Arrangement = Arrange.Fill
$hdatechooser = New DateChooser(HPanel) As "DateChooser"
Me.WidthForm = 300
Me.HeightForm = 200
$hForm.Resize($iWidthForm, $iHeightForm)
2008-05-20 10:54:04 +02:00
' $hObserver = New Observer(Me.Window) As "OBS"
2007-12-30 17:41:49 +01:00
Type_Write(Number)
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Public Sub Pan_Arrange()
If Me.Type = {Date} Then $hButton.Show
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Function Value_Read() As Variant
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Select Case $iType
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case Identifier
Return $hTextBox.Text
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case Else
Return Val($hTextBox.Text)
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End Select
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Catch
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Sub Value_Write(Value As Variant)
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$hTextBox.Text = Str(Value)
2008-03-17 15:54:17 +01:00
TextBox_LostFocus
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Function Type_Read() As Integer
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Return $iType
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Sub Type_Write(Type As Integer)
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Dim sVal As String
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Object.Lock(Me)
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$hTextBox.Text = ""
$hTextBox.Alignment = Align.Right
2007-12-30 17:41:49 +01:00
'ME.Alignment = Align.Left
2008-04-16 11:30:17 +02:00
Select Case Type
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case {Number}
$hTextBox.Text = "0"
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case {Date}, {Time}
$hTextBox.Text = ""
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case Identifier
$hTextBox.Text = ""
$hTextBox.Alignment = Align.Normal
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case Else
2007-12-30 17:41:49 +01:00
Type = $iType
2008-04-16 11:30:17 +02:00
End Select
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Object.Unlock(Me)
$sLast = $hTextBox.Text
2007-12-30 17:41:49 +01:00
$sLastGood = $sLast
$iType = Type
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Sub RemoveLeadingZeros()
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Dim iPos As Integer
Dim bNeg As Boolean
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
iPos = $hTextBox.Pos
bNeg = Left($hTextBox.Text) = "-"
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If bNeg Then $hTextBox.Text = Mid$($hTextBox.Text, 2)
While Left($hTextBox.Text) = "0"
$hTextBox.Text = Mid$($hTextBox.Text, 2)
Dec iPos
Wend
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If $hTextBox.Length = 0 Then $hTextBox.Text = "0"
If bNeg Then $hTextBox.Text = "-" & $hTextBox.Text
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$hTextBox.Pos = iPos
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Sub FormatDateTime(sSep As String)
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Dim iPos As Integer
Dim sVal As String
Dim sElt As String
Dim aFormat As String[]
Dim aValue As String[]
Dim iInd As Integer
Dim sRes As String
Dim iSep As Integer
Dim sRest As String
2007-12-30 17:41:49 +01:00
'IF ME.Text = "31/12/2007/" THEN STOP
2008-03-13 22:38:43 +01:00
'DEBUG "ME.Pos = "; ME.Pos
2008-04-16 11:30:17 +02:00
iPos = $hTextBox.Pos
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
aValue = Split($hTextBox.Text, sSep)
If sSep = $sDateSep Then
2007-12-30 17:41:49 +01:00
aFormat = Split($sDateFormat, sSep)
2008-04-16 11:30:17 +02:00
Else
2007-12-30 17:41:49 +01:00
aFormat = Split($sTimeFormat, sSep)
2008-04-16 11:30:17 +02:00
Endif
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
For iInd = 0 To aValue.Max
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If iInd > aFormat.Max Then Break
2007-12-30 17:41:49 +01:00
sElt = aValue[iInd]
2008-04-16 11:30:17 +02:00
If iInd < aValue.Max Then
2007-12-30 17:41:49 +01:00
sElt = Right(sElt, Len(aFormat[iInd]))
2008-04-16 11:30:17 +02:00
While Len(sElt) < Len(aFormat[iInd])
If iPos >= (Len(sVal) + Len(sElt)) Then Inc iPos
2007-12-30 17:41:49 +01:00
sElt = "0" & sElt
2008-04-16 11:30:17 +02:00
Wend
Else
2007-12-30 17:41:49 +01:00
sRest = Mid(sElt, Len(aFormat[iInd]) + 1)
sElt = Left(sElt, Len(aFormat[iInd]))
2008-04-16 11:30:17 +02:00
Endif
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If Len(sElt) = Len(aFormat[iInd]) Then
If sSep = $sDateSep Then
If CInt(sElt) = 0 Then sElt = Left(sElt, -1) & "1"
Endif
If iInd < aFormat.Max Then
If iPos >= (Len(sVal) + Len(sElt)) Then Inc iPos
2007-12-30 17:41:49 +01:00
sElt &= sSep
2008-04-16 11:30:17 +02:00
Endif
Endif
2007-12-30 17:41:49 +01:00
sVal &= sElt
2008-04-16 11:30:17 +02:00
Next
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If aValue.Count < aFormat.Count And If sRest Then
If iPos >= (Len(sVal) + 1) Then Inc iPos
2007-12-30 17:41:49 +01:00
sVal &= sSep & sRest
2008-04-16 11:30:17 +02:00
Endif
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$hTextBox.Text = sVal
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Finally
2008-03-17 15:54:17 +01:00
2008-04-16 11:30:17 +02:00
$hTextBox.Pos = iPos
2008-03-13 22:38:43 +01:00
'DEBUG "ME.Pos = "; iPos
'DEBUG System.Backtrace.Join("/")
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Sub CheckIdentifierChar(iPos As Integer, sChar As String) As Boolean
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If IsLetter(sChar) Then Return
If iPos > 0 Then
If IsLetter(sChar) Then Return
If IsDigit(sChar) Then Return
If $sAllowed Then
If String.InStr($sAllowed, sChar) Then Return
Else
If sChar = "_" Then Return
Endif
Endif
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Return True
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Public Sub TextBox_KeyPress()
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Dim iPos As Integer
2007-12-30 17:41:49 +01:00
2008-03-13 22:38:43 +01:00
'DEBUG
2008-04-16 11:30:17 +02:00
If Key.Code = Key.Escape Then
$hTextBox.Text = $sLastGood
Stop Event
Return
Endif
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If Key.Code = Key.Delete Or If Key.Code = Key.BackSpace Then
$bDelete = True
Return
Endif
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If Asc(Key.Text) < 32 Then Return
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$bDelete = False
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Select Case $iType
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case {Number}
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If IsDigit(Key.Text) Then
$hTextBox.Insert(Key.Text)
Else If Key.Text = $sPointSep Or Key.Text = "." Then
If InStr($hTextBox.Text, $sPointSep) = 0 Then $hTextBox.Insert($sPointSep)
Else If Key.Text = "-" Then
If Left($hTextBox.Text) <> "-" Then
iPos = $hTextBox.Pos
$hTextBox.Text = "-" & $hTextBox.Text
$hTextBox.Pos = iPos + 1
Else
iPos = $hTextBox.Pos
$hTextBox.Text = Mid$($hTextBox.Text, 2)
$hTextBox.Pos = iPos - 1
Endif
Endif
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case {Date}
2007-12-30 17:41:49 +01:00
2008-03-13 22:38:43 +01:00
'DEBUG "IsDigit: "; IsDigit(Key.Text)
'DEBUG "Key.Text = $sDateSep: "; Key.Text = $sDateSep
'DEBUG "ME.Pos: "; ME.Pos; " ME.Length: "; ME.Length
2008-04-16 11:30:17 +02:00
If IsDigit(Key.Text) Then Return
If Key.Text = $sDateSep And If $hTextBox.Pos = $hTextBox.Length Then Return
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case {Time}
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If IsDigit(Key.Text) Then Return
If Key.Text = $sTimeSep And If $hTextBox.Pos = $hTextBox.Length Then Return
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case {Identifier}
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
If Not CheckIdentifierChar($hTextBox.Pos, Key.Text) Then Return
2007-12-30 17:41:49 +01:00
', {Time}, {DateTime}
2008-04-16 11:30:17 +02:00
End Select
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Stop Event
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Public Sub TextBox_Change()
If $sLast = $hTextBox.Text Then Return
If $bDelete Then Return
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Object.Lock(Me)
2007-12-30 17:41:49 +01:00
2008-03-13 22:38:43 +01:00
'DEBUG
2008-04-16 11:30:17 +02:00
Select Case $iType
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case Number
2007-12-30 17:41:49 +01:00
RemoveLeadingZeros
2008-04-16 11:30:17 +02:00
Case {Date}
2007-12-30 17:41:49 +01:00
FormatDateTime($sDateSep)
2008-04-16 11:30:17 +02:00
Case {Time}
2007-12-30 17:41:49 +01:00
FormatDateTime($sTimeSep)
2008-04-16 11:30:17 +02:00
End Select
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$sLast = $hTextBox.Text
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Object.Unlock(Me)
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Sub CheckIdentifier()
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Dim iInd As Integer
Dim sCar As String
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
For iInd = 1 To String.Len($hTextBox.Text)
sCar = String.Mid($hTextBox.Text, iInd, 1)
If CheckIdentifierChar(iInd - 1, sCar) Then Error.Raise("Bad character")
Next
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Public Sub TextBox_LostFocus()
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Select Case $iType
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case Number
$hTextBox.Text = Str(Val($hTextBox.Text))
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case {Date}
If $hTextBox.Text Then $hTextBox.Text = Format(Val($hTextBox.Text), $sDateFormat)
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case {Time}
If $hTextBox.Text Then $hTextBox.Text = Format(Val(Format(Date(1972, 09, 06), gb.ShortDate) & " " & $hTextBox.Text), $sTimeFormat)
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Case {Identifier}
2007-12-30 17:41:49 +01:00
CheckIdentifier
2008-04-16 11:30:17 +02:00
End Select
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$sLastGood = $hTextBox.Text
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Catch
2007-12-30 17:41:49 +01:00
WarningTimer
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Function Text_Read() As String
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Return $hTextBox.Text
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Function Allowed_Read() As String
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Return $sAllowed
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Sub Allowed_Write(Value As String)
2007-12-30 17:41:49 +01:00
$sAllowed = Value
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Private Sub WarningTimer()
2007-12-30 17:41:49 +01:00
' DIM sMsg AS String
2008-04-16 11:30:17 +02:00
If $hTimer Then
2007-12-30 17:41:49 +01:00
Timer_Timer
2008-04-16 11:30:17 +02:00
Endif
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$hTimer = New Timer As "Timer"
2007-12-30 17:41:49 +01:00
$hTimer.Delay = 100
2008-04-16 11:30:17 +02:00
$hTimer.Enabled = True
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$iWarnBackground = $hTextBox.Background
$iWarnForeground = $hTextBox.Foreground
$bWarnReadOnly = $hTextBox.ReadOnly
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$hTextBox.Background = Color.SelectedBackground
$hTextBox.Foreground = Color.SelectedForeground
$hTextBox.ReadOnly = True
2007-12-30 17:41:49 +01:00
' SELECT $iType
' CASE Number
' sMsg = ("Incorrect number")
' CASE Date
' sMsg = ("Incorrect date")
' CASE Time
' sMsg = ("Incorrect time")
' CASE Identifier
' sMsg = ("Incorrect identifier")
' END SELECT
'
' DEBUG ME
' Balloon.Warning(sMsg, ME, 0, 0)
2008-04-16 11:30:17 +02:00
End
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
Public Sub Timer_Timer()
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$hTextBox.Background = $iWarnBackground
$hTextBox.Foreground = $iWarnForeground
$hTextBox.ReadOnly = $bWarnReadOnly
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
$hTimer = Null
$hTextBox.Text = $sLastGood
2007-12-30 17:41:49 +01:00
2008-04-16 11:30:17 +02:00
End
Private Function WidthForm_Read() As Integer
Return $iWidthForm
End
Private Sub WidthForm_Write(Value As Integer)
$iWidthForm = Value
$hForm.Resize($iWidthForm, $iHeightForm)
End
Private Function HeightForm_Read() As Integer
Return $iHeightForm
End
Private Sub HeightForm_Write(Value As Integer)
$iHeightForm = Value
$hForm.Resize($iWidthForm, $iHeightForm)
End
2008-04-21 16:35:14 +02:00
Public Sub Form_Resize()
$hForm.Resize($iWidthForm, $iHeightForm)
End
Public Sub Button_Draw()
2008-05-20 10:54:04 +02:00
Draw.Begin($hButton)
2008-04-22 01:15:48 +02:00
Draw.Style.Button(0, -5, 54, Me.Height + 50, $bInButton)
2008-04-21 16:35:14 +02:00
Draw.Picture(hIcon, (28 - hIcon.Width) / 2, (Me.Height - hIcon.Height - 4) / 2)
2008-05-20 10:54:04 +02:00
Draw.End()
2008-04-21 16:35:14 +02:00
End
Public Sub Button_Enter()
2008-04-22 01:15:48 +02:00
$bInButton = True
$hButton.Refresh
2008-04-21 16:35:14 +02:00
End
Public Sub Button_Leave()
2008-04-22 01:15:48 +02:00
$bInButton = False
$hButton.Refresh
2008-04-21 16:35:14 +02:00
End
Public Sub Button_MouseDown()
$hDateChooser.Value = Val($hTextBox.Text)
isActivate = True
$hForm.Show
End
2008-04-16 11:30:17 +02:00
Public Sub LstForm_DeACtivate()
2008-05-20 10:54:04 +02:00
htimer.Trigger
2008-04-21 16:35:14 +02:00
End
Public Sub LstForm_Show()
2008-05-20 10:54:04 +02:00
OBS_Move()
2008-04-21 16:35:14 +02:00
Button_Enter
End
Public Sub LstForm_Hide()
Button_Draw
2008-04-16 11:30:17 +02:00
End
Public Sub hTimer_Timer()
2008-06-09 14:30:41 +02:00
'Print "aa"
2008-04-16 11:30:17 +02:00
hTimer.Stop
2008-04-21 16:35:14 +02:00
Try $hForm.Close
2008-04-16 11:30:17 +02:00
isActivate = False
End
2008-04-21 16:35:14 +02:00
Public Sub DateChooser_Activate()
Try $hForm.Close
isActivate = False
2008-04-16 11:30:17 +02:00
End
Public Sub DateChooser_Change()
$hTextBox.Text = Str($hDateChooser.Value)
TextBox_LostFocus
End
Public Sub OBS_Move()
2008-04-21 10:22:06 +02:00
$hdatechooser.Font = Me.Font
2008-04-16 11:30:17 +02:00
If $hButton.ScreenY + $hButton.Height + $hForm.Height < Desktop.Height Then
$hForm.Move($hButton.ScreenX + $hButton.Width - $iWidthForm, $hButton.ScreenY + $hButton.Height)
Else
$hForm.Move($hButton.ScreenX + $hButton.Width - $iWidthForm, $hButton.ScreenY - $hForm.Height)
Endif
End
2008-06-09 14:30:41 +02:00
Public Sub LstForm_KeyPress() 'Hides the date form and returns the selected value
If Key.Code = Key.Esc Then DateChooser_Activate()
End