BBC BASIC for Windows
« Date picker problem »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:56pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Date picker problem  (Read 431 times)
KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Date picker problem
« Thread started on: Mar 31st, 2016, 7:00pm »

I'm sure I've asked this question before, but I can't find it, so please excuse if you get a sense of deja vu.

I am using the time and date picker in a dialog box to input the date. There is no need for the rather complicated method the Wiki recommends to read the selected date, a simple SYS"GetDlgItemText" does just fine.

The problem comes when I want to restore the contents of the dialog box from file. SYS"SetDltItemText" doesn't do it and the Wiki doesn't offer any help. The edit box stubbornly displays today's date instead of the date I want to set.

So, for example, when I first used the dialog box I set the date to 10/01/2015 and that is the date that has been written out to file. When I want to edit that data all the other bits are read successfully from the file, but the date displays 31/03/2016, which is today's date, instead of 10/01/2016.

Any ideas, please?
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: Date picker problem
« Reply #1 on: Apr 1st, 2016, 08:09am »

Hi KenDown,

Have you tried using

SYS "SendMessage", hdtp%, DTM_SETSYSTEMTIME, 0, systemtime{}

That is what MSDN says, and it works for me. You will need to create the systemtime{} structure, which is the one in the Wiki for the "complicated" method of reading the data, and you'll need to set the relevant sections of it to the date required. hdtp% is the value returned by FN_createwindow, as in the wiki, and DTM_SETSYSTEMTIME can be found using the "Add Windows Constants" utility: it appears to have the value 4098.

If you are reading it in and then restoring it, does it make sense to use the complicated method when reading it, and then just store the whole structure?

Best wishes,

D
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date picker problem
« Reply #2 on: Apr 1st, 2016, 2:17pm »

No, I haven't tried that. I searched on the internet and found that it *is* possible to set the date, but I couldn't make head nor tail of the code used - I couldn't even work out whether it was C or VisualBasic or what!

So thank you very much. I'll investigate.

I don't think it would make sense to start off with the complicated structure as I need the date in ascii format for other purposes, so I'll just read the xx/xx/xxxx in from file and then convert it.
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date picker problem
« Reply #3 on: Apr 1st, 2016, 4:22pm »

Hmmmm.

You quote
SYS "SendMessage", hdtp%, DTM_SETSYSTEMTIME, 0, systemtime{}

Should that not be
SYS "SendMessage", !hdtp%, DTM_SETSYSTEMTIME, 0, systemtime{}

Also, should there not be a reference to the dialog item which contains the date picker? I have three date pickers on that one dialog box, so there has to be a way of distinguishing between them.

Sorry to be a pain.
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date picker problem
« Reply #4 on: Apr 1st, 2016, 4:31pm »

Ha! Sorted. The correct version (for me) is

SYS"SendDlgItemMessage",!grpdlg%,512,4098,0,systemtime{}

grpdlg% is the handle of the dialog box.
512 is the dialog item which holds the date pick thingy.
4098 is your DTM_SETSYSTEMTIME

Many thanks for pointing me in the right direction.
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date picker problem
« Reply #5 on: Apr 1st, 2016, 4:39pm »

For anyone else who has the same problem:

DEFPROCsetpicker(date$,dg%,ic%)
systemtime.Day.l&=VALLEFT$(date$,2)
systemtime.Month.l&=VALMID$(date$,4,2)
systemtime.Year.l&=VALRIGHT$(date$,4)MOD256
systemtime.Year.h&=VALRIGHT$(date$,4)DIV256
SYS"SendDlgItemMessage",!dg%,ic%,4098,0,systemtime{}
ENDPROC

date$ is a string of the form dd/mm/yyyy
dg% is the handle of the dialog box
ic% is the handle of the dialog item
systemtime{} is set up as in the Wiki article.
User IP Logged

DDRM
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 321
xx Re: Date picker problem
« Reply #6 on: Apr 1st, 2016, 10:02pm »

Hi Kendall,

Sorry, should have been clearer: my response related to the version on the wiki using Winlib5 to put it in the main window (for a quick test I didn't want to set up a whole dialogue box). Glad you have sorted out the version for a DB.

D
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls