public: MyForm(void) { InitializeComponent(); //Shows current time in label 2 DateTime datetime = DateTime::Now; this->label2->Text = datetime.ToString("hh:mm"); checkBox1->Enabled = false; //disables checkbox for hour 1 checkBox2->Enabled = false; //disables checkbox for hour 2 checkBox3->Enabled = false; //disables checkbox for hour 3 checkBox4->Enabled = false; //disables checkbox for hour 4 checkBox5->Enabled = false; //disables checkbox for hour 5 checkBox6->Enabled = false; //disables checkbox for hour 6 checkBox7->Enabled = false; //disables checkbox for hour 7 checkBox8->Enabled = false; //disables checkbox for hour 8 checkBox9->Enabled = false; //disables checkbox for hour 9 checkBox10->Enabled = false; //disables checkbox for hour 10 checkBox11->Enabled = false;//disables checkbox for hour 11 checkBox12->Enabled = false; //disables checkbox for hour 12 // //TODO: Add the constructor code here // } ________________________________________________________________________________ /*Here is what I have done for hour 1. If I can get this to work then I can do the same for the other check boxes.*/ private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { //Controls time for binary clock time_t currentTime; struct tm* localTime; time(¤tTime); // Get the current time localTime = localtime(¤tTime); // Convert the current time to the local time int Hour = localTime->tm_hour % 12; //Must mod time by 12 to get standard time if (Hour = 1) { checkBox1->Checked = true; //checks off box } } _____________________________________________________________________________ /*This part of the code is for the refresh button. Right now, all it does is updates the current time in label 2 but does not update the check boxes to reflect the time*/ private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { DateTime datetime = DateTime::Now; this->label2->Text = datetime.ToString("hh:mm"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)