Sign in to follow this  
Followers 0
mLipok

_Date_FROM_TO - Form for selecting time period

2 posts in this topic

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiButton.au3>
#include <date.au3>

Local $a_result = _Date_FROM_TO('Select time period', '2013/01/01')
If IsArray($a_result) Then MsgBox(48, 'Result', $a_result[0] & @CRLF & $a_result[1])

Func _Date_FROM_TO($s_info, $DATE_FROM = '', $DATE_TO = '')
If $DATE_FROM = '' Then $DATE_FROM = _Now()
If $DATE_TO = '' Then $DATE_TO = _Now()

Local $Form_date_from_to = GUICreate("Date from ... to ....", 413, 392, 254, 114)
GUISetBkColor(0xA6CAF0)
Local $MonthCal_FROM = GUICtrlCreateMonthCal($DATE_FROM, 10, 144, 190, 190)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
Local $MonthCal_TO = GUICtrlCreateMonthCal($DATE_TO, 210, 144, 190, 190)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
Local $Button_SELECT = GUICtrlCreateButton("&Select time period", 10, 352, 190, 25, BitOR($BS_DEFPUSHBUTTON, $BS_CENTER, $BS_VCENTER))
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
Local $Button_CANCEL = GUICtrlCreateButton("&Cancel", 210, 352, 190, 25, BitOR($BS_CENTER, $BS_VCENTER))
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
GUICtrlCreateLabel("from DAY:", 10, 126, 64, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
GUICtrlCreateLabel("to DAY :", 210, 126, 64, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
GUICtrlCreateLabel($s_info, 10, 10, 390, 110, $WS_BORDER, $WS_EX_CLIENTEDGE)
GUICtrlSetBkColor(-1, 0xFFFBF0)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
GUISetState(@SW_SHOW)

Local $nMsg
Local $var_to_return = ''
WinSetOnTop("Date from ... to ....", $s_info, 1)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$var_to_return = False
ExitLoop
Case $Button_SELECT
Local $a_result[2] = [GUICtrlRead($MonthCal_FROM), GUICtrlRead($MonthCal_TO)]
$var_to_return = $a_result
ExitLoop
Case $Button_CANCEL
$var_to_return = False
ExitLoop
EndSwitch
WEnd
GUIDelete($Form_date_from_to)
Return $var_to_return
EndFunc ;==>_Date_FROM_TO


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Hi mlipok,

Nice example, in my opinion to be useful, your script lacks at least a basic legality check.

Please look at my udf

_InputDate udf

also used in my SQLite Report Generator

SQLite Report Generator

Thank you for your contribution

Regards, GreenCan


Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0