|
Hi Buck,
you would not get Intellisense (nor compilable code) when omitting a
using namespace line that you need to find a class.
other than that I don't know, I program in VS C# Express Edition 2005 and
Intellisense works well for me (in C# the class name turns blue if it has been
recognized, so black class is missing a "using" statement).
Wenever strange things happen during editing/building, I tend to delete the debug
folder (that is both obj and bin) and do a "rebuild all"; if bin contains some special
files my app needs, I have to be more selective of course.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi (Luc), I am using Visual Studio 2005 C++/CLI and I am having a problem with a constructor but it looks okay to me. Can anyone tell if this is because I am using a forward declaration?
namespace MySpace {
ref class Class2; // Here is the forward declaration
public ref class Class1 : Form
{
public: Class1(Form form) { Class1 constructor code here }
public: void Print()
{
Class2^ my_class2 = gcnew Class2^(this); // This is causing error
}
}; // end of Class1
public ref class Class2 : PrintDocument
{
public: Class2(Class1^ class_arg){ Class2 constructor code here }
}; // end of Class2
} // end of MySpace namespace
If the single line in the Print() function is remarked out this compiles fine but if it is unremarked out then I get a "no appropriate default constructor" error. I don't see what's wrong with this constructor, does anyone else?
Thanks
Buck
|
|
|
|
|
There's an extra ^ in there
Plus, the compiler won't be able to resolve the parameterized constructor.
Can you do something like this?
namespace MySpace {
public ref class Class1 : Form
{
public: Class1(Form form) { Class1 constructor code here }
public: void Print();
};
public ref class Class2 : PrintDocument
{
public: Class2(Class1^ class_arg){ Class2 constructor code here }
};
inline void Class1::Print()
{
Class2^ my_class2 = gcnew Class2(this);
}
}
Mark
Last modified: 12mins after originally posted --
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, that did allow me to get the code to compile but it started as someone elses code and now I'm just confused as to why this was supposed to help. I just wanted my Print() and PrintPreview() to have the correct information (size wise) be displayed by PrintPreview() and printed by Print(). I think I'll ditch this whole idea for awhile.
Thanks
Buck
|
|
|
|
|
BuckBrown wrote: but it started as someone elses code and now I'm just confused as to why this was supposed to help
Fun fun!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
It seems I have been providing the fun here, I suggested Buck to look into
my Sokoban article for printing, but then that's in C# and does not know
about circular reference problems...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
It gets worse when you start using Generics in C++/CLI in this situation!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi George, thanks for the warning. I haven't used generics much yet,
no problems so far...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I guess you know how to keep yourself away from big issues; however, I don't. In certain situations, even with formal coding techniques, the compiler will still view your class (with a base clase of Foo ) as a basic ref class with just a base class of Object . The only way I was able to get the code to compile was to create an IFoo generic interface and made <class>Foo a Template class.
Geo
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
That's interesting. There's a bug where the C++/CLI compiler won't recognize that a managed array implements System::Array. The result is you can't pass a managed array to a function that takes an argument as IEnumerable<t>^ or something similar. What you're saying makes it sound like this bug might just be a more specific case of a general problem the C++/CLI compiler has with generics. Unless I'm misunderstanding you.
|
|
|
|
|
iddqd515 wrote: There's a bug where the C++/CLI compiler won't recognize that a managed array implements System::Array. The result is you can't pass a managed array to a function that takes an argument as IEnumerable^ or something similar. What you're saying makes it sound like this bug might just be a more specific case of a general problem the C++/CLI compiler has with generics.
I don't know if what I said applies to that. Nevertheless, translating C# code to C++/CLI may require some extensive hoop jumping. On the other hand, with the help of templates and other C++ idiosyncrasies, you can write code not possible in C#. Since I don't currently have time to write articles, I have been posting in my blog on Code Project some C++/CLI code and brief comments. I will be adding some code on this as soon as my wife allows me to. Any, any comments good, bad or indifferent are welcomed.
-- modified at 10:57 Tuesday 21st August, 2007
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I forgot to read what I posted. I meant a function with an argument of the generic interface IEnumerable<T>^ not IEnumerable^. That's what prompted me to connect your problem with that bug. I'm about to try fiddling with it.
|
|
|
|
|
|
Interesting stuff, but I'm not sure its quite along the lines I'm looking for. Do you have a code example or solution that demonstrates the problem where the compiler doesn't recognize the proper base class of the derived class and just thinks its a System::Object?
|
|
|
|
|
Yes I do. I will try to post it as soon as I get time! Also, the problem you refering to is something like the following where I have to use a safe_cast to get it to work:
using namespace System;
using namespace System::Collections::Generic;
generic <typename T>
void Foo(IEnumerable<T>^ col)
{
for each (T val in col)
{
Console::WriteLine(val);
}
}
int main(array<System::String ^> ^args)
{
array<int>^ arr = {10, 20, 30, 40, 50};
Foo(safe_cast<IEnumerable<int>^>(arr));
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
yeah that's exactly the problem. Alternatively you could call Foo<int>(arr). The C# compiler properly recognizes that an array is System::Array so it doesn't require that cast. I don't believe there's any way to dynamically get the generic type argument with typeof or GetType(). It seems this would make it quite difficult to use generics dynamically based on user input or something similar.
|
|
|
|
|
Hello,
I would use a global variable in c++ cli
help me
if exist a means to do this give me an exemple
thanks ,
aef
|
|
|
|
|
I'm assuming you need a global managed object.
One way would be to use gcroot
#include <vcclr.h>
...
gcroot<MyManagedClass ^> MyGlobalObject = gcnew MyManagedClass();
...
extern gcroot<MyManagedClass ^> MyGlobalObject; Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You can also create a global ref class with static methods.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
can anybody tell me how to convert from excel format to .csv format
|
|
|
|
|
Open it in excel, click save as and choose csv format
|
|
|
|
|
It is not simple, I found this Java Lib to do this, but I never used it before
http://jakarta.apache.org/poi/hssf/how-to.html
Russell
|
|
|
|
|
I guess it can be done easily bu excel object library
|
|
|
|
|
Yes, of course. But I don't know how. It could be that other lenguages offers some shortcuts.
Probally it is also possible to prepare a macro to save the file as CVS format and then call it from the program...but again: I don't know how. It is onlyu an idea
Russell
|
|
|
|
|
Here is code snippet that I've written recenlty:
<br />
private void savetoexcelformat(string currentpath, string pathtosave)<br />
{<br />
object missing = System.Reflection.Missing.Value;<br />
<br />
Excel.Application app = new Excel.Application();<br />
app.Visible = false;<br />
<br />
app.Workbooks.OpenXML(currentpath, missing,missing).SaveAs(pathtosave, Excel.XlFileFormat.xlWorkbookNormal, missing, missing,<br />
missing, missing, Excel.XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing, missing);<br />
app.Quit();<br />
<br />
}
Just change Excel.XlFileFormat.xlWorkbookNormal to the format you need Also you will need to open your file by calling Open() function and passing necessary parameters. My file was in xml format of excel that's why I used OpenXML
|
|
|
|