managed C++ & Active-X calendar
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=5193
Printed Date: 22 November 2024 at 3:11pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: managed C++ & Active-X calendar
Posted By: hicus
Subject: managed C++ & Active-X calendar
Date Posted: 02 October 2006 at 3:39pm
Is it possible to use Xtreme CalendarPro Active-X control with mannaged C++? Is there any example code of adding calendar events written in C++ concerning Xtreme CalendarPro Active-X control?
forum_topics.asp?FID=36 -
|
Replies:
Posted By: sserge
Date Posted: 02 October 2006 at 3:54pm
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
|
Posted By: hicus
Date Posted: 05 October 2006 at 12:52pm
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(); }
}; } /////////////////////////////////////////////////////////////
|
|