BBC BASIC for Windows
« Date/Time Picker »

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



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/Time Picker  (Read 2247 times)
KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Date/Time Picker
« Thread started on: Feb 10th, 2014, 08:57am »

I've just been playing around with the Date/Time Picker. I have a dialog box with multiple edit boxes for things like Name, Address, Phone, etc. There are buttons to move forward and back and display the next or previous record.

I want to use the Date/Time Picker to enter a date, but if I enter - say - 01/01/2013 and then move to the next record, the Date/Time Picker retains the 01/01/2013 date instead of reverting to the present date

Is there any way of resetting the Date/Time Picker to the present date when I click to move to another record or, even better, setting it to the date already present in that record?

Many thanks.
User IP Logged

Matt
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Date/Time Picker
« Reply #1 on: Feb 10th, 2014, 2:44pm »

The wiki page http://bb4w.wikispaces.com/Using+the+Date+and+Time+Picker explains some of how to use the datetime piker. I also use the following routines to convert formats:

Code:
      REM requires INSTALL @lib$+"DATELIB"
      REM requires the following structure in the main program:
      DIM systemtime{Year{l&,h&}, Month{l&,h&}, DayOfWeek{l&,h&}, Day{l&,h&}, \
      \              Hour{l&,h&}, Minute{l&,h&}, Second{l&,h&}, Milliseconds{l&,h&}}
      ;
      ;
      REM Converts systemtime{} to mid-Julian date. Requires DATELIB
      DEF FN_date_from_struc(st{})
      = FN_mjd(st.Day.l&, st.Month.l&, st.Year.h& * 256 + st.Year.l&)
      ;
      ;
      REM Converts mid-Julian date to systemtime{}. Requires DATELIB
      DEF FN_date_to_struc(date%, RETURN st{})
      LOCAL ds%
      IF date%=&80000000 OR date%=0 THEN date%=FN_today: ds%=FALSE ELSE ds%=TRUE
      st.Day.l&   = FN_day(date%)
      st.Month.l& = FN_month(date%)
      st.Year.l&  = FN_year(date%) MOD 256
      st.Year.h&  = FN_year(date%) DIV 256
      =ds%
 


Matt
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date/Time Picker
« Reply #2 on: Feb 11th, 2014, 5:46pm »

Thanks - but not a word of that answers my question.

Let me try again: when I am displaying record n% and move to the next record, I repopulate the various edit boxes with the details of record n%+1 using SYS"SetDlgItemText". First, however, I read the details of record n% using SYS"GetDlgItemText" (which works the Date and Time Picker, by the way) and store them in name$(n%) (etc).

When I move to record n%+2 I read the details of n%+1, store them and display n%+2. And so on.

All clear?

Let us suppose I have used the Date Picker to set the record for n% to 28/02/1948. However the date in record n%+1 is already set to 10/12/2000. I would like to insert that into the Date Picker.

When I move on from n%+1 the program reads the date, which is still set to 28/02/1948 and inserts that into the record. I would like to reset the Date Picker to today's date.

Neither is even hinted at in the Wiki article you referenced, nor in the reply you gave. I very much appreciate your trouble in replying, but I have no need to convert formats - useful though that doubtless is for some people. I need to set - or reset - the Date/Time Picker.
User IP Logged

Matt
Developer

member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Date/Time Picker
« Reply #3 on: Feb 11th, 2014, 6:35pm »

on Feb 11th, 2014, 5:46pm, KenDown wrote:
Let us suppose I have used the Date Picker to set the record for n% to 28/02/1948. However the date in record n%+1 is already set to 10/12/2000. I would like to insert that into the Date Picker.

If I understand you correctly (which I may not do at all) then what your asking is how to set the DTP to a particular date - in this case 10/12/2000, the date in the new record, N%+1.

Before putting a whole lot of answer down can you confirm that this is what you mean. If it's not then I do apologise.

Matt
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Date/Time Picker
« Reply #4 on: Feb 11th, 2014, 6:58pm »

on Feb 11th, 2014, 5:46pm, KenDown wrote:
Neither is even hinted at in the Wiki article you referenced

