|
arabghalizy wrote:
please refer me to application classes and main method
CWinApp::InitInstance()
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi,
I have imported several unmanaged C++ LIBs into a mixed C++ .NET DLL.
Two LIBs have the SAME class name (CLog) without namespace.
Is there a way to assign a namespace to each imported LIB in the mixed DLL project?
Also, when I use this mixed DLL in my C# app, I can see that these unmanaged classes (from LIBs) are shown :
how can I set the visibility of the classes to something like "internal" (as in C#) in the Mixed DLL ??
Thanks a lot!
Bertrand
|
|
|
|
|
Any hint ?
Pleaaaase....
|
|
|
|
|
Hello,
As a newbie to MC++, i've been working on a C# API that accesses a class written in C++. I've converted my C++ class into a wrapper as was suggested to me, but now i have an incredibly frustrating problem: when i try to "set" parameters into the attributes in the C++ class, i get datatype conversion problems. namely, here are my errors:
Argument '1': cannot convert from 'decimal' to 'int'
Argument '2': cannot convert from 'string' to 'std.basic_string<char,std::char_traits<char>,std::allocator<char> >*'
Argument '3': cannot convert from 'char' to 'sbyte'
I don't know how to get arnd these issues -- are there any "common" datatypes between the two languages? Any help would be REALLY appreciated
thanks in advance
|
|
|
|
|
Actually i just found something that could be "common":
The C++ "char" == the C# "sbyte"
not pretty, but it does the trick
|
|
|
|
|
If you are going to mess with C++ let alone "mixed mode" development you need a very clear understanding of "types" in C/C++ and "type conversion" principles.
But, that's just my opinion... I could be wrong.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
I want to make own ls command in UNIX.
Example:ls | more
give the list of fine in the directory.
same as
myls | more
give the same output as given by above(list of fine in the directory).
Can u suggest me where i have to search.
|
|
|
|
|
I am trying to build a DLL but every time I build my project it gives me an EXE. I have set the configuration type to 'Dynamic Library (.dll)' but it still only gives me an EXE.
I appreciate any help.
|
|
|
|
|
If you are using Visual Studio, check the entry of your output file.
You can find it in the project properties, in the Linker section, below the "Common" section (sorry, if the section - titles are called a bit different in the english version of VS.NET, but I'm using the german version ...)
|
|
|
|
|
It worked, thank you very much.
|
|
|
|
|
Hello,
I am trying to save an image stream into a .bmp file or a jpeg file. I an trying to use the .NET classes in the System::Drawing namespaces.
I have some code like the following
<code>
char* buf = new char[bufSize];
dev->Grab(buf);
Byte b[] = new Byte[bufSize];
MemoryStream *ms = new MemoryStream( b );
for(int i=0; i<bufSize; i++)
{
b[i]=buf[i];
}
Bitmap *b = new Bitamp( ms );
b->Save(S"C:\\test.jpg", ImageFormat::Jpeg);
</code>
Every time i run the code the following line
Bitmap *b = new Bitamp( ms );
throws a ArgumentException:Invalid Parameter used exception.
Does any one Know Why, could it be that the Bitmap class understands that the stream is not a valid image yet because the stream only contains the row bytes... any help please...
|
|
|
|
|
Hello,
I'm confusing with pinning pointers. In the language specification of MC++ you can read about pinning pointers:
"Pinning a sub-object defined in a managed object has the effect of pinning the entire object."
So I tried to find out if this really works, because I want be sure of it when I am using pinning pointers to convert a managed char[] char c _gc[] to an unmanaged null-terminated-char pointer.
Because a char array wouln't show, when it is destroyed, I wrote a class 'O', which does so:
__gc class O
{
int m_i;
public:
O(int i) : m_i(i)
{
Console::WriteLine(String::Concat("constructor O ", m_i.ToString()));
}
~O()
{
Console::WriteLine(String::Concat("destructor O ", m_i.ToString()));
m_i=0;
}
};
Then I wrote a class 'C', containing an array of 'O' which will be pinned. And this should pin the whole object.
'C' shows when it is created or destroeyed, too.
__gc class C
{
public:
O *o[];
C()
{
Console::WriteLine("contructor C");
o = new O* [4];
for(int i=0; i<4; i++)
o[i] = new O(i+1);
}
~C()
{
Console::WriteLine("destructor C");
}
};
And now the testprog. I create an instance of 'C' an pin an element of its member 'o'.
After that I remove the reference to 'c' and invoke the GC. Non of the allocated objects (the 'C' - instance itself or the array of 'O') shold be destroued.
Because I pinned a subobject of the array - so the array mus be pinned, and the array is a (now pinned) subobject of the 'C' - Class - so 'c' must be pinned, too ..
int main()
{
C *c = new C();
Console::WriteLine("O __pin*p = c->o[0]");
O __pin*p = c->o[0];
Console::WriteLine("c = 0");
c = 0;
GC::Collect();
GC::WaitForPendingFinalizers();
Console::WriteLine("p = 0");
p = 0;
GC::Collect();
GC::WaitForPendingFinalizers();
Console::WriteLine("END _ OF _ CODE");
return 0;
}
I compiled with VS.NET 2003 an got the following output:
contructor C
constructor O 1
constructor O 2
constructor O 3
constructor O 4
O __pin*p = c->o[0]
c = 0
destructor O 4
destructor C
destructor O 3
destructor O 2
p = 0
destructor O 1
END _ OF _ CODE
This shows, that any element was destroyed, except the element of the 'O'-array, I was pointing to. But this is not pinning! :-/
At least the whole array of 'O' should still remain after GC.
I wonder if I misunderstud anything related to pinning or if I did something wrong ...
By the way, I tested pining before with a common Int32 - member variable of an __gc class (let me call it 'G'). After pinning this Int32-member and removing the reference to the containing object (the instance of 'G'), the whole object still remains after GC. So it seems pinning works when pinning a __value - type.
Is it possible that my problem causes in the same behavior why I shouldn't use the operator == to check two System::String for Equality?
(see http://www.winterdom.com/mcppfaq/archives/000124.html[^])
System::String *str1 = S"Test";
System::String *str2 = new String("Test");
System::Console::WriteLine( (str1 == str2).ToString() );
System::Console::WriteLine( (str1->Equals(str2)).ToString() );
So what's going on there? Can anybody give me an explanation?
Do pinning pointers really pin objects or is there a bug?
Thanks in advance.
|
|
|
|
|
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 !
|
|
|
|