|
It is CSV Please; How to do it from Visual c++ NET
|
|
|
|
|
I am using a computer that has not been installed VC++6.0. So, what files should I copy to my computer in order to compile successful a project without installing VC++6.0?
|
|
|
|
|
Hi, I'm completely new to C++ as a whole, so there might be a simple answer to my question, so here goes.
I'm trying to write a program that will have the screen broken up into zones, or areas, each with a Point (location) a Size, an Image, and an array of terrain types (an enum). Trying to include a bitmap in my class made the compiler tell me that I couldn't mix managed and unmanaged types. To try to work around this, I tried extending the PictureBox control, but this has given me even more headaches.
Basically, I can't figure out how to declare/use an array in an extended control.
#pragma once
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace cli;
namespace MapEdit
{
const int MAX_TERRAIN = 3;
public ref class Zone : public System::Windows::Forms::PictureBox
{
public:
enum Terrain
{
Plain,
Hill,
Wood,
Marsh,
Stream,
River,
ShoreLine,
Impassable
};
array<byte^> ^TerrainTypes;
int TerrainTypes[3];
...
All of my errors (except the parts where I try to use these faulty enum/ array) come from this block. Frankly, I'm at a loss as to how to fix this.
Also, if someone could tell me how to include a Bitmap in an unmanged class, that would be nice too.
Thanks,
Christian
|
|
|
|
|
poppabaggins wrote: Trying to include a bitmap in my class made the compiler tell me that I couldn't mix managed and unmanaged types. To try to work around this
Rather than work around by making something up yourself I would strongly suggest that you learn C++/CLI. There are excellent tutorial articles on CLI here at CodeProject. Look under the "Chapters" in the site menu.
Of course I would also strongly recommend you learn C++ first and then learn C++/CLI. I mean CLI is an extension so it seems rather obvious that one learns the root before the extension, but what do I know right?
led mike
|
|
|
|
|
|
Mark Salsbery wrote: it's pretty obvious
there's a whole new generation of "programmers" that
have completely bypassed the fundamentals.
they also seem to mostly bypass thinking. It's likely a symptom of Drag and Drop development. Vee Bee Stupid
led mike
|
|
|
|
|
Are you trying to make an array of enums?
If so, why did you try to create a byte (whatever that is)
array and an int array?
First, you can't embed a native enumeration in a ref class.
Second, once you have a managed enum class, you can create an
array that stores the enum type...
enum class Terrain
{
Plain,
Hill,
Wood,
Marsh,
Stream,
River,
ShoreLine,
Impassable
};
array<Terrain> ^TerrainTypes;
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
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.)
|
|
|
|