|
-
Mar 5th, 2010, 04:40 AM
#1
Thread Starter
New Member
How to lock a button until next day?
I'm trying to make this simple program in visual studio 2008.
It's for a pocket pc
It's with a randomizer, where you press a button, and it'll pick a random sentence.
Then made a variable with 10 random sentences, that's all good and working BUT i would like you to be able to only press the button once a day, and then lock it, and then it will ofcourse get unlocked the next day.
For example you press button at 4 pm, then it'll get locked until 12 @ midnight, then unlocks, and process restarts.
So you will have sentence a day, and no more.
If you have any idea about this, i would appreciate some help, havent been able to find anything about it unfortunately.
-
Mar 5th, 2010, 08:26 AM
#2
Re: How to lock a button until next day?
If this is for a mobile app the it really should be posted in the Mobile forum because the considerations are different. I've asked the mods to move it.
You should handle the Click event of the Button and set its Enabled property to False. You can then calculate the amount of time until midnight and use that to set the Interval of a Timer, which you then Start. When the Timer Ticks, you enable the Button. This will work in a PC app and I assume a mobile app too, but I'm not 100% sure.
-
Mar 5th, 2010, 09:18 AM
#3
Re: How to lock a button until next day?
 Originally Posted by jmcilhinney
You should handle the Click event of the Button and set its Enabled property to False. You can then calculate the amount of time until midnight and use that to set the Interval of a Timer, which you then Start. When the Timer Ticks, you enable the Button. This will work in a PC app and I assume a mobile app too, but I'm not 100% sure.
I don't know if this is a good option, because once the user quits the app and comes back in the button would be re-enabled. I think the OP might be better off persisting that information in a file or registry and using a timer to read the value every few seconds/minutes depending on the desired functionality.
-
Mar 5th, 2010, 09:22 AM
#4
Re: How to lock a button until next day?
 Originally Posted by Negative0
I don't know if this is a good option, because once the user quits the app and comes back in the button would be re-enabled. I think the OP might be better off persisting that information in a file or registry and using a timer to read the value every few seconds/minutes depending on the desired functionality.
I did mean to cover that contingency but got distracted and forgot to finish before submitting. You would save a Date somewhere and, when the app started up, you'd compare that Date to the current date. If they were the same day then you'd do the same again, i.e. disable the Button and set the Timer to Tick at midnight.
-
Mar 5th, 2010, 09:42 AM
#5
Re: How to lock a button until next day?
Thread moved to 'Mobile Development' forum
(thanks for letting us know jmcilhinney )
-
Feb 27th, 2015, 04:50 PM
#6
New Member
Re: How to lock a button until next day?
Hi there mate, i am on the same problem as yours! Would you mind please explaining me how did you come through? thank you very much!!!!
-
Feb 27th, 2015, 08:56 PM
#7
Re: How to lock a button until next day?
 Originally Posted by elx00r
Hi there mate, i am on the same problem as yours! Would you mind please explaining me how did you come through? thank you very much!!!!
This thread is five years old. Maybe you should start a new one for yourself, particularly given that the person who asked the question here has not posted again since then.
-
Feb 28th, 2015, 05:11 AM
#8
New Member
Re: How to lock a button until next day?
yeah i learnt that later 
i even made one of my own...but nobody seems to explain it to me good enough so that i could understand. I thought the guy who made this post coul've helped me...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|