Always bear in mind that, when it comes to the Windows API, neither the BB4W manual nor the Wiki can hope to provide a comprehensive coverage of the facilities available; it would be impossible and fruitless to attempt to do so.

What they do aim to achieve is to give sufficient of an overview of how to access the feature from BB4W that, used in conjunction with MSDN, you can work out for yourself what to do.

In this specific case a quick glance at MSDN will immediately tell you how to preset a Date and Time Picker to any desired date and time: it's the DTM_SETSYSTEMTIME message:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb761782.aspx

Richard.
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date/Time Picker
« Reply #5 on: Feb 13th, 2014, 9:00pm »

Thanks, Matt, I think that is precisely what I want.

Richard, I appreciate your message and the URL, but that is what I find so frustrating about the MSN site (and others like it). It very kindly tells you that the parameters are GDT_VALID and GDT_NONE - but you try typing one of those into BB4W and see how far it gets you!

I presume that those are, in fact, numbers, but I cannot find anywhere that will tell me what the value of GDT_VALID is or should be. Why the devil can't they just say, "the paramters are &400010 to set the clock and &666 to make your computer blow up" or whatever the call is supposed to do.

Grrrrrr.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Date/Time Picker
« Reply #6 on: Feb 13th, 2014, 9:33pm »

on Feb 13th, 2014, 9:00pm, KenDown wrote:
It very kindly tells you that the parameters are GDT_VALID and GDT_NONE - but you try typing one of those into BB4W and see how far it gets you!

It gets you all the way, so long as you remember to run the Windows Constants Utility afterwards (slot 8 in the Utilities menu, usually).

Quote:
I presume that those are, in fact, numbers, but I cannot find anywhere that will tell me what the value of GDT_VALID is or should be.

Cannot find anywhere? It's what the Windows Constants Utility is for, as I mention above, and API Viewer will also do it, although less conveniently:

http://jonripley.com/bb4w/win32api/viewer

Quote:
Why the devil can't they just say, "the paramters are &400010 to set the clock and &666 to make your computer blow up" or whatever the call is supposed to do.

There are many reasons, but one of the most important is code readability. Which of these code snippets is easier to understand?

Code:
      SYS "ShowWindow", @hwnd%, SW_MINIMIZE 

or

Code:
      SYS "ShowWindow", @hwnd%, 6 

The first tells you at a glance that the action of the code is to minimize the window, whereas you can't tell from the second what it does, unless you happen to remember what the 6 signifies (which, given that there are thousands of constants, is rather unlikely).

Richard.
User IP Logged

Malvern
Guest
xx Re: Date/Time Picker
« Reply #7 on: Feb 14th, 2014, 12:01am »

There is always this program of Malcolm's as well.
WINCONSTlookup2_1.exe on the Yahoo files/tools/folder

Sorry links still aren't working.

It can let you do two things. Search for all of a particular type of constant say ES_ and give you all the edit styles that exist, since you won't remember any but a couple. You can then look them up in WIN32 help or Google them. Or you can put in a constant value and it will tell you all the matches, so you can look up what is going on in code that is terse, such as LIB files. But Grrrrr! should be overriden by this or Richard's suggestions. I put a link to this constants look up on the Utilities link.
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date/Time Picker
« Reply #8 on: Feb 14th, 2014, 04:27am »

Wow! That's clever.

Mind you, I am still no nearer understanding the information on that page. Obviously there is SYS"DateTime_SetSystemtime" followed by a comma and then, I presume, a reference to the structure they describe as !param, so SYS"DateTime_SetSystemtime",struc{} and then what? Another comma and GDT_VALID? Do you need GDT_VALID *and* GDT_NONE or just one of them? Are there any trailing zeroes?

No doubt it is all very clear to geniuses like yourself, but to a bear of very little brain like me ....

Anyway, thanks for your help and I'm impressed by that utility. Experimentation is in order, methinks.

Malvern, thanks for your reply, but hasn't the Yahoo thingy died permanently?
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Date/Time Picker
« Reply #9 on: Feb 14th, 2014, 09:23am »

