|
Make that...
__gc class outer<br />
{<br />
public:<br />
int m_value;<br />
int m_value2<br />
<br />
__gc class inner<br />
{<br />
int getAccess()<br />
{<br />
return (??)m_value;<br />
}<br />
}<br />
}<br /> ...forgot the managed qualifiers...
|
|
|
|
|
Hi Douglas,
I don't know exactly if this helps but I'll give it a try. Basically i have just converted the C# example of nested classes into C++/CLI. It seems to me that this is a way to get it working (it actually did work):
public ref class Container
{
public:
Container(void);
private:
int m_value;
public:
void SetValue(int pVal)
{
m_value = pVal;
}
public:
ref class InnerClass
{
private:
Container^ m_parent;
public:
InnerClass(void) {};
InnerClass(Container^ parent)
{
m_parent = parent;
}
public:
int getAccess()
{
return m_parent->m_value;
}
};
};
Container^ outer = gcnew Container();
Container::InnerClass^ nested = gcnew Container::InnerClass(outer);
Console::WriteLine(nested->getAccess()); // prints 4
outer->SetValue(5);
Console::WriteLine(nested->getAccess()); // prints 5
hope this helps,
best regards Tobias
|
|
|
|
|
Yeah, that's what I ended up doing. I wonder if there's a cleaner way, though...
|
|
|
|
|
|
Hi, I'm just starting to write my first application in C++ .NET with Windows Forms. Needing a vertical ProgressBar, I downloaded from CodeProject the ExtendedDotNET library, which features a nice looking ProgressBar written in C#. I correctly installed it in my toolbox and placed it on my Form, but when compiling my (C++) application I get a lot of errors, these are the very first ones:
error C3699: '^' : cannot use this indirection on type 'System::Drawing::Font'<br />
compiler replacing '^' with '*' to continue parsing<br />
This diagnostic occurred while importing type 'ExtendedDotNET::Controls::Progress::ProgressBar ' from assembly 'ExtendedDotNET.Controls, Version=1.0.2125.33876, Culture=neutral, PublicKeyToken=null'.<br />
<br />
error C3699: '^' : cannot use this indirection on type 'System::ComponentModel::Container'<br />
compiler replacing '^' with '*' to continue parsing<br />
This diagnostic occurred while importing type 'ExtendedDotNET::Controls::Progress::ProgressBar ' from assembly 'ExtendedDotNET.Controls, Version=1.0.2125.33876, Culture=neutral, PublicKeyToken=null'.<br />
<br />
error C2079: 'ExtendedDotNET::Controls::Progress::ProgressBar::m_EdgeColor' uses undefined class 'System::Drawing::Color'<br />
This diagnostic occurred while importing type 'ExtendedDotNET::Controls::Progress::ProgressBar ' from assembly 'ExtendedDotNET.Controls, Version=1.0.2125.33876, Culture=neutral, PublicKeyToken=null'.<br />
<br />
error C2664: 'void System::Windows::Forms::TableLayoutControlCollection::Add(System::Windows::Forms::Control ^,int,int)' : cannot convert parameter 1 from 'ExtendedDotNET::Controls::Progress::ProgressBar ^' to 'System::Windows::Forms::Control ^'<br />
No user-defined-conversion operator available, or<br />
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Now my question is: can I really use a DLL containing a WindowsForms control written in C# in a C++ application?
|
|
|
|
|
I recompiled the sources ot the library instead of using the published DLL, and now it works! For some reason, VS2005 doesn't like the DLL made by VS2003... so, it's not an issue of using C# controls in C++ (maybe this topic can be removed from here, I also posted in the article's comments)
|
|
|
|
|
The difference between both is:
VS2003 uses the .NET Runtime version 1.1, whereas VS2005 uses the .NET Runtime version 2.0.
Its not exactly 100% compatible. But, as you noticed, adapting and recompiling will work most of the times. I daresay, you will get 99% of all .NET assemblies to compile with no or minor adjustements.
OK, maybe more like 90%.
75 to 90.
50ish.
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
I want to add desktop node in treeview and further want to add the My Computer , Recycle Bin , My Documents etc in the Desktop node .For that I think SHGETDESKTOPFOLDER function should be used. I searched it's implementation in online MSDN . But no help given.
Please help me.
Thank You.
Pankaj Garg
|
|
|
|
|
hi,
When i try to build the VC++6.O workspace in VC++.NET environment iam getting the following linker error
LNK1104 : "Cannot open file msvcirt.lib"
I have tried in the NODefault option also. It didn't worked out.
Please help me in this context.
Thanks and regargds,
LaksshmiNarasiman
|
|
|
|
|
the error is explicit enough i find :
you are calling some functions in your progam than are located in msvcirt.dll, but the compiler needs the .lib to link to the functions. verify in the project settings the lib path...
|
|
|
|
|
As of my knowlegdge msvcirt.dll belongs to VC++ or microsoft library. But i don't know the path for the msvcirt.lib. I searched completely in .NET installation folder. But i couldn't able to locate.
I reckon the same linker error is posted by some body in some websites. Still they are also waiting for a solution.
I have converted many projects from VC++ to VC++.net solution. Only iam facing the problem in a particular workspace.
The project is a Multhreaded Dll which includes 2 libraries.
Please let me know if you can able to fix this problem.
Advance thanks and regards,
LaksshmiNarasiman
|
|
|
|
|
I have a simple application in VC6.0 and ported it to .NET 2003.
I set "Use Managed Extensions" to Yes from the Project Properties->Configuration Properties->General because am using #using <mscorlib.dll>.
i get the foll error
Command line error D2016 : '/RTC1' and '/clr:initialappdomain' command-line
options are incompatible
i saw a lot of articles on this which suggested to do the foll to solve this error: i.e.
Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
Click the C/C++ folder.
Click the Code Generation property page.
Modify one or both of the following properties: Basic Runtime Checks or Smaller Type Check
i tried changing options under Basic Runtime Checks but to no avail?
i still get the error?
How can I solve this command line error?
Pls help!
Sincerely
Giftsana
|
|
|
|
|
I do have following structure in VC++
struct Employee
{
int a;
char b;
float c;
};
i need to obtain the size of the above struct.
While using sizeof operator will it return the byte size(in this case 9) or padding will also be taken into account.
if so how the size can be obtained without padding
Thanks
sanggetha
|
|
|
|
|
The Almighty MSDN says:
"When the sizeof operator is applied to a class, struct, or union type, the result is the number of bytes in an object of that type, plus any padding added to align members on word boundaries."
If I am not wrong sizeof should return in your case:
10 bytes, because a word is 2 byte. But it might be even more, depending on your system and how the padding is done.
int = 4 bytes
char = 1 byte
float = 4 bytes
total = 9 bytes + padding to word boundaries (1 byte here)
Tobias
|
|
|
|
|
it returns the size that the class/structure actually occupies in memory.
it can take 9 bytes (as you say) in minimum on a 32 bits machine ( (int = 4) + (char = 1) + (float = 4) ), but on a 64 bits system, your int will be 8 bits wide.
moreover, the compiler aligns the members on the larger member.... so, don't expect your struct to be 9 bytes wide.
|
|
|
|
|
I really really need help with tracking the mouse in a simple image program i am writing, any help will be greatly appresciated.
I have writen the program to load an image, and display its dimensions, which it does.
I now need to get it to alter the pixel values within a selection, i cant get the selection to display or select.please help
Be good...if you can't be good....be good at it!
|
|
|
|
|
how do you make a shared function?
In VB.NET I'd have done like this:
Public Shared Function f() As Integer
Think it's something like this:
public:<br />
int f()
but how do you make it shared?
|
|
|
|
|
As far as I know is the Shared keyword the equivalent to C#'s static keyword. Furthermore please note that the static keyword in VB is different to C#'s or C++/C one. However, static should be the way to go.
Tobias
|
|
|
|
|
|
Hello everybody,
I have two classes, one in c# and one in c++. The c# class is derived from the c++ class. Now I want to create a new virtual member function. No problem. But the function should return a double value in an parameter.
I use VS2005.
c#
public override Status GetProgress (ref System.Double dVal)
{
...
}
What's the equivalent of the base class in c++ ?
virtual Status GetProgress (System::Double ^dVal) is wrong.
Does anybody know the solution?
|
|
|
|
|
Probably you're looking for a "tracking reference %".
As far as i know it should be in your case :
virtual Status GetProgress (System::Double^% dVal)
On the other hand an interior pointer might suit as well;
virtual Status GetProgress (interior_ptr<System::Double> dVal)
Tobias
|
|
|
|
|
Hi Tobias,
thank you for the quick reply.
Using "System::Double^% dVal", I'm still getting an error message: no suitable method found to override. But "interior_ptr<system::double> dVal" works.
Now I'm checking, what it means...
Thanks!!
Hermann
|
|
|
|
|
// Assuming Status is a ref class
virtual Status^ GetProgress(System::Double% dVal) override
{
}
|
|
|
|
|
Hi George,
Thanks a lot! It works! Since I know it's a tracking reference, I found the description in the online help. Now I realized the meaning
Hermann
|
|
|
|
|
how to create an algorithm?
|
|
|
|