|
There is a post at the top in red text explaining what this forum is for. But people don't manage to see (++) that.
|
|
|
|
|
Hi guys,
here is my problem I have defined a list of managed objects in MyClass.h:
<br />
class MyClass.h<br />
{<br />
public:<br />
MyClass();<br />
gcroot<List<MessageListener^>^> messageListeners;<br />
}<br />
and using the list in the .cpp file
<br />
MyClass::MyClass()<br />
{<br />
messageListeners = gcnew List<MessageListener^>();<br />
}<br />
void MyClass::addMessageListener(u_short id,u_short version)<br />
{<br />
MessageListener^ msgl = gcnew MessageListener(id,version);<br />
messageListeners->Add(msgl);<br />
}<br />
...as you can see I'm trying to use a list of managed objects in an unmanaged class.
My problem is than I can't access the objects in the list
<br />
void MyClass::findMessageListener(u_short id,u_short version)<br />
{<br />
<br />
for(int i = 0;i<messageListeners->Count;i++)<br />
{<br />
MessageListener^ msg = messageListeners[i];<br />
if(msg->id == id && msg->version == version)<br />
{<br />
return msg;<br />
}<br />
}<br />
return nullptr;<br />
}<br />
I would like to have some comments on how this can be done.
Thx
|
|
|
|
|
kristmun wrote: gcroot<List<MessageListener^>^> messageListeners;
kristmun wrote: MessageListener^ msg = messageListeners[i];
"messageListeners" is a gcroot template instance and does not have an operator []. You need to use the conversion operator ( operator T ) to get at the CLR List object before you can get to the indexer ([]).
MessageListener^ msg = ((List<MessageListener^>^)messageListeners)[i];
led mike
|
|
|
|
|
Works like a charm!
Thanks Mike
|
|
|
|
|
Hello,
In MFC's CRichEditCtrl , I could set paragraph spacing (before and after) by using PARAFORMAT2 . Is there a possibility of achieving the same functionality with .NET 2.0 RichTextBox in C++/CLI ?
I've seen several enormous hacks on using PARAFORMAT2 in C# , but I believe it could be done more elegant in C++/CLI (using raw /clr , without safe or pure enforcement).
Or perhaps is there a more convenient method to format paragraph spacing without using native calls?
|
|
|
|
|
Hello!
I'm trying to translate some codes from Verilog to C++ using Verilator.
As I could see, there are not many materials to search about it, and I'm getting a lot of errors during this process.
Anyone that works with or at least Verilog (VHDL) could help me?
Thanks a lot!
|
|
|
|
|
I think you're in the wrong forum, this is for C++/CLI, I think you want Visual c++.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Christian,
We need to change the name of this forum to "This Is not the Visual C++ Forum".
Hmm. Never mind! If we did that, we will get an increase of unrelated posts. 
|
|
|
|
|
I suspect a lot of people see 'visual c++' and assume MFC, and have no idea what 'managed' or 'CLI' means, so they just ignore it.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Dear all
My company has a fax server pool that contains 16 faxes cards. We are using the HylaFax software http://www.hylafax.org/content/Main_Page[^] Which written in C language.
Now that software is good in that when a fax is coming, it transfer it to the correct card (tha card that is specified for the recipt)... But, when we send a fax, it handles tha job to the next available card in the Queu (not nesesarly to be the card that is specified for the sender).
If anybody knows how to enhance this software so it sends the fax correctly(using the sender card) I will appreciate his/her help.
Or if you have an alternative solution that not expensive to use. I will also appreciate that.
Best Regards
|
|
|
|
|
mhmo wrote: Which written in C language.
Then you can't possibly modify it using C++/CLI. If you want to know how to change this code, your best bet is the Visual C++ forum, although even that is a long shot. You probalby want forums dedicated to users of this particular software.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I am using visual c++ 6.0. I wish to use the COleVariant::GetByteArrayFromVariantArray member function
but the compiler generates error message : GetByteArrayFromVariantArray is not a member function of COleVariant. Why could this happen?? Is this function available only in VC++ 2005??
Is there any way to retrieve a byte array from variant array??
Thanks. I will appreciate any help from you.
|
|
|
|
|
weehau wrote: I am using visual c++ 6.0
Then you're plainly not using C++/CLI. Try the Visual C++ forum.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I am trying to write an app which requires me to convert a String^ to a WCHAR but not having much luck with a resolution.
Can anyone point out where I am going wrong ?
I'm using Visual Studio 2005 and it's a console application.
Pete
|
|
|
|
|
Fritzables wrote: Can anyone point out where I am going wrong ?
Just a guess but you are not using the documentation, examples and samples found on msdn.microsoft.com.
led mike
|
|
|
|
|
G'Day led mike,
Well, ya could be right despite the fact I have tried a number of times creating different search strings in the hope I may find something that steers me in the right direction.
I am pretty new to C++ as I have recently come across from using Borland's Delphi, so I will use that as my excuse.
Pete
|
|
|
|
|
Fritzables wrote: despite the fact I have tried a number of times creating different search strings
That is easy to believe. Keep at it though. Developing the "skill" to find information is a critical skill in our field. If this helps at all, I use Google to do my searching and when I expect that MSDN will contain the information I seek I put "MSDN" as the first keyword in the Google search phrase. I find that Google provides much better results than the MSDN search engine. But that's just me.
Anyway using your question as an example my Google search string would be
MSDN System.String convert WCHAR
Try it out.
led mike
|
|
|
|
|
I hope this example helps:
#include <iostream>
using namespace System;
using namespace System::Runtime::InteropServices;
int main(array<System::String ^> ^args)
{
String ^gcString = L"Hello, World!";
IntPtr intptr = IntPtr::Zero;
try
{
intptr = Marshal::StringToHGlobalUni(gcString);
const wchar_t *hgString =
static_cast<const wchar_t*>(intptr.ToPointer());
std::wcout << hgString << std::endl;
}
catch (Exception ^e)
{
Console::WriteLine(e->Message);
}
finally
{
if (intptr != IntPtr::Zero)
{
Marshal::FreeHGlobal(intptr);
}
}
return 0;
}
-- modified at 19:20 Wednesday 29th November, 2006
|
|
|
|
|
I use this easy way, but it is not recommended for large strings.
String ^s = "Hello world";<br />
CString str = s;<br />
WCHAR *w = str.GetBuffer();<br />
WCHAR *myChar = new WCHAR[str.GetLength() +1];<br />
memcpy(myChar,w,str.GetLength()*sizeof(WCHAR));<br />
myChar[str.GetLength()] = '\0';<br />
<br />
AfxMessageBox(myChar);
|
|
|
|
|
Thanks all for the help on this one - much appreciated.
Fritzables.
|
|
|
|
|
Can anyone tell me the difference between Storage Class and Storage Class Specifier?
Thanks and Regards
Kenny
|
|
|
|
|
In C++, the storage class specifiers auto, static, register, extern, and mutable. The storage class specifiers explicitly determine the storage class of a variable. Thus, the storage class specifier, auto, lets you define a variable with automatic storage (storage class). However, you will also hear: auto storage class. So, storage class and storage class specifier may be used to mean the same thing.
|
|
|
|
|
i need creating a database myself,i need make a database from scratch , can u give me some help please?
ert
|
|
|
|
|
According to your profile, you program with C++ and not C++/CLI. Also, your plea for help does not give me enough information to assist you. What are your requirements? Here is an example of how your plea for help sounds to me:
I need to create a vehicle from scratch? Can you help me?
|
|
|
|
|
George L. Jackson wrote: Here is an example of how your plea for help sounds to me:
I need to create a vehicle from scratch? Can you help me?
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|