|
Nope, I am sugesting these are things you can try yourself
|
|
|
|
|
---CODE---
// Split Test: String::Split does NOT work properly when given a # of substrings to return
void splitTest() {
String^ toBeSplit = "a b c d e f g h";
array<String^>^ split = toBeSplit->Split(' ',3);
//Expected: "Count: 3" Actual "Count: 8"
Console::WriteLine("Count: {0}",split->Length);
}
---END CODE---
Am I doing something ridiculously stupid, or is this really a bug?
The equivilent C# code works properly.
|
|
|
|
|
jmlsteele wrote: toBeSplit->Split(' ',3);
I don't know how you got that to compile but the following works as expected
array<wchar_t>^ delim = gcnew array<wchar_t> {' '};
String^ src = "1 2 3 4 5";
array<String^>^ a1 = src->Split( delim);
Console::WriteLine( String::Format("{0}", a1->Length));
a1 = src->Split( delim, 2);
Console::WriteLine( String::Format("{0}", a1->Length));
led mike
|
|
|
|
|
I get no errors, and no warnings when compiling what I posted, and upon further inspection I realise why.
The first entry you get for intellisense is Split(... cli::array<__wchar_t,1> ^seperator) so it's just converting my 3 into a wchar_t.
Now I feel stupid...
Thanks for your help.
|
|
|
|
|
Hello,
I need to use COM server in VC++ .NET 2003 managed application. Tlbimp.exe was used to generate runtime callable wrapper. After that I was able to use this com server in single threaded VC++.NET managed code. What do I need to do to use it in secondary thread? How to pass a pointer to COM interface in to the second thread?
In regular unmanaged code I need to have IStream* and call CoMarshalInterThreadInterfaceInStream(…) in the main thread and CoGetInterfaceAndReleaseStream(…) in the second thread.
What do I need to do to marshal wrapper for this COM interface from one thread to another in managed C++ before this code:
pThreadDelegate = new ThreadStart(0, &ThreadWork::DoSomething);
pThread = new Thread(pThreadDelegate);
pThread->Start();
and inside method DoSomething() of ThreadWork class?
Please help!!!!!!!!!!!!
Regards,
Leonid
|
|
|
|
|
Hello friends,
I have an appication of recording a wave file.
But i want to specify the sound device through which only
the wave file should be recorded. That is if my machine has more than one sound card
then i want to select one (through Programmatically) and record sound from that one only.
How to do that.
Thanks in Advance.
Rahul Kulkarni
|
|
|
|
|
I'm working with managed C++ in VS 2005 and am communicating with a MS Access 2003 databse using the primary interop assemblies. I'm importing and exporting text files to/from the database and I want to apply a format specifcation to them. However, instead of defining a specification in the database itself, I'd like to apply one on-the-fly so my application is not dependant on using a specific database. I've tried using a schema.ini file, but it isn't working for me (I placed it in the same directory as the source/destination text file) and I think that it's because I am not using VBA. However, I could be wrong. I also thought that I might be able to include a "static" or non-growing database in the executable, but I don't know where to start. In any case, I'm looking for possible ideas/solutions and a shove in the correct direction. I'd be grateful for any help.
Thanks
|
|
|
|
|
Sir,
I want to connect the database(Sql Server) to vc++.net programically.I also want to use insert delete update queries in the form .Please help me or please send any link for the problem.
Thanks.
www.codeproject.com/database[^]
the link contains only the connection strings
Please help.
Thanks
|
|
|
|
|
Do you want to know how to do this in C++/CLI, or are you asking in the wrong forum ?
It looks to me like you're asking in the wrong forums, and that you need to go back to that link and really look at all the stuff on offer there.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sir,
I want to connect the database(Sql Server) to vc++.net programically.I also want to use insert delete update queries in the form .Please help me or please send any link for the problem.
Thanks.
www.codeproject.com/database[^]
the link contains only the connection strings
Please help.
Thanks
|
|
|
|
|
amaneet wrote: the link contains only the connection strings
Wrong. Between the articles on that link, and the articles in MSDN, you really shouldn't have any trouble.
But you're still posting in the wrong forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If I write this...
Managed c++..
template<typename T>
public ref class SomeTemplate
{
public:
SomeTemplate();
void Test(void)
{
}
};
public ref class ManagedCppClassToUseFromCSharp
{
public:
SomeTemplate<System::Int32> aMember;
};
Then in c# client
ManagedCppClassToUseFromCSharp test = new ManagedCppClassToUseFromCSharp();
test does not contain a member called aMember
However if I do this...
template<typename T>
public ref class SomeTemplate
{
public:
SomeTemplate();
void Test(void)
{
}
};
public ref SomeTemplateInt : public SomeTemplate<System::Int32>
{
public:
SomeTemplateInt();
}
public ref class ManagedCppClassToUseFromCSharp
{
public:
SomeTemplateInt aMember;
};
Now I can access aMember from c#. Anyone know why and if there is a way to get around having to declare different classes derived from my template?
|
|
|
|
|
Josh, not having any direct experience myself but drawing only on memory of what I have read (whew)... since you are using C++ templates to define SomeTemplate rather than .NET generics any instance of it is a "native" type and cannot therefore be exposed through the CTS for C#.
SomeTemplate<System::Int32> aMember;
is a native member declaration NOT a managed type declaration.
led mike
|
|
|
|
|
Hello,
The template does produce a managed type as it is declared as
template<typename t="">
public ref class
{
}
the ref keyword makes it a managed type. In the second example from my original post the class derived from the template is also a managed class and the member of that type can be accessed frmo the c# client. The template must produce a managed class as you cant derive a managed class from a non-managed one.
|
|
|
|
|
Previous attempt to post this code screwed the code all up... let's try again.
namespace Library1 {
generic <typename T>
public ref class TWhat
{
T _what;
public:
property T What
{
void set(T value){ _what=value;}
T get(){ return _what;}
}
};
public ref class ManagedCppClassToUseFromCSharp
{
private:
TWhat<System::Int32>^ _twhat;
public:
ManagedCppClassToUseFromCSharp(){ _twhat = gcnew TWhat<System::Int32>(); }
TWhat<System::Int32>^ GetWhat(){return _twhat; }
};
}
and the C# code:
InitializeComponent();
Library1.ManagedCppClassToUseFromCSharp mcctuf = new ManagedCppClassToUseFromCSharp();
TWhat<System.Int32> tw = mcctuf.GetWhat();
tw.What = 11;
System.Diagnostics.Trace.WriteLine(String.Format("TWhat: {0}", tw.What));
led mike
|
|
|
|
|
Thanks mate, Ill give it a shot
|
|
|
|
|
Let me know how it goes ok?
"When your argument falls apart...resort to name-calling." Red Stateler aka (D)espeir in the Soapbox
Whereas "liberal" is just a moron. Red Stateler aka (D)espeir in the Soapbox
led mike
|
|
|
|
|
Changing the template to be a generic causes all sorts of compilation errors.
I get lots of
C3229 indirections on a generic type parameter are not allowed
C3231 template type argument cannot use a generic type parameter
This is the first few lines of the template that produce a lot of these errors
template<typename rawtype,="" typename="" managedtype="">
public ref class BoostEventAdapter
{
public:
delegate void EventDelegate(ManagedType^);
BoostEventAdapter(boost::function<void (rawtype&)=""> &boostEvent): mBoostEvent(boostEvent) {}
};
Using the template by deriving empty classes from it as I described in the first post seems to be the best way for me to go
|
|
|
|
|
How CreateDIBSection To Work For
Picture Screen On Desktop.
|
|
|
|
|
CreateDIBSection works when you call the API. If you want the desktop in a DIBSEction, you need to capture it, and copy it on to a DIBSection. That's fine, the desktop will always be a DDB, anyhow.
You've also asked this in the managed C++ forum, CreateDIBSEction is not a C++/CLI API, so this belongs in the Visual C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
now,I want to learn C++/CLI, somebody would introduce a e-book for me?
(I have lern C++ before)
Thanks
|
|
|
|
|
|
|
Thanks ,and would you like to introduce a book about it to me?
|
|
|
|
|
When Nishes book is published, it will be your best bet. I say wait for it, and use web based resources in the meantime.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|