MonthCalendar
cat monthCalendar_test.cpp
// monthCalendar_test.cpp
#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Windows::Forms;
#include "monthCalendar_test.h"
#include "myApp.h"
[STAThreadAttribute]
int main(array<System::String ^> ^args){
Application::Run(gcnew myApp()); // message loop
return EXIT_SUCCESS;
}
cat myApp.h
// myApp.h
#pragma once
ref class myApp : public Form {
public:
myApp(); //constructor
// ~myApp(); //destructor
// !myApp(); //finalizer
private:
void InitializeComponent(void); //
int gridSize; //
System::Windows::Forms::MonthCalendar^ monthCalendar1;
System::Windows::Forms::MonthCalendar^ monthCalendar2;
void monthCalendar1_DateChanged(Object^ sender, System::Windows::Forms::DateRangeEventArgs^ e);
void monthCalendar1_DateSelected(Object^ sender, System::Windows::Forms::DateRangeEventArgs^ e);
System::Windows::Forms::Label^ label1;
System::Windows::Forms::Button^ button1;
void button1_Click(Object^ sender, System::EventArgs^ e);
System::Windows::Forms::TextBox^ textBox1;
void textBox1_TextChanged(Object^ sender, System::EventArgs^ e);
}; //semi-colon
cat myApp.cpp
// myApp.cpp
#using <mscorlib.dll>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::ComponentModel;
using namespace System::Drawing;
using namespace System::Windows::Forms;
#include "monthCalendar_test.h"
#include "myApp.h"
// myApp::~myApp(){} //destructor
// myApp::!myApp(){} //finalizer
myApp::myApp(){ //constructor
this->InitializeComponent();
}
void myApp::InitializeComponent(void){ //constructor
this->gridSize=20; //
int tabindex=0; //
// set MonthCalendar
this->monthCalendar1 = gcnew System::Windows::Forms::MonthCalendar;
this->monthCalendar1->Location = System::Drawing::Point(gridSize, gridSize * 4);
this->monthCalendar1->Name = "monthCalendar1";
this->monthCalendar1->TabIndex = tabindex++;
this->monthCalendar1->DateSelected += gcnew System::Windows::Forms::DateRangeEventHandler(this,&myApp::monthCalendar1_DateSelected);
this->monthCalendar1->DateChanged += gcnew System::Windows::Forms::DateRangeEventHandler(this,&myApp::monthCalendar1_DateChanged);
this->Controls->Add(this->monthCalendar1);
//
// set MonthCalendar 2
this->monthCalendar2 = gcnew System::Windows::Forms::MonthCalendar;
this->monthCalendar2->Location = System::Drawing::Point(gridSize*10, gridSize * 4);
this->monthCalendar2->Name = "monthCalendar2";
this->monthCalendar2->TabIndex = tabindex++;
// Change the color.
this->monthCalendar2->BackColor = System::Drawing::SystemColors::Info;
this->monthCalendar2->ForeColor = System::Drawing::Color::FromArgb( ((System::Byte)(192)) ),((System::Byte)(0)),((System::Byte)(192));
this->monthCalendar2->TitleBackColor = System::Drawing::Color::Purple;
this->monthCalendar2->TitleForeColor = System::Drawing::Color::Yellow;
this->monthCalendar2->TrailingForeColor = System::Drawing::Color::FromArgb( ((System::Byte)(192)) ),((System::Byte)(192)),((System::Byte)(0));
// Add dates to the AnnuallyBoldedDates array.
array<System::DateTime>^ temp1 = {System::DateTime( 2007, 4, 20, 0, 0, 0, 0 ),System::DateTime( 2007, 4, 28, 0, 0, 0, 0 ),System::DateTime( 2007, 5, 5, 0, 0, 0, 0 ),System::DateTime( 2007, 7, 4, 0, 0, 0, 0 ),System::DateTime( 2007, 12, 15, 0, 0, 0, 0 ),System::DateTime( 2007, 12, 18, 0, 0, 0, 0 )};
this->monthCalendar2->AnnuallyBoldedDates = temp1;
// Add dates to BoldedDates array.
array<System::DateTime>^ temp2 = {System::DateTime( 2007, 9, 26, 0, 0, 0, 0 )};
this->monthCalendar2->BoldedDates = temp2;
// Add dates to MonthlyBoldedDates array.
array<System::DateTime>^ temp5 = {System::DateTime( 2007, 1, 15, 0, 0, 0, 0 ),System::DateTime( 2007, 1, 30, 0, 0, 0, 0 )};
this->monthCalendar2->MonthlyBoldedDates = temp5;
// Configure the calendar to display 3 rows by 4 columns of months.
this->monthCalendar2->CalendarDimensions = System::Drawing::Size( 4, 3 );
// Set week to begin on Monday.
this->monthCalendar2->FirstDayOfWeek = System::Windows::Forms::Day::Monday;
// Set the maximum visible date on the calendar to 12/31/2010.
this->monthCalendar2->MaxDate = System::DateTime( 2010, 12, 31, 0, 0, 0, 0 );
// Set the minimum visible date on calendar to 1/1/1999.
this->monthCalendar2->MinDate = System::DateTime( 1999, 1, 1, 0, 0, 0, 0 );
// Only allow 21 days to be selected at the same time.
this->monthCalendar2->MaxSelectionCount = 21;
// Set the calendar to move one month at a time when navigating using the arrows.
this->monthCalendar2->ScrollChange = 1;
// Do not show the "Today" banner.
this->monthCalendar2->ShowToday = false;
// Do not circle today's date.
this->monthCalendar2->ShowTodayCircle = false;
// Show the week numbers to the left of each week.
this->monthCalendar2->ShowWeekNumbers = true;
this->Controls->Add(this->monthCalendar2);
// set Label
this->label1 = gcnew System::Windows::Forms::Label();
this->label1->Location = System::Drawing::Point(gridSize, gridSize);
this->label1->Name = "label1";
this->label1->Size = System::Drawing::Size(gridSize * 20, gridSize);
this->label1->Text = "0";
this->label1->TabIndex = tabindex++;
this->Controls->Add(label1);
// set Button
this->button1 = gcnew System::Windows::Forms::Button();
this->button1->Location = System::Drawing::Point(gridSize, gridSize * 2);
this->button1->Name = "button1";
this->button1->Size = System::Drawing::Size(gridSize * 2, gridSize);
this->button1->TabIndex = tabindex++;
this->button1->Text = "Push me";
this->button1->Click += gcnew System::EventHandler(this,&myApp::button1_Click);
this->Controls->Add(button1);
// set TextBox
this->textBox1 = gcnew System::Windows::Forms::TextBox();
this->textBox1->Location = System::Drawing::Point(gridSize, gridSize * 3);
this->textBox1->Name = "textBox1";
this->textBox1->Size = System::Drawing::Size(gridSize * 20, gridSize);
this->textBox1->TabIndex = tabindex++;
this->textBox1->Text = ""; // default string
this->textBox1->TextChanged += gcnew System::EventHandler(this,&myApp::textBox1_TextChanged);
this->Controls->Add(textBox1);
// set some form properties/fields
this->Text = "monthCalendar_test";
this->FormBorderStyle=::FormBorderStyle::Fixed3D;
this->MaximizeBox=false;
this->ClientSize=System::Drawing::Size(1024,600);
}
// Button Handler
void myApp::button1_Click(Object^ sender, System::EventArgs^ e){
MessageBox::Show("Hi");
}
// TextBox Handler
void myApp::textBox1_TextChanged(Object^ sender, System::EventArgs^ e){
MessageBox::Show(textBox1->Text+"\n was entered");
}
// monthCalendar Handlers
void myApp::monthCalendar1_DateChanged(Object^ sender, System::Windows::Forms::DateRangeEventArgs^ e)
{
}
void myApp::monthCalendar1_DateSelected(Object^ sender, System::Windows::Forms::DateRangeEventArgs^ e)
{
this->label1->Text=monthCalendar1->SelectionStart.ToString();
}
cat makefile
# makefile for monthCalendar_test
.PHONY: all test mmm clean
.SUFFIXES: .exe .obj .txt .resources .dll
TARGET=monthCalendar_test
CULTUREDIRS=
DLLS=
all: $(TARGET).exe $(DLLS)
LOPT=-ENTRY:main -SUBSYSTEM:WINDOWS
OBJS=$(TARGET).obj myApp.obj AssemblyInfo.obj
$(TARGET).obj: $(TARGET).cpp myApp.h
myApp.obj: myApp.cpp myApp.h
AssemblyInfo.obj: AssemblyInfo.cpp
meta: $(TARGET).exe
ILDasm /out:$@ /metadata $<
$(TARGET).exe: $(OBJS)
link $(LOPT) $^
.cpp.obj:
cl -c -Wall -Od -clr:safe $<
test: $(TARGET).exe
./$(TARGET).exe &
clean:
@-rm $(TARGET).exe *.obj *~ $(TARGET).exe.manifest 1>/dev/null 2>&1
@-rm *.resources 1>/dev/null 2>&1
@-rm -fr $(CULTUREDIRS)
mmm:
cat $(TARGET).cpp
cat myApp.h
cat myApp.cpp
@echo
cat makefile
html:
cat /dev/clipboard | code2html.exe | unix2dos
install: $(TARGET).exe
cp $(TARGET).exe ~/bin
cp $(TARGET).exe.manifest ~/bin