|
Hi,
if U are Using MFC, check setHotItem(int iIndx)
by
baijumax
|
|
|
|
|
I am using Visual Studio.net 2003; and I don't see anything that looks like setHotItem.
???
|
|
|
|
|
Hai,
u can simply solve the problem by selecting the last item.
ie
this->listBox1->SelectedIndex=this->listBox1->Items->Count-1;;
ANish
|
|
|
|
|
|
I've added a new windows form to my project and I have no idea how to display the form. I have books with examples, but they only work if the form is the main form of the app. This is a mixed-mode app and I'm just doing a test to get familiar with windows forms. I have #included the header file for the form and in the menu's event handler, I have done this:
#pragma push_macro("new")
#undef new
CTestForm* dlg = new CTestForm();
dlg->ShowDialog();
#pragma pop_macro("new")
Can anyone help me out here? Thanks in advance
[insert witty comment here]
bdiamond
|
|
|
|
|
Hi,
The Following Links May Help You.
1) http://www.codeproject.com/useritems/Windows_Forms_in_MC__.asp
2)
http://www.developer.com/net/net/article.php/1378751
3)http://www.codeguru.com/columns/Kate/article.php/c6585/
|
|
|
|
|
thanks!!
[insert witty comment here]
bdiamond
|
|
|
|
|
..not really sure why this is in the Managed C++ forum,...but,...
I have been reading Don Box's book: "Essential COM". He has a code section in the back where he provides a server/client Chat application. It's all C++, and is written as an example of how to create a COM server/client app. It may help you (or, maybe not).
http://www.awprofessional.com/content/images/0201634465/sourcecode/COMCHAT.zip[^]
This is probably like 'cheating'.
|
|
|
|
|
thanx alot for your concern!
my main problem is not the code, its trying to arrange a graphical interface for my "chat program" with borland.
i dont know how to do that and i dont know if borland 5.01 enables me to.
well, thanx alot once again, i appreciate it
|
|
|
|
|
From what I've read, compiler implementations are proprietary, and can be different from vendor to vendor. This is the forum for the Microsoft Visual Studio .NET IDE. Before I used the .NET IDE, I tried messing around with the Borland compiler, and, as I recall, it works completely differently from .NET.
Most importantly, the .NET runtime environment depends on the CLR (Common Language Runtime) which is a proprietary implementation of the CLI (Common Language Infrastructure). As far as I know, the CLR is the only implementation of the CLI on Earth, and so, any code that is specific to .NET would NOT work on the Borland compiler.
|
|
|
|
|
Hi all,
Hope somebody can help clear up an issue I'm experiencing trying to create an array of strings in my code. The line that is causing me all the problems is:
String* tst_str[] = {S"AA", S"BB", S"CC");
Now, when i include this in any of my main form member functions it compiles and links fine, however when I include it in a function in a separate source file (using the same namespace as my main form) I get the following linker error:
error LNK2001: unresolved external symbol "unsigned long const NSpace::$ConstGCArrayBound$0xb8408b96$1$" (?$ConstGCArrayBound$0xb8408b96$1$@NSpace@@3KB)
I have also found that I don't get this error message (even in the second source file) if I create the array first then assign each string to the appropriate position e.g:
String* tst_str = new String*[3];
tst_str[0] = S"AA";
tst_str[1] = S"BB";
tst_str[2] = S"CC";
Can anybody explain why this is happening??? I am reasonably new to this .Net programming so there is a good chance that this is something really simple that I just haven't grasped yet. As far as I can see from the reference books I have, the initial method of assigning the elements on the same line as the variable declaration is valid and will create an array of the appropriate size - but this does not appear to be what is happening?!?!
Any suggestions greatly appreciated
Gazmundo.
|
|
|
|
|
Hi,
I Try To Reproduce Your Problem.But I didn' get any error.First I thought u put bracket instead of curly braces.but it gives compile error not linker error. pl's cut paste the code i mean .h and .cpp file.
by
baijumax
|
|
|
|
|
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 />
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 />
<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 />
System::ComponentModel::Container * components;<br />
<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 />
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 />
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 />
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"};
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 />
}
***************************************************************
|
|
|
|
|
Hi,
i Checked U R Test.cpp And Test.h files still i didn't get u r problem.but i wrote code for u check it out that may help u.
------------------Main App Code----------------
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
#include "TestString.h"
using namespace System;
// This is the entry point for this application
int _tmain(void)
{
CTestString obj; //Test Object
Console::WriteLine( obj.fast_Segments(0));
Console::ReadLine();
return 0;
}
----I wrote class CTestString .
----------------------------------TestString.h------------------------
#pragma once
#using <mscorlib.dll>
using namespace System;
class CTestString
{
public:
CTestString(void);
~CTestString(void);
String* fast_Segments(Int32 nKey);
};
---------------------------------------TestString.cpp---------------------------
#include "StdAfx.h"
#include "teststring.h"
CTestString::CTestString(void)
{
}
CTestString::~CTestString(void)
{
}
String* CTestString::fast_Segments(Int32 nKey)
{
String* ts_str[] = {S"AA",S"BB",S"CC"} ;
return ts_str[nKey];
}
by
baijumax
|
|
|
|
|
I'm attempting to write a managed wrapper interface to a native C++ class such that I can access it from within my C# code.
I'm using Visual Studio .NET 2003 on Windows 2000.
I started a new solution: Visual C++ Projects > Class Library (.NET)
My Stdafx.h file has the following in it:
#pragma once
#define WIN32_LEAN_AND_MEAN
#include
#include
using std::cout; using std::endl;
In the Solution Explorer, under Source Files I have the following:
1. AssemblyInfo.cpp
2. BiquadCode.cpp (native C++ code)
3. DSPWrap.cpp (the wrapper code)
4. Stdafx.cpp
Under Header Files, I have:
1. BiquadCode.h
2. DSPWrap.h
3. resource.h
4. Stdafx.h
I've "included" the Stdafx.h file in the first statement of DSPWrap.cpp.
On a build attempt, the code generated a C1010 error. For the files BiquadCode.cpp and BiquadCode.h, I've now set the precompiled header option as "Not using precompiled headers".
However, this throws a C1034 error
\DSPWrap\DSPWrap\Stdafx.h(9): fatal error C1034: windows.h: no include path set
My questions are as follows:
1. How do I get this code to compile?
2. Where exactly do I need to "include" the Stdafx.h file? Do I need to do it only once in the wrapper code file?
Thanks in advance!
|
|
|
|
|
Does anyone know how to determine at runtime the number of permissible values which an enum variable can assume?
Sparky
|
|
|
|
|
In Managed C++, you can use the static method on the Enum namespace which will give you an array of all the possible values. Just get the count of those values.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I need to wrap a native class for using it in C#
the class contain CString objects.
in old MC++ ver 2003 i write somthing like :
__property String * get_ImageName ()
{
return mBillPopJobParameters-> m_ImageName ;
}
__property void set_ImageName (String * pValue )
{
mBillPopJobParameters-> m_ImageName = pValue;
}
(m_ImageName is a CString.)
and it work ok.
when i try to use it in C++/CLI
property String^ ImageName
{
String^ get()
{
return mPrintSetParameters->m_ImageName ;
}
void set(String^ pValue)
{
mPrintSetParameters-> m_ImageName = pValue;
}
}
i get error that it can not convert from CString to String
any one know how to it right ?
Thanks.
Avraham Cohen.
|
|
|
|
|
Hi,
try This
if u R Accepts System::String _gc*
then (LPCTSTR) YourCString
by
baijumax
|
|
|
|
|
Hello
I am coding an application I do have problem to work with one ActiveX COM. I do not know how to convert
System::String * form structure or char and pass to property (set_Value())function with argument which is type of System::Object _gc * _gc *.
When I call this function in VB.NET works fine and I do not need to do anything to conver string.
Does anybody can help???
Tnx
Mirdous
|
|
|
|
|
Hi,
try this
System::String str1 = _gc new String();
by
baijumax
|
|
|
|
|
I am having problems writing an opc client using managed c++. I using an opcdotnetautomation.dll. When I go to read in a value from the OPC server. I am getting a signature I don't understand for the OPCItem Read method. Thank you in advance for assistance.
myServer = new OPCServerClass();
myServer->Connect(S"KEPware.KEPServerEx.V4",S"machineName");
myGroups = static_cast< OPCGroupsClass *> ( Marshal::CreateWrapperOfType( myServer->OPCGroups, __typeof( OPCGroupsClass ) ) );
vendor_textBox->Text = myServer->VendorInfo;
start_time_textBox->Text = myServer->StartTime.ToString();
current_time_textBox->Text = myServer->CurrentTime.ToString();
Updated_textbox->Text = myServer->LastUpdateTime.ToString();
groups_textBox->Text = myGroups->Count.ToString();
Server_textBox->Text = myServer->ServerName;
major_textBox->Text = myServer->MajorVersion.ToString();
minor_textBox->Text = myServer->MinorVersion.ToString();
build_textBox->Text = myServer->BuildNumber.ToString();
GroupA = myGroups->Add(S"GroupA");
//GroupB = myGroups->Add(S"GroupB");
AItems = GroupA->OPCItems;
item1 = AItems->AddItem(S"Channel_0_User_Defined.Sine.Sine1",1);
item2 = AItems->AddItem(S"Channel_0_User_Defined.Sine.Sine2",1);
item1->Read(OPCDataSource::OPCCache,?,?,?);
|
|
|
|
|
I'm still a rookie, so forgive me if this is simple.
I have a form and in the form's .h file i have the form's regular class stuff, but I have also added another class.
For example:
in my .h file i have something like this:
namespace MyNamespace
{
public __gc class Form1 : public System::Windows::Forms::Form
{
//then i have all of the regular form stuff
//I also have an event handler that is
//like this:
private: System::Void axTws1_tickPrice(System::Object * sender, AxInterop::TWSLib::_DTwsEvents_tickPriceEvent * e)
{
//when this event happens I want to create an
//instance of another class that I have defined
//within this same .h file, which you can see
//below.
//now when i try to do the following, i get an
//error message that states that
//"SymbolObject_Constructor" is an undeclared
//identifier:
SymbolObject_Constructor *tempObject = new SymbolObject_Constructor;
}//end of event handler
};//end of form class
public __gc class SymbolObject_Constructor
{
public: String *Stock_Ticker;
Decimal Bid;
Decimal Ask;
public: SymbolObject_Constructor()
{
Stock_Ticker = S"";
Bid = 0.0;
Ask = 0.0;
}
};//end of SymbolObject class
}//end of namespace
in my .cpp file for this form, i have a void method that creates an instance of the SymbolObject class, and I do it the same way as I attempted in the .h file; but in the .cpp file, I don't get the error message.
Can anyone see what I am doing wrong?
Thanks,
Jody Blau
|
|
|
|
|
Hai
Nothing wrong in ur code.
i also don't know why it happened.
But placing your second class before the Form1 calss will solve the problem.
ie define all your classes before it uses
by
Anisg
|
|
|
|
|
Hi, I have a C dll written using VC6, now I need a wrapper for it so that I can use the managed extension in .NET environment. I read the help page from Visual Studio .NET, they all show the unmananged code are cpp files. Do I need to convert my c dll to cpp before writing the wrapper for it? I notice that when I tried to open a c project from Visual Studio .NET, I accepted the conversion, but there are no stdafx.h and stdafs.cpp. When I wrote a wrapper file which is compiled using /clr and build it, error : D2016: '/YXstdafx.h' and '/clr' command-line options are incompatible. Please help.
Thanks
|
|
|
|