|
Thanks, I was trying to come up with some sort of sensible code from searching the internet, but nothing seemed to work for me. Basically, I'm working off of what little I know from C# and the small amount of information I can get from my professor after class. It obviously wasn't working well for me.
This is part of a project for school, but my book has absolutely nothing on managed c++. I would take the time to learn C++/cli, but this project is due at the end of the semester, and I have so many other things I'm reading now for classes/personal study/entertainment. I'll get to it eventually, but I have a lot of other things I'm doing now.
|
|
|
|
|
hello,
I am writing an extension to Ms Outlook and I came across this problem. In this extension I'm adding some buttons to Outlook's toolbar and my goal is to display their tooltip texts in Unicode encoding. The problem is that by default it is displayed in ANSI encoding and I have no idea how to change it.
STDMETHODIMP MyExchExtCommands::QueryHelpText(UINT cmdid, ULONG ulFlags,
LPTSTR psz, UINT cch)
{
HRESULT hr = S_FALSE;
if (cmdid == MyCmdid)
{
if (ulFlags == EECQHT_STATUS)
lstrcpyn(psz, "Some status text", cch);
if (ulFlags == EECQHT_TOOLTIP)
lstrcpyn(psz, "Some tooltip text", cch);
hr = S_OK;
}
return hr;
}
In the above piece of code MyExchExtCommands ofcourse inherits from the IExchExtCommands interface and psz is a pointer to buffer to be populated with text to display. And no matter what I pass in that buffer, the text is always displayed in ANSI. Maybe I'm looking in the wrong place? Any help would be appreaciated.
Regards,
pawel
|
|
|
|
|
Welcome to CodeProject.
You might not have noticed the first post in the forum, which always stays on top, by the Site Administrator stating what the subject matter of this forum is for. The C++ / CLI is for managed and mixed-mode C++ programming only
I seems likely that you don't know enough about how Unicode works. Try looking at this article.[^] Then if you have more questions use the Visual C++ MFC forum since your subject is not related to managed or mixed mode development in C++/CLI.
led mike
|
|
|
|
|
Thank You for help and sorry for my mistake.
Regards,
pawel
|
|
|
|
|
Hi all, can anyone explain to me what is stack semantics?
Thanks in advance!
VBDT
|
|
|
|
|
In native C++, you can allocate objects on the stack or on the heap:
void somefunction()
{
ifstream *infile = new ifstream(...);
}
void somefunction()
{
ifstream infile(...);
}
You can use these same semantics for most managed types:
void somefunction()
{
FileStream ^filestream = gcnew FileStream(...);
}
void somefunction()
{
FileStream stacksemanticsfilestream(...);
}
Just like an automatic variable in native C++, the managed stack-semantics
object's destructor will be called automatically when the variable goes out
of scope.
More detatils here: C++ Stack Semantics for Reference Types[^]
|
|
|
|
|
Mark, thanks again for your response, examples and the link! So what I understand so fare about stack semantics is that it is a way of creating an object that is the same as in native C++, creating objects in the stack. As I can guess from the name “stack semantics” stands for STACK LOGIC. Is this right?
Also what confuse me the most is that if the object type is referenced than what I read in these two days is that the referenced objects always are created in the heap so using stack semantics is suggesting that they are created in the stack. But it contradicts with reference objects created in the heap.
|
|
|
|
|
VBDT wrote: So what I understand so fare about stack semantics is that it is a way of creating an object that is the same as in native C++, creating objects in the stack. As I can guess from the name “stack semantics” stands for STACK LOGIC. Is this right?
No. "Semantics" in this case means the code just looks like a
native C++ stack allocation. Ref objects can only be allocated on
the managed heap. The stack semantics are just a more native-C++ way
of coding local, short-lived objects.
Essentially, this:
{
FileStream filestream(...);
...
}
is the same as this:
{
FileStream ^filestream = gcnew FileStream(...);
...
delete filestream;
}
In both cases above, the object is allocated using gcnew,
and when the object goes out of scope, the class destructor
is called. The difference is, the compiler adds those gcnew/delete
calls for you when you use stack semantics.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ah, thanks a lot Mark for your patience and the help. It is clear for me now!!!
|
|
|
|
|
please guide I create an application and from this application can created file.exe in vc++6.0. thank you very much
|
|
|
|
|
Hello to everyone, I am trying to get to know C++/CLI and I have some questions. Just to let you know I have VB.Net background and I also have taken some C++ classes some years before. I hope someone can shade a light on my questions. Here it goes:
First, what is exactly the deference between the reference class and the value class? I mean why we need to declare the “ref” or “value” classes if we pass the arguments as ref or value in VB.Net. It is a little bit confusing for me to have a type as referenced and value.
Second, what is this [int main(array<System::String ^> ^args)] line representing? My guess is that the argument is a string array and it may contain the command line for this app passed when the app starts. Is this right?
Also I have a question about “^”. What I read from MSDN the symbol “^” directs the compiler to create handle for the object in the managed garbagecollecter heap so that it can be cleaned when there are no references to this object. Is this right? And also why they are two on that line? I mean one is not enough having it in front of “args”? Is it because the string data type is an array of chars in C++ and it its self should have a handle in the heap? Is this correct?
The questions may be very simple but I tried to get the answers on MSDN and still they are confusing for me. I would appreciate for any help.
Thanks in advance,
VBDT
|
|
|
|
|
VBDT wrote: what is exactly the deference between the reference class and the value class?
A C++ value class/struct is the equivalent of a VB.NET Structure.
A C++ ref class/struct is the equivalent of a VB.NET Class.
The value and ref differentiation in C++/CLI is necessary because
class and struct have different meanings in C++ than they do in
other .NET languages like C# and VB.NET.
VBDT wrote: what is this [int main(array<System::String^> ^args)] line representing?
^ designates a handle to an object on the managed heap.
args is a managed handle to an array of System::String handles.
There's two '^' on that line because they are used in two different contexts:
1) The type of the array members (System::String ^)
2) The type of the parameter args (array<> ^)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you Mark for your response! So to simplify the meaning of the value class is that it is the same as structures in VB.Net that can’t be inherited, and the “ref class” can be inherited form the other “ref classes”. I think I got it now!
And again, thank you for clearing the confusion I had!
|
|
|
|
|
VBDT wrote: the meaning of the value class is that it is the same as structures in VB.Net that can’t be inherited, and the “ref class” can be inherited form the other “ref classes”.
Yes!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
One more question I would like to ask. As what I read about “ref class” and “value class” it appears that these are only used in C++/CLI projects and these keywords specify that the classes (data types) are managed and these keywords are not used in native C++ code. Is this the case?
|
|
|
|
|
|
Mark you just made my day! Thank you for your help. Your explanation was awesome, and yes it makes a lot sense about ref and value classes to define them class and structure respectively comparing with VB.Net. Thank you for your help very much!!!
|
|
|
|
|
Hey again, gang,
Once again, I have a question that I'm sure comes from me just missing something simple. I googled around a bit for this, but wasn't able to find anything that addressed this directly, just related tasks that didn't quite give me what I needed. If I'm just being thick-headed, I'd be more than happy with just being slapped with a link so I can learn on my own.
I'm dealing with a large collection of .h and .cpp files that together make up a bunch of classes that assist with TCP communication for a large project. Several different programs in the project use these files, and they currently do so by just #include-ing them in their own code. Consequently, a change to one packet class makes it necessary to recompile every project that depends on it. I believe that it would be better to roll all of these files into a DLL that each of the other projects can link against.
I have written my own DLLs a few times, but have always done so by creating a namespace in the DLL project and adding classes to it directly, but I can't do that here since the classes are already defined in the existing headers. How can I include these existing classes in my DLL project and make them visible from its namespace? Just #include-ing them doesn't seem to be enough, since I get a bundle of linker errors when I try to use the resulting DLL in other projects.
Could someone please clue me in or point me to a resource on this? Thanks a million!
(I'm using Visual Studio 2008 with C++/CLI. The code I'm trying to roll up is written in C++, and is cross-platform enough to be compiled on Windows and Linux boxes. I'm trying to create a DLL out of them to be used in other C++/CLI projects, and let the Linux guys handle it their own way on their side, so I don't want to modify the existing code and make it Windows-only.)
|
|
|
|
|
|
I did think my goal was to create a .NET assembly, but perhaps I was wrong about that as well. If that is the case, I'm very sorry that I put this up in the wrong place. I hate being the forum dolt.
I need to study the links you provided a little more closely to be sure, but it does look like that is the information I need. If I can figure out how to use dllexport to expose a class outside of the DLL, I'll be set.
Thank you very much for the lead, Mike. (Har!)
|
|
|
|
|
I am Using Visual c++ 2005
I need to make ab choice of all my Printing options
I have a Problem how to fill into my comBobox All Orientation Parper
I try This
this->paperorientation->DataSource = System::Enum::GetValues(GetType(PaperOrientation))
I have a message CrystalDecisions::Shared::PaperOrientation: Illegal use of this type as an expression.
I do not what to do
Can you help me
I need to fill my Paper Orientation, PAper Size, Paper Duplex ComboBoxes
Help needed
|
|
|
|
|
Hello,
I want to use RAR compression in my MC++ project ...
Please help me.
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
Have you tried googling around?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have a medium sized (27 projects) solution which has a mixture of project types, libs (both MC++ and C++), DLL's (both MC++ & C++) and exes all MC++.
I am considering upgrading the project to vc 2008 mainly because this is the only project that I look after that needs VC 2003 and would like to use one development environment for everything. (have successfully upgraded all my VC2005 projects to VC2008)
During the upgrade I was considering doing a 'proper' upgrade of all the code e.g. changing __gc class to ref class and using gcnew as required.
Anyone know of any undocumented issues that might make this upgrade a failure or accelerate hair loss!
Robin
|
|
|
|
|
I personally would take the time to upgrade all the Managed Extensions
code to C++/CLI format. The old syntax is still supported (with a
compiler option) but the Managed Extensions are deprecated (and not
as clean to read/use as the C++/CLI format).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|