usercontrol question (C++)
From: Dave (Dls5678_at_community.nospam)
Date: 11/02/04
- Next message: Lee: "Re: Design time "extras""
- Previous message: johndoe_at_driver.net: "Re: Framework 1.0 SP3 eventproblem"
- Next in thread: Claes Bergefall: "Re: usercontrol question (C++)"
- Reply: Claes Bergefall: "Re: usercontrol question (C++)"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 2 Nov 2004 12:03:21 -0500
Just trying to learn how to create a usercontrol. I created a new Windows
Control Library (.NET) project and put in a status bar with a couple of
panels. Then display the time in one of the panels using a timer control to
trigger the update. I was trying to enter in some user defined properties
for the control and have some trouble understanding where to do it.
Where should I be declaring the private variables for properties? Declaring
tFormat, my variable used to determine how the time is presented in the
panel, where I have it doesn't seem right. I can only declare it there as
static.
Also I receive this error when building the control project? What is the
libc.pdb?
dlsTest warning LNK4099: PDB 'libc.pdb' was not found with 'C:\Program
Files\Microsoft Visual Studio .NET 2003\Vc7\lib\nochkclr.obj' or at
'C:\Documents and Settings\Sterling\My Documents\Programming Files\C++\User
Controls\dlsTest\Debug\libc.pdb'; linking object as if no debug info
I've included the code below. Thanks in advance for your help.
Dave
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace dlsTest
{
/// <summary>
/// Summary for dlsTestControl
/// </summary>
///
/// 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.
public __gc class dlsTestControl : public
System::Windows::Forms::UserControl
{
public:
dlsTestControl(void)
{
InitializeComponent();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::StatusBar * statusBar1;
private: System::Windows::Forms::StatusBarPanel * sbpTime;
private: System::Windows::Forms::Timer * tClock;
private: System::Windows::Forms::StatusBarPanel * sbpDate;
private: System::Windows::Forms::Timer * tDate;
public: System::Windows::Forms::StatusBarPanel * sbpText;
private: System::ComponentModel::IContainer * components;
private: static int tFormat = 1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = new System::ComponentModel::Container();
this->statusBar1 = new System::Windows::Forms::StatusBar();
this->sbpTime = new System::Windows::Forms::StatusBarPanel();
this->sbpDate = new System::Windows::Forms::StatusBarPanel();
this->tClock = new System::Windows::Forms::Timer(this->components);
this->tDate = new System::Windows::Forms::Timer(this->components);
this->sbpText = new System::Windows::Forms::StatusBarPanel();
(__try_cast<System::ComponentModel::ISupportInitialize *
>(this->sbpTime))->BeginInit();
(__try_cast<System::ComponentModel::ISupportInitialize *
>(this->sbpDate))->BeginInit();
(__try_cast<System::ComponentModel::ISupportInitialize *
>(this->sbpText))->BeginInit();
this->SuspendLayout();
//
// statusBar1
//
this->statusBar1->Location = System::Drawing::Point(0, 126);
this->statusBar1->Name = S"statusBar1";
System::Windows::Forms::StatusBarPanel* __mcTemp__1[] = new
System::Windows::Forms::StatusBarPanel*[3];
__mcTemp__1[0] = this->sbpTime;
__mcTemp__1[1] = this->sbpDate;
__mcTemp__1[2] = this->sbpText;
this->statusBar1->Panels->AddRange(__mcTemp__1);
this->statusBar1->ShowPanels = true;
this->statusBar1->Size = System::Drawing::Size(150, 24);
this->statusBar1->TabIndex = 0;
//
// sbpTime
//
this->sbpTime->Alignment =
System::Windows::Forms::HorizontalAlignment::Center;
this->sbpTime->AutoSize =
System::Windows::Forms::StatusBarPanelAutoSize::Contents;
this->sbpTime->Width = 10;
//
// sbpDate
//
this->sbpDate->Alignment =
System::Windows::Forms::HorizontalAlignment::Center;
this->sbpDate->AutoSize =
System::Windows::Forms::StatusBarPanelAutoSize::Contents;
this->sbpDate->Width = 10;
//
// tClock
//
this->tClock->Enabled = true;
this->tClock->Interval = 1000;
this->tClock->Tick += new System::EventHandler(this, tClock_Tick);
//
// tDate
//
this->tDate->Enabled = true;
this->tDate->Interval = 60000;
this->tDate->Tick += new System::EventHandler(this, tDate_Tick);
//
// sbpText
//
this->sbpText->AutoSize =
System::Windows::Forms::StatusBarPanelAutoSize::Spring;
this->sbpText->Width = 114;
//
// dlsTestControl
//
this->Controls->Add(this->statusBar1);
this->Name = S"dlsTestControl";
(__try_cast<System::ComponentModel::ISupportInitialize *
>(this->sbpTime))->EndInit();
(__try_cast<System::ComponentModel::ISupportInitialize *
>(this->sbpDate))->EndInit();
(__try_cast<System::ComponentModel::ISupportInitialize *
>(this->sbpText))->EndInit();
this->ResumeLayout(false);
}
private: System::Void tClock_Tick(System::Object * sender, System::EventArgs
* e)
{
bool static init;
if ( !init ){
sbpDate->Text = System::DateTime::Now.ToShortDateString();
init = false;
}
if ( tFormat == 1 ){
sbpTime->Text = System::DateTime::Now.ToLongTimeString();
} else {
sbpTime->Text = System::DateTime::Now.ToShortTimeString();
}
}
private: System::Void tDate_Tick(System::Object * sender, System::EventArgs
* e)
{
sbpDate->Text = System::DateTime::Now.ToLongDateString();
}
public: void timeFormat( int tFormat )
{
this->tFormat = tFormat;
}
};
}
- Next message: Lee: "Re: Design time "extras""
- Previous message: johndoe_at_driver.net: "Re: Framework 1.0 SP3 eventproblem"
- Next in thread: Claes Bergefall: "Re: usercontrol question (C++)"
- Reply: Claes Bergefall: "Re: usercontrol question (C++)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|