-
January 27th, 2011, 09:40 PM
#1
Make a copy of a serial port handle to local class var
Hi
I’m trying to pass a handle to a serial port class to a form that will configure the serial port.
I can pass a handle to the constructor and it works fine/as I expect inside the constructor but I need a local copy of the handle that points to the port I can use after the constructor is finished by combobox events.
I can declare a local serial port class var.
I can copy of the original serial port’s class data but I want a handle to the original not a copy of its data.
public ref class Config_Serial_Port_Form : public System::Windows::Forms::Form
{
public:
Config_Serial_Port_Form(System::IO::Ports::SerialPort^% initport)
{
initport->BaudRate = 600; //this accesses the correct port
theport = initport; //this only copies all the original to the local object
//I need theport to be a pointer
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
void domystuff(void)
{
port_stuff^ port_stuff_ptr;
port_stuff_ptr = gcnew port_stuff();
this->Baud_Rate_comboBox->Text = port_stuff_ptr->BaudRate_to_string(theport);
this->Parity_comboBox->Text = port_stuff_ptr->Parity_to_string(theport);
this->handshakingcomboBox->Text = port_stuff_ptr->Handshake_to_string(theport);
this->databitscomboBox->Text = port_stuff_ptr->DataBits_to_string(theport);
if (theport->IsOpen)
this->portselectcomboBox->Text = theport->PortName;
this->portselectcomboBox->Items->AddRange(theport->GetPortNames());
this->portselectcomboBox->Items->Add("COM4");
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Config_Serial_Port_Form()
{
if (components)
{
delete components;
}
}
private: System::IO::Ports::SerialPort^ theport; /// this gives me a second object not a handle to the original.
-
January 28th, 2011, 04:20 AM
#2
Re: Make a copy of a serial port handle to local class var
Wrong forum. Your code looks like a managed C++, not a native VC++ one.
Victor Nijegorodov
-
January 28th, 2011, 11:39 AM
#3
Re: Make a copy of a serial port handle to local class var
Originally Posted by gpsdude
Where is the freakin edit button?????
It is to the left of the Quote button.
Victor Nijegorodov
-
January 28th, 2011, 11:49 AM
#4
Re: Make a copy of a serial port handle to local class var
I guess it appears only after 5 posts...
Victor Nijegorodov
-
January 28th, 2011, 11:56 AM
#5
Re: Make a copy of a serial port handle to local class var
Hi Victor
After the edit button finally poped up I was able to delete the follow on messages but not the original message in the thread.
I moved it to managed C++ as you suggested.
Can the SYS op delete this thread for me??
Last edited by gpsdude; January 28th, 2011 at 12:01 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|