Click here to Skip to main content
15,915,059 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: windows forms Pin
BAIJUMAX1-Oct-04 20:46
professionalBAIJUMAX1-Oct-04 20:46 
GeneralRe: windows forms Pin
BlackDice2-Oct-04 3:11
BlackDice2-Oct-04 3:11 
GeneralCOMCHAT Pin
ursus zeta2-Oct-04 10:38
ursus zeta2-Oct-04 10:38 
GeneralRe: COMCHAT Pin
porac692-Oct-04 11:14
porac692-Oct-04 11:14 
GeneralRe: COMCHAT Pin
ursus zeta4-Oct-04 10:19
ursus zeta4-Oct-04 10:19 
Generalmanaged string arrays Pin
gazmundo1-Oct-04 0:53
gazmundo1-Oct-04 0:53 
GeneralRe: managed string arrays Pin
BAIJUMAX1-Oct-04 2:33
professionalBAIJUMAX1-Oct-04 2:33 
GeneralRe: managed string arrays Pin
gazmundo1-Oct-04 3:02
gazmundo1-Oct-04 3:02 
The two .h and two .cpp files I created for a quick test are copied below. The main form just contains one button and one textbox - used to try and display the returned string from the 'Test' function in the other.cpp file.

Thanks
Gazmundo

Form1.cpp******************************************************
#include "stdafx.h"<br />
#include "Form1.h"<br />
#include <windows.h><br />
#include "other.h"<br />
<br />
using namespace arrtest;<br />
<br />
int APIENTRY _tWinMain(HINSTANCE hInstance,<br />
                     HINSTANCE hPrevInstance,<br />
                     LPTSTR    lpCmdLine,<br />
                     int       nCmdShow)<br />
{<br />
	System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;<br />
	Application::Run(new Form1());<br />
	return 0;<br />
}<br />
<br />
System::Void Form1::button1_Click(System::Object *  sender, System::EventArgs *  e)<br />
{<br />
	String* tmp;<br />
	tmp = Test(counter);<br />
	textBox1->Text = tmp;<br />
	//String* fast_segments[] = {S"AA", S"BB", S"CC"};//incluing declaration here and commenting<br />
	//textBox1->Text = fast_segments[counter];		  //out previous three lines works OK<br />
	counter++;<br />
	if(counter>2)<br />
	{<br />
		counter =0;<br />
	}<br />
}

***************************************************************
Form1.h********************************************************
#pragma once<br />
<br />
<br />
namespace arrtest<br />
{<br />
	using namespace System;<br />
	using namespace System::ComponentModel;<br />
	using namespace System::Collections;<br />
	using namespace System::Windows::Forms;<br />
	using namespace System::Data;<br />
	using namespace System::Drawing;<br />
//	using namespace arrtest;<br />
<br />
	/// <summary> <br />
	/// Summary for Form1<br />
	///<br />
	/// WARNING: If you change the name of this class, you will need to change the <br />
	///          'Resource File Name' property for the managed resource compiler tool <br />
	///          associated with all .resx files this class depends on.  Otherwise,<br />
	///          the designers will not be able to interact properly with localized<br />
	///          resources associated with this form.<br />
	/// </summary><br />
	public __gc class Form1 : public System::Windows::Forms::Form<br />
	{	<br />
	public:<br />
		Form1(void)<br />
		{<br />
			InitializeComponent();<br />
			counter=0;<br />
		}<br />
		Int32 counter;<br />
  <br />
	protected:<br />
		void Dispose(Boolean disposing)<br />
		{<br />
			if (disposing && components)<br />
			{<br />
				components->Dispose();<br />
			}<br />
			__super::Dispose(disposing);<br />
		}<br />
	private: System::Windows::Forms::TextBox *  textBox1;<br />
	private: System::Windows::Forms::Button *  button1;<br />
<br />
	private:<br />
		/// <summary><br />
		/// Required designer variable.<br />
		/// </summary><br />
		System::ComponentModel::Container * components;<br />
<br />
		/// <summary><br />
		/// Required method for Designer support - do not modify<br />
		/// the contents of this method with the code editor.<br />
		/// </summary><br />
		void InitializeComponent(void)<br />
		{<br />
			this->textBox1 = new System::Windows::Forms::TextBox();<br />
			this->button1 = new System::Windows::Forms::Button();<br />
			this->SuspendLayout();<br />
			// <br />
			// textBox1<br />
			// <br />
			this->textBox1->Location = System::Drawing::Point(96, 168);<br />
			this->textBox1->Name = S"textBox1";<br />
			this->textBox1->TabIndex = 0;<br />
			this->textBox1->Text = S"textBox1";<br />
			// <br />
			// button1<br />
			// <br />
			this->button1->Location = System::Drawing::Point(128, 72);<br />
			this->button1->Name = S"button1";<br />
			this->button1->TabIndex = 1;<br />
			this->button1->Text = S"button1";<br />
			this->button1->Click += new System::EventHandler(this, button1_Click);<br />
			// <br />
			// Form1<br />
			// <br />
			this->AutoScaleBaseSize = System::Drawing::Size(5, 13);<br />
			this->ClientSize = System::Drawing::Size(292, 273);<br />
			this->Controls->Add(this->button1);<br />
			this->Controls->Add(this->textBox1);<br />
			this->Name = S"Form1";<br />
			this->Text = S"Form1";<br />
			this->ResumeLayout(false);<br />
<br />
		}	<br />
		private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e);<br />
<br />
	};<br />
}

