|
Posted by Highlander on 01/02/07 16:57
mr_unreliable wrote:
> hi Highlander,
>
> I'm impressed with all that html to get the date,
> but why not let microsoft do the work?
>
> Microsoft has a "date-picker" control which has
> good-looking graphics, and is familiar to anybody
> who uses windows.
>
> If you have a recent version of vb (or maybe even
> vba) you will have "date-picker" available, and
> it is scriptable via an actX interface.
>
> Microsoft's (vb) date-picker is located in mscomct2.ocx.
> There is a demo script attached which shows how to
> use it.
>
> There is more. Microsoft also published a msCalender
> control (mscal.ocx). There is also a demo script
> (hta) attached, in case you happen to have the mscal
> control on your system. (I personally like the DTP
> better).
>
> Returning to the date-picker control, if you _don't_
> happen to have microsoft's control installed, there
> are several other versions published. I happen to
> like the ccrp's (Common Control Replacement Project)
> -- a group of guys (sorry, no gals) who are so arrogant
> that they think they can do a better job with the controls
> than microsoft, and generally succeeded.
>
> Here is a reference to the ccrp "date-picker" control,
> which they call the "Date/Time-Picker":
>
> http://ccrp.mvps.org/index.html?controls/ccrpdtp6.htm
>
> It is also an actX control and you ought to be able
> to instantiate it on an hta page and also script it,
> even though I don't have a demo of that.
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>
>
> p.s. I have also seen html/dhtml versions of the
> date-picker control, but why bother?
>
> Highlander wrote:
> > Any suggestions would be greatly appreciated.
> > Thanks!
> >
> > - Dave
> >
>
> --------------040709090300030903000607
> Content-Type: text/plain
> Content-Disposition: inline;
> filename="demoMSDTPickerControl.hta.txt"
> X-Google-AttachSize: 1702
>
> <HTML>
> <HEAD>
>
> <HTA:APPLICATION ID="oHTA" APPLICATIONNAME="Show_msCAL"
> WINDOWSTATE="normal" SCROLL = "no" BORDERSTYLE="normal" BORDER="thin"
> CAPTION="yes" MAXIMIZEBUTTON="no" MINIMIZEBUTTON="no" ICON="mru.ico"
> SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" VERSION="1.0" >
>
> <TITLE> demo msDateTimePicker control </TITLE>
> <!--
> ' --- description block --------------------------
> '
> ' Title: an HTA to demo ms Date-Picker control...
> '
> ' Description: allows the user to pick a date...
> '
> ' Author: mr_unreliable
> ' Website: none at present,
> ' (but may be found lurking around wsh/vbs ng)...
> '
> ' Usage: Use at you own risk, tested on win98se...
> '
> ' --- revision history ---------------------------
> ' 29Dec06: initial attempt...
> ' --- end of description block -------------------
> -->
>
> <SCRIPT language="vbscript">
> ' (global code: resize the window)...
> window.ResizeTo 350,300
>
> Sub btnReadDate_onClick()
> ' MsgBox("click event detected")
> MsgBox("The msCAL control reads: " & vbCrLf & vbCrLf _
> & CStr(oDTP.Month) & "/" & CStr(oDTP.Day) & "/" _
> & CStr(oDTP.Year))
> End Sub
> </SCRIPT>
> </HEAD>
>
> <BODY bgcolor="silver" style="font:10pt verdana">
>
> <OBJECT ID="oDTP" WIDTH=250 HEIGHT=25
> CLASSID="CLSID:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1">
> <PARAM NAME="CalendarTitleBackColor" VALUE="-2147483646">
> <PARAM NAME="CalendarTitleForeColor" VALUE="-2147483639">
> </OBJECT>
> <BR><BR><BR>
> <p>Note: to show the date-time-picker graphic,
> you must click on the down arrow to the right of
> the textbox above. </p>
>
> <BR><BR><BR><BR><BR>
> <BUTTON id="btnReadDate"> Read the Date from msDTP Control </BUTTON>
> </BODY>
> </HTML>
>
> --------------040709090300030903000607
> Content-Type: text/plain
> Content-Disposition: inline;
> filename="demoMSCALControl.hta.txt"
> X-Google-AttachSize: 1378
>
> <HTML>
> <HEAD>
>
> <HTA:APPLICATION ID="oHTA" APPLICATIONNAME="Show_msCAL"
> WINDOWSTATE="normal" SCROLL = "no" BORDERSTYLE="normal" BORDER="thin"
> CAPTION="yes" MAXIMIZEBUTTON="no" MINIMIZEBUTTON="no" ICON="mru.ico"
> SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" VERSION="1.0" >
>
> <TITLE> demo msCAL control </TITLE>
> <!--
> ' --- description block --------------------------
> '
> ' Title: an HTA to demo msCAL control...
> '
> ' Description: allows the user to pick a date...
> '
> ' Author: mr_unreliable
> ' Website: none at present,
> ' (but may be found lurking around wsh/vbs ng)...
> '
> ' Usage: Use at you own risk, tested on win98se...
> '
> ' --- revision history ---------------------------
> ' 29Dec06: initial attempt...
> ' --- end of description block -------------------
> -->
>
> <SCRIPT language="vbscript">
> ' (global code: resize the window)...
> window.ResizeTo 350,300
>
> Sub btnReadDate_onClick()
> ' MsgBox("click event detected")
> MsgBox("The msCAL control reads: " & vbCrLf & vbCrLf _
> & CStr(oMSCAL.Month) & "/" & CStr(oMSCAL.Day) & "/" _
> & CStr(oMSCAL.Year))
> End Sub
> </SCRIPT>
> </HEAD>
>
> <BODY bgcolor="silver" style="font:10pt verdana">
>
> <OBJECT ID="oMSCAL" WIDTH=288 HEIGHT=192
> CLASSID="CLSID:8E27C92B-1264-101C-8A2F-040224009C02">
> </OBJECT>
>
> <BR><BR><BR>
> <BUTTON id="btnReadDate"> Read the Date from msCAL Control </BUTTON>
> </BODY>
> </HTML>
>
> --------------040709090300030903000607--
JW,
This is exactly what I was looking for! Selecting dates is now much
more efficient, there's built-in date validation, and you've cut my
script down from 181 lines to 56:
<html>
<head>
<title>Date Pulldowns</title>
<HTA:APPLICATION
ID="HTAUI"
APPLICATIONNAME="Date Pulldowns"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximized">
</head>
<SCRIPT language="VBScript">
Dim fromDate, toDate
Sub Window_Onload
self.Focus()
self.ResizeTo 400,200
self.MoveTo 400,150
End Sub
Sub DisplayDatesSub
fromDate = CStr(FromDTP.Month) & "/" & CStr(FromDTP.Day) & "/" & _
CStr(FromDTP.Year)
toDate = CStr(ToDTP.Month) & "/" & CStr(ToDTP.Day) & "/" & _
CStr(ToDTP.Year)
MsgBox "From:" & vbTab & fromDate & vbCrlf & "To:" & vbTab & toDate
End Sub
</SCRIPT>
<BODY STYLE="font:6 pt arial; color:white;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000000', EndColorStr='#0000FF')">
<font face="serif" size="4"><b>
FROM:
TO:
<br>
<OBJECT ID="FromDTP" WIDTH=125 HEIGHT=25
CLASSID="CLSID:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1">
<PARAM NAME="CalendarTitleBackColor" VALUE="-2147483646">
<PARAM NAME="CalendarTitleForeColor" VALUE="-2147483639">
</OBJECT>
<OBJECT ID="ToDTP" WIDTH=125 HEIGHT=25
CLASSID="CLSID:20DD1B9E-87C4-11D1-8BE3-0000F8754DA1">
<PARAM NAME="CalendarTitleBackColor" VALUE="-2147483646">
<PARAM NAME="CalendarTitleForeColor" VALUE="-2147483639">
</OBJECT>
<p>
<input id=DisplayDatesButton type="button" value="Display Dates"
name="DisplayDates_button"
onClick="DisplayDatesSub">
<p>
</BODY>
</html>
One question jw. When the script opens the date fields display the
current date. After I've made some selections of different dates, is
there any way to programatically (VBScript) reset the date display to
the current date? Thanks.
And thanks to everyone else who had offered their suggestions.
- Dave
Navigation:
[Reply to this message]
|