|
I certainly don't know this, just guessing.
>> O *__pin*p = &c->o[0];
You are not pinning a member of the class right? you are pinning an element of the array Try pinning the variable "o" and see what happens.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Yes of course, it seems so. with *__pin*p I have a __gc pointer - and so I have an other reference to the object.
But if I pin the variable 'o' directly, I got the compiler error C2440.
I removed the part with the 'pointer to pointer' section, because it is superfluous for my question.
Thanks.
|
|
|
|
|
I'm trying to subclass a .NET control (panel actually) in Visual C++ 2005 Express. Its been about 2 years since I worked with C++ (stupid java (school), and lovely C# have spoiled me) and I have never really done much with managed C++ or CLI. I can't get any of the new class wizards to work so I have to do it by hand. I just don't know how CLI classes are formed or how to do inheritance with CLI, I can figure out the rest from there. Thanks if you can help.
Matt Newman
What is your malfunction? - Dangeresque, too?
|
|
|
|
|
here's a quick example i knocked together for you ...
#pragma once
namespace managed_cplus
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
public __gc class sClass : public System::Windows::Forms::NativeWindow
{
public: Form* frm;
public:
sClass(System::IntPtr handle)
{
this->AssignHandle(handle);
frm = dynamic_cast<Form*>(Form::get_ActiveForm());
}
protected:
void WndProc(Message* m)
{
NativeWindow::WndProc(m);
frm->Text = m->Msg.ToString();
}
};
public __gc class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing);
}
private: System::Windows::Forms::Button * button1;
private: System::Windows::Forms::Panel * panel1;
private:
System::ComponentModel::Container * components;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->button1 = new System::Windows::Forms::Button();
this->panel1 = new System::Windows::Forms::Panel();
this->SuspendLayout();
this->button1->Location = System::Drawing::Point(28, 13);
this->button1->Name = S"button1";
this->button1->TabIndex = 0;
this->button1->Text = S"button1";
this->button1->Click += new System::EventHandler(this, &Form1::button1_Click);
this->panel1->BackColor = System::Drawing::SystemColors::ActiveCaption;
this->panel1->Location = System::Drawing::Point(116, 26);
this->panel1->Name = S"panel1";
this->panel1->TabIndex = 1;
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
this->ClientSize = System::Drawing::Size(716, 444);
this->Controls->Add(this->panel1);
this->Controls->Add(this->button1);
this->Name = S"Form1";
this->Text = S"Form1";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{
sClass* sc = new sClass(panel1->Handle);
}
};
}
hope it helps.
<font color="blue">Csharp</font> me = (<font color="blue">Csharp</font>)Dynamic_Sysop; <font color="#008000">// My Signature.</font><br><font color="#008000">$twins</font> = <font color="#008000">me.twins</font>(<font color="#800080">"Taylor"</font> , <font color="#800080">"Delta"</font>); <font color="#C0C0C0">// My twin daughters.</font><br>echo <font color="#008000">$twins</font>;
|
|
|
|
|
Ok, I think I've found my mistake. Thanks alot!
Matt Newman
What is your malfunction? - Dangeresque, too?
|
|
|
|
|
Hi all,
I'm trying to do the following :
std::queue <MyManagedClass *> m_qSomeName;
but I get the following compile error
...\Vc7\include\deque(59): error C2847: cannot apply sizeof to managed type 'TestApp1::MyManagedClass'
ok.. so I changed MyManagedClass to a non Managed Class, and now I get a different compile error:
...\TestApp1\MyServer.h(29): error C3633: cannot define 'm_qSomeName' as a member of managed 'TestApp1::MyServer'
Now I'm just trying things out, but is it not possible to use the std::queue template class in managed c++? what about other STL classes?
<EDIT>
Before anyone says, why aren't you using .NET queue/list classes. I'm geniunely curious why I am not able to use STL
</EDIT>
Thanx
|
|
|
|
|
I have not tried to store managed object pointers in STL collections, I can imagine there could be many perils in that even if it was supported.
I have used STL vector in a "mixed mode" exe project in VS 2003
std::vector<LPCTSTR> strV;
So STL will compile and execute within a mixed mode project. But as you can see I was not mixing STL and Managed types.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
thanx for your reply Palbano,
yeh i've been able to use standard objects in an stl vector but not managed ones. oh well. i can just live with out it. would have been nice to know though
thanx
If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson
|
|
|
|
|
|
Hi everybody,
I have a question about using list on c++.. I have learnt c++ 10 years ago, but I cant remember anything..
A close friend of mine send me this paper, which u can see it at the weblink below, to explain it to him.. but I could not understand what happens...
can anyone explain me whats goin on with this code, that is under "Besser" title..
http://www11.brinkster.com/nurteknik/Seite%2094.jpg
Thanks alot..
Togi
Tolga YARAMIS
|
|
|
|
|
|
|
Hi Guys,
I wish to get an alternative of CObject and Clist classes in MFC so that i can use it in my code for the Linux Platform.
Looking for Non-MFC CObject and CList Classes.
Can any one suggest me !
Thanks !
|
|
|
|
|
Try std::vector or std::list instead.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Try checking out the VFC library. It has both and makes porting to linux easy. It is in beta state but it is quite stable. It is on sourceforge. It has gui, threads, resources, and file io, and more. Web address http:\\vcf.sourceforge.net
|
|
|
|
|
Hi Guys,
I wish to get an alternative of CObject and Clist classes in MFC so that i can use it in my code for the Linux Platform.
Can any one suggest me !
Thanks !
|
|
|
|
|
If all you want is the functionality provided in those classes then for CList you could just use the STL list class. If you just want an MFC-like framework then your best bet is to try wxWidgets or Qt, both of which are cross-platform. I've not used either but presumambly they will have collection classes.
Kevin
|
|
|
|
|
Hi,
can you help me to add a System Menu (Minimize, Restore, Close icons on right corner up of a Window) into a rebar with inside a custom menu?
All application developed with C++ and Win 32 (without MFC).
Thanks.
Nando.
|
|
|
|
|
Hi,
I am using unmanaged c code from managed c++ 7 code.
I need to convert a managed c++ 7 code function pointer to a user defined fucntion pointer type which is defined in c code. For instance
I have
int CWrapper::functionA(int a, double b);
and I want to type cast it into MyFunctionPtr. where MyFunctionPtr is defined in unmanaged c code as
typedef int (*MyFunctionPtr)();
If this functionA was a c function then this typecast is valid and tested but if I do it from managed c++ 7 code, I get a linking error
Can some one help me in correcting this type cast?
Thanks
Bilal Farooq
|
|
|
|
|
Herb Sutter - Is C++ Relevant on Modern Environments?
http://www.accu.org/conference/presentations/[^]
Herb's answer...
Q: Which .NET language should you use?
Microsoft’s answer, in our Whidbey release:
• C++ is the recommended path to .NET and Longhorn.
• If you have an existing C++ code base:
Keep using C++.
• If you want to make frequent use of native code/libs:
Use C++. It’s far simpler (seamless) and faster.
• If you want to write brand-new pure-.NET apps that
rarely or never interop with native code:
Use whatever language you’re already comfortable with,
and pick based on language features. The .NET features
and Frameworks library are available equally through all
languages.
Kevin
Kevin
|
|
|
|
|
Herb says good things
And I think we actually support generics better than C# does for whidbey, but don't quote me on it.
|
|
|
|
|
I can comfirm that.
With VisualStudio 2005 (Whidbey) they will ship a whole new Version of C++, called C++/CLI.
I've seen a presentation of it at the TechEd last weekend and was simply blown away.
You get all the well known controll of C++ and all the features of C# ... like gc, ref, interfaces.
TechED Bloggers
- Newro
|
|
|
|
|
hello..
i'm not sure whether this is the right place to ask this question, sorry if i'm in the wrong place. here goes:
say i have a string, for example 'the code project'
i'd like to swap two characters at once.. for example i'd like to swap 'th' in 'the' with 'co' in 'code'.. how can i do that efficiently? i was thinking of collecting the letters into one variable: a = th and b = co and then swap them but i think it's ridiculous to do that.. can anyone give me any suggestions? i thank you in advance for your guidance
thanks!
~wilDcat~
|
|
|
|
|
Hello,
I have some troubles on writing my Managed C++ wrapper on the very good physics engine Tokamak.
To use Tokamak (simply), I have to create 1 simulator instance and several
bodies with Tokamak C++ interface :
class TOKAMAK_API neSimulator {
public:
// Static factory functions
static neSimulator * CreateSimulator(const neSimulatorSizeInfo & sizeInfo, const neV3 * gravity = NULL);
static void DestroySimulator(neSimulator * sim);
...
// Rigid body managment functions
neRigidBody * CreateRigidBody();
void FreeRigidBody(neRigidBody * body);
...
};
So my .NET Managed C++ wrapper is like this :
public __gc class Simulator {
private public:
neSimulator __nogc *_Simulator;
public:
Simulator() {
_Simulator = neSimulator::CreateSimulator(*(sizeInfo->_SimulatorSizeInfo),NULL,&V3_gravity);
}
~Simulator() {
neSimulator::DestroySimulator(_Simulator);
}
...
};
public __gc class RigidBody {
private public:
Simulator __gc *_Simulator;
neRigidBody __nogc *_RigidBody;
public:
RigidBody(Simulator __gc *simulator) {
_Simulator = simulator;
_RigidBody = _Simulator->_Simulator->CreateRigidBody();
}
private:
~RigidBody() {
if (_RigidBody != NULL)
if (_Simulator != NULL)
if (_Simulator->_Simulator != NULL)
_Simulator->_Simulator->FreeRigidBody(_RigidBody);
_RigidBody = NULL;
_Simulator = NULL;
}
...
};
All is OK at the beginning : 1 simulator instance, 5 rigid body instances
...
Problem appears when Garbage Collector calls finalizers at the end of my test, it calls for example :
~RigidBody() for body 1
~RigidBody() for body 2
~Simulator() !!!! Why is it freed ? There is yet 3 rigid body instances not freed which have reference on it !!!
~RigidBody() for body 3 -> Access to undefined object _Simulator !!!
Is there any solution to inform Garbage Collector about multiple _Simulator
references ?
Thanks
greg
|
|
|
|
|
I want to use a FileNameEditor in which you can select only bitmap files, so I overloaded FileNameEditor, and in the InitializeDialog function, I set the Filter member to only show bitmap files. But this doesn't work. It does work fine when I just specify FileNameEditor as editor, but even when I only overload the FileNameEditor into a new class, without even adding any members, it doesn't work. I have done this before, in c#, and there it worked perfectly, and the managed c++ version doesn't work. There just isn't an ellipses button in my property grid.
The c# class that worked fine:
class ImageFileEditor : FileNameEditor
{
public ImageFileEditor()
{
}
protected override void InitializeDialog(OpenFileDialog dlg)
{
dlg.Title = "Select Image";
dlg.Filter = "Bitmap Files (*.bmp)|*bmp";
}
}
and the managed c++ version that doesn't work:
__gc class ImageFileEditor : public FileNameEditor
{
public:
ImageFileEditor()
{
}
protected:
virtual void InitializeDialog(OpenFileDialog *pDlg)
{
pDlg->Title = S"Select Image";
pDlg->Filter = S"Bitmap Files (*.bmp)|*.bmp";
}
};
And this is the property that should use the ImageFileEditor. If I change ImageFileEditor to FileNameEditor it works fine though.
[Category(S"Base Texture"),
EditorAttribute(__typeof(ImageFileEditor),__typeof(UITypeEditor))]
__property String* get_BaseImageName()
{
return pBaseImageName;
}
__property void set_BaseImageName(String *value)
{
pBaseImageName = value;
}
How should I do this?
Thank you
|
|
|
|