***************************************************************
other.cpp******************************************************
#include "stdafx.h"<br />
#include "other.h"<br />
<br />
using namespace arrtest;<br />
using namespace System;<br />
<br />
System::String * arrtest::Test(Int32 value)<br />
{<br />
	String* fast_segments[] = {S"AA", S"BB", S"CC"};//including this causes linker error<br />
	return (fast_segments[value]);<br />
}

***************************************************************
other.h********************************************************
#pragma once<br />
<br />
namespace arrtest<br />
{<br />
	using namespace System;<br />
	System::String * Test(Int32 value);<br />
<br />
}

***************************************************************
GeneralRe: managed string arrays Pin
BAIJUMAX1-Oct-04 3:47
professionalBAIJUMAX1-Oct-04 3:47 
GeneralStdafx.h and the C1010 and C1034 errors Pin
NietzscheDisciple30-Sep-04 17:45
NietzscheDisciple30-Sep-04 17:45 
GeneralCounting enums in Builder Pin
UKSparky27-Sep-04 5:52
UKSparky27-Sep-04 5:52 
GeneralRe: Counting enums in Builder Pin
Christian Graus28-Sep-04 11:55
protectorChristian Graus28-Sep-04 11:55 
Generalusing MFC in c++/cli Pin
aaa_avraham25-Sep-04 9:14
aaa_avraham25-Sep-04 9:14 
GeneralRe: using MFC in c++/cli Pin
BAIJUMAX25-Sep-04 20:51
professionalBAIJUMAX25-Sep-04 20:51 
GeneralSystem::Object _gc * _gc * Pin
Mirdous25-Sep-04 1:45
Mirdous25-Sep-04 1:45 
GeneralRe: System::Object _gc * _gc * Pin
BAIJUMAX25-Sep-04 20:54
professionalBAIJUMAX25-Sep-04 20:54 
GeneralOPC Automation Pin
Anonymous23-Sep-04 3:47
Anonymous23-Sep-04 3:47 
GeneralNewbie: Undeclared Identifier Pin
jblau22-Sep-04 13:22
jblau22-Sep-04 13:22 
GeneralRe: Newbie: Undeclared Identifier Pin
AnsGe26-Sep-04 19:01
AnsGe26-Sep-04 19:01 
Generalwrapper for C dll - newbie Pin
nina80222-Sep-04 13:14
nina80222-Sep-04 13:14 
GeneralRe: wrapper for C dll - newbie Pin
BAIJUMAX22-Sep-04 20:56
professionalBAIJUMAX22-Sep-04 20:56 
GeneralRe: wrapper for C dll - newbie Pin
nina80229-Sep-04 10:58
nina80229-Sep-04 10:58 
GeneralSTL in a C++ managed DLL Pin
Anonymous21-Sep-04 9:55
Anonymous21-Sep-04 9:55 
GeneralRe: STL in a C++ managed DLL Pin
George L. Jackson1-Oct-04 19:24
George L. Jackson1-Oct-04 19:24 
GeneralConversion problems.Please help Pin
benibo21-Sep-04 9:08
benibo21-Sep-04 9:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.