managed C++ & Active-X calendar |
Post Reply |
Author | |
hicus
Newbie Joined: 02 October 2006 Status: Offline Points: 3 |
Post Options
Thanks(0)
Posted: 02 October 2006 at 3:39pm |
sserge
Moderator Group Joined: 01 December 2004 Status: Offline Points: 1297 |
Post Options
Thanks(0)
|
Hi,
Yes, that's possible. There are no specific examples, but it will be quite similar to out C# Calendar sample application. You can look at it and compare... -- WBR, Serge |
|
hicus
Newbie Joined: 02 October 2006 Status: Offline Points: 3 |
Post Options
Thanks(0)
|
Here is Form1.h file that demonstrates use of ActiveX calendar with managed C++. Project name is "klinika". Just 1 form and 1 "CalendarControl":
///////////////////////// #pragma once namespace kalendar { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::Globalization; using namespace System::IO; /// <summary> /// Summary for Form1 /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// </summary> public __gc class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); //src/dst for CalendarControl events -> set it on .xml file: ConnectionString = String::Concat("Provider=XML;Data Source=" , System::Environment::CurrentDirectory->ToString(), "\\.." ); CalendarControl->SetDataProvider(String::Concat(ConnectionString,"\\CalendarData.xml")); pCalendarData = CalendarControl->DataProvider; //if file (xml) exists => open it for use; else create new one: if (!File::Exists(String::Concat(System::Environment::CurrentDirectory->ToString(),"\\..\\CalendarData.xml")) ) { //ujedno kreira i otvara za rad fajl CalendarData.xml: pCalendarData->Create(); } else { pCalendarData->Open(); } CalendarControl->Populate(); } protected: void Dispose(Boolean disposing) { if (disposing && components) { components->Dispose(); } __super::Dispose(disposing); } // calendar variables: private: Interop::XtremeCalendarControl::CalendarEvent* ptrEvent; private: Interop::XtremeCalendarControl::CalendarDataProvider* pCalendarData; private: AxInterop::XtremeCalendarControl::AxCalendarControl * CalendarControl; //Sting used to hold path to save xml data files. //This file will contain all of the event information displayed in the calendar view: public: String* ConnectionString; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container * components; /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { System::Resources::ResourceManager * resources = new System::Resources::ResourceManager(__typeof(kalendar::Form1)); this->CalendarControl = new AxInterop::XtremeCalendarControl::AxCalendarControl(); (__try_cast<System::ComponentModel::ISupportInitialize * >(this->CalendarControl))->BeginInit(); this->SuspendLayout(); // // CalendarControl // this->CalendarControl->Dock = System::Windows::Forms::DockStyle::Fill; this->CalendarControl->Location = System::Drawing::Point(0, 0); this->CalendarControl->Name = S"CalendarControl"; this->CalendarControl->OcxState = (__try_cast<System::Windows::Forms::AxHost::State * >(resources->GetObject(S"CalendarControl.OcxState"))); this->CalendarControl->Size = System::Drawing::Size(800, 510); this->CalendarControl->TabIndex = 0; this->CalendarControl->EventChanged += new AxInterop::XtremeCalendarControl::_DCalendarControlEvents_EventChangedEventHandler(this, CalendarControl_EventChanged); this->CalendarControl->EventAdded += new AxInterop::XtremeCalendarControl::_DCalendarControlEvents_EventAddedEventHandler(this, CalendarControl_EventAdded); // // Form1 // this->AutoScaleBaseSize = System::Drawing::Size(5, 13); this->ClientSize = System::Drawing::Size(800, 510); this->Controls->Add(this->CalendarControl); this->Name = S"Form1"; this->Text = S"Form1"; (__try_cast<System::ComponentModel::ISupportInitialize * >(this->CalendarControl))->EndInit(); this->ResumeLayout(false); } ////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////// // You can call this function in constructor for test... private: void AddTestEvents() { // add test events DateTime dtNow = DateTime(DateTime::Now.Ticks); // Create 1 normal event: // Normal Event 1 Interop::XtremeCalendarControl::CalendarEvent* ptrEvent = pCalendarData->CreateEvent(); ptrEvent->StartTime = dtNow; ptrEvent->EndTime = dtNow.AddHours(1); ptrEvent->Subject = "Event &Now [Tentative Meeting]"; ptrEvent->Location = "MSB - Room 204"; //ptrEvent->SetReminderMinutesBeforeStart(10); ptrEvent->BusyStatus = Interop::XtremeCalendarControl::CalendarEventBusyStatus::xtpCalendarBusyStatusTentative; ptrEvent->MeetingFlag = true; pCalendarData->AddEvent(ptrEvent); //Saves events to .xml file: pCalendarData->Save(); CalendarControl->Populate(); } // /////////////////////////////////////////////////////////// private: System::Void CalendarControl_EventChanged(System::Object * sender, AxInterop::XtremeCalendarControl::_DCalendarControlEvents_EventChangedEvent * e) { pCalendarData->Save(); } private: System::Void CalendarControl_EventAdded(System::Object * sender, AxInterop::XtremeCalendarControl::_DCalendarControlEvents_EventAddedEvent * e) { //Saves events to TestEvents.xml file pCalendarData->Save(); } }; } ///////////////////////////////////////////////////////////// |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |