1 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
   2 Private mc As cMonthCtrl
   3 
   4 ''' // Close Btn
   5 Private Sub CommandButton1_Click()
   6     Unload Me
   7 End Sub
   8 
   9 
  10 
  11 
  12 
  13 ''' // *********************** UserForm ***********************
  14 
  15 Private Sub UserForm_Initialize()
  16 Dim hWndFormDlg As Long
  17 Dim moForm As Object
  18 
  19     Set moForm = Me
  20     ' Create an instance of our Calendar Class
  21     Set mc = New cMonthCtrl
  22     ' ** YOU MUST SET THE hWndForm Property!
  23     'mc.hWndForm = Application.hWnd
  24     'If Val(Application.Version) < 9 Then
  25     '    hWndFormDlg = FindWindow("ThunderXFrame", moForm.Caption)
  26     'Else
  27     '    hWndFormDlg = FindWindow("ThunderDFrame", moForm.Caption)
  28     'End If
  29 
  30     hWndFormDlg = FindWindow("ThunderDFrame", moForm.Caption)
  31     hWndFormDlg = FindWindow(vbNullString, moForm.Caption)
  32     mc.hWndForm = hWndFormDlg
  33 End Sub
  34 
  35 Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
  36     ' This is required in case user Closes Form with the
  37     ' Calendar still open. It also handles when the
  38     ' user closes the application with the Calendar
  39     ' still open.
  40 
  41     If Not mc Is Nothing Then
  42         If mc.IsCalendar Then
  43             Cancel = 1
  44             Exit Sub
  45         End If
  46     Set mc = Nothing
  47     End If
  48 End Sub
  49 
  50 
  51 ''' // Date Picker - Use any date selected
  52 Private Sub Image4_Click()
  53 Dim dtStart As Date, dtEnd As Date
  54 Dim blRet As Boolean
  55 
  56     If Me.TextBox4.Value = "" Then
  57         dtStart = Now
  58     Else
  59         dtStart = Me.TextBox4
  60     End If
  61 
  62     dtEnd = 0
  63 
  64     blRet = modDateTimePicker.ShowMonthCalendar(mc, dtStart, dtEnd)
  65     If blRet = True Then
  66         Me.TextBox4.Value = dtStart
  67     Else
  68     End If
  69 End Sub
  70 
  71 
  72 ''' // Date Picker - Use restricted range of dates: Startdate
  73 Private Sub Image5_Click()
  74 Dim dtStart As Date, dtEnd As Date
  75 Dim blRet As Boolean
  76 Dim TimeArray As Variant
  77 
  78     TimeArray = Tools.DateRanges_Get()
  79 
  80     If Me.TextBox5.Value = "" Then
  81         dtStart = Now
  82     Else
  83         dtStart = Me.TextBox5
  84     End If
  85 
  86     dtEnd = 0
  87 
  88     blRet = modDateTimePicker.ShowMonthCalendar(mc, dtStart, dtEnd, TimeArray)
  89     If blRet = True Then
  90         Me.TextBox5.Value = dtStart
  91     Else
  92     End If
  93 End Sub
  94 
  95 ''' // Date Picker - Use restricted range of dates: Enddate
  96 Private Sub Image6_Click()
  97 Dim dtStart As Date, dtEnd As Date
  98 Dim blRet As Boolean
  99 Dim TimeArray As Variant
 100 
 101     TimeArray = Tools.DateRanges_Get()
 102 
 103     If Me.TextBox6.Value = "" Then
 104         dtStart = Now
 105     Else
 106         dtStart = Me.TextBox6
 107     End If
 108 
 109     dtEnd = 0
 110 
 111     blRet = modDateTimePicker.ShowMonthCalendar(mc, dtStart, dtEnd, TimeArray)
 112     If blRet = True Then
 113         Me.TextBox6.Value = dtStart
 114     Else
 115     End If
 116 End Sub