|
Mostly. However Non ANSI / ISO Win32 C++ code is also considered "native" in discussions of "managed" C++.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
|
Hi all,
I got a problem with Return key in my C++/C# application.
On CView dilalog I put my C# control using managed extension. This C# control has couple
other controls nested. I have problem with RichTextBox control which
is at the bottom of my control hierarchy. It does not process
VK_RETURN key down. So I can not create new line. All other keys work
in RichTextBox. Of course I made it Multiline. I used Spy++ tool to
figure out what is going on. I managed to see that RichTextBox window
receives ON_KEYDOWN message with VK_RETURN. But there is no WM_CHAR message which normally should follow WM_KEYDOWN. As a result no new line is created in RichTextBox.
Tried to catch WM_KEYDOWN in WndProc and onkeydown. But they are hit for all keys except of RETURN
I would greatly appreciate any hints.
Thanks in advance,
Roman
|
|
|
|
|
So your C# control is not receiving the VK_RETURN event notification? Try asking in the C# forum.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Just found solution.
In overriden WndProc I listened for WM_KEYDOWN message and never got it. But in reality I should have listened for WM_GETDLGCODE.
After I caught the message I could insert new line in textbox manually
Roman
|
|
|
|
|
Hi everybody
If can anybody help me with checking the "Change" in the Status register of the Parallel Port, i want to use it to check a clock from an external device periodically, also i want to know if i can stop the interrupt to the Microprocessor while i'm using the parallel Port
Thank you everybody and have a nice day
|
|
|
|
|
Parallel port is usualy on 0x378 adress and it's registers are: controll 0x379, status 0x37A, so you just ned to read from adress 0x37A something like clock_status = inportb(0x37A) or something elese. Note that you can not use inportb function on NT based systems before you use some driver (there is a lot of that stuff) that will allow you direct accsess.
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
I'm looking for some help in coding an application where I need to share some data between two threads. The first thread is managed code and it launches another thread that is unmanaged code. Can someone point me to an article, example, etc. on how to do this?
Thanks.
|
|
|
|
|
Hello!
i want to use from your codes about widows programming in c++ (mfc classes)
but your codes have not "application class" ,please refer me to application classes and main method ...
thank you very much.
dsdsd
|
|
|
|
|
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>;
|
|
|
|