on Feb 14th, 2014, 04:27am, KenDown wrote:
Mind you, I am still no nearer understanding the information on that page. Obviously there is SYS"DateTime_SetSystemtime" followed by a comma...

The very first paragraph on the MSDN page to which I linked says: "You can send this message explicitly or use the DateTime_SetSystemtime macro". You cannot use macros from BASIC because they are implemented in C (and are defined in C header files)! The relevant part is "send this message explicitly" - that's what you need to do from BBC BASIC.

Quote:
No doubt it is all very clear to geniuses like yourself

It's nothing to do with being a genius, but all about using your common sense.

The relevant Wiki article shows you how to send the DTM_GETSYSTEMTIME message to the control, so it's only a matter of making a trivial modification to send DTM_SETSYSTEMTIME instead. I'd prefer you to understand exactly what you are doing and why, but in this particular case it's not essential.

This was the point I was making about the BB4W documentation giving you sufficient information to work out for yourself what to do.

Quote:
Malvern, thanks for your reply, but hasn't the Yahoo thingy died permanently?

The BB4W Yahoo! group is still a valuable repository for files, and I still post announcements there. I have no intention of closing it, not least because that would mean moving the entire BB4W Files archive somewhere else.

Richard.
« Last Edit: Feb 14th, 2014, 11:32am by admin » User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date/Time Picker
« Reply #10 on: Feb 18th, 2014, 7:02pm »

Really? I've just clicked on the "Discussion Group" option in BB4W help, which used to take me to that site, and I find a message "This group is temporarily closed to new messages etc" and no way that I can see of accessing the content that used to be there.

I have signed in and although I can now access correspondence, I can't reply to anything and there is no archive of programs that I can see.

Incidentally, I'd be happy to try running all my programs on v.6 if you felt that would be useful.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Date/Time Picker
« Reply #11 on: Feb 18th, 2014, 9:29pm »

on Feb 18th, 2014, 7:02pm, KenDown wrote:
I've just clicked on the "Discussion Group" option in BB4W help, which used to take me to that site, and I find a message "This group is temporarily closed to new messages etc"

That's right, it's currently closed to new messages. But you can still read all the archived messages, you can upload and download files, in fact I think you can do everything except post new messages. Of course you've got to navigate the 'Neo' interface, but there's nothing I can do about that!

Quote:
Incidentally, I'd be happy to try running all my programs on v.6 if you felt that would be useful.

I don't think you responded to my request for volunteers, did you? If you had you would be on my BB4W v6 email mailing list, and you're not.

Richard.
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date/Time Picker
« Reply #12 on: Feb 19th, 2014, 04:26am »

No, I only just noticed the message about volunteers. If I'm too late, that's fine. I hope, however, that it reassures you that there is still interest in your work.

I couldn't find the area where files are uploaded or downloaded, but that may be due to the new interface.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Date/Time Picker
« Reply #13 on: Feb 19th, 2014, 08:23am »

on Feb 19th, 2014, 04:26am, KenDown wrote:
No, I only just noticed the message about volunteers.

I tried to disseminate the information as widely as possible. The message was sent to members of the Yahoo group (with at least 'Special Notices' enabled), to every member of the Wiggio group, and to every member of this forum (with email notifications allowed).

I would therefore have expected most 'interested' BB4W users to have received three copies of the email! If you received none, it would imply that you have disabled email notifications on all three groups, even Special Notices. sad

Quote:
If I'm too late, that's fine. I hope, however, that it reassures you that there is still interest in your work.

It's possible that there will be a second phase of testing with a larger number of people involved.

Quote:
I couldn't find the area where files are uploaded or downloaded, but that may be due to the new interface.

I don't know how you can miss it. The header (immediately below the banner) says 'Conversations Photos Files More': just click on 'Files'!

Richard.
User IP Logged

KenDown
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 181
xx Re: Date/Time Picker
« Reply #14 on: Feb 19th, 2014, 4:55pm »

Oh, I'm sure it is probably my fault. I don't log in here very often.

So far as I know, I haven't disabled anything - and can see no reason why I would disable communication from a most valued source.

Anyway, not to worry. I'm glad to help if I can.
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