|
A.Barakat wrote: lets say a loaded GIF file in a char * buffer
Don't do that. Load it into an Image type.
|
|
|
|
|
If you choose to ignore led mike's advice...
I think you could store in a MemoryStream and use Image.FromStream() to create the object later.
I'm not sure why though
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hello,
I have an MFC application that i would like to mix with Managed C++.
I changed the compiler settings and everything compiles fine.
For the moment I did not write any managed code but I have the message as follows at execution:
"An unhandled exception of type 'System.TypeLoadException' occurred in ApplicationName.exe
Additional information: Could not load type _TREEITEM from assembly ApplicationName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null."
This message occurs before execution of the function that returns a pointer.
I have put a breakpoint in it but it is never called.
I think it is unmanaged pointer problem because I have modified the function to return a reference to CWnd and everything was Ok.
below is the code snipped, Could please help me because I am 100% newbee with C++/CLI
Declaration
private:
CWnd* m_pView;
CWnd* CreateTreeView();
Definition
BnBPaneView::BnBPaneView():m_pView(NULL){}
int BnBPaneView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_pView = CreateTreeView();
etc..
.
.
.
}
|
|
|
|
|
i don't see anything involving managed code at all here so I'm not sure how the problem could
be with unmanaged pointers.
BnBPaneView is an unmanaged class, right (derived from an MFCclass)?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Yes it is unmanaged, derived from CWnd:
class BnBPaneView : public CWnd
Actually all what I have done is to change the compiler settings recommended in the MSDN:
Use managed extensions = yes
Enable minimum Rebuild = no
basic runtime checks = default
And before changing those settings, the application was working fine.
|
|
|
|
|
|
Does that mean that those who want to mix their applications must specify #pragma unmanaged before all their functions that are implemented with native code?
It is a hudge work to pass through thousands of functions.
While reading some articles on the subject, I understood that thanks to JIW ( just it works), there is nothing to do except changing the compiler settings.
And regarding MFC applications, following directives
#using <mscorlib.dll>
#using <system.windows.forms.dll>
using namespace System;
using namespace System::Windows::Forms;
are to be added in the stdafx.h file.
|
|
|
|
|
Arris7 wrote: While reading some articles on the subject, I understood that thanks to JIW ( just it works), there is nothing to do except changing the compiler settings.
That's correct.
Arris7 wrote: Does that mean that those who want to mix their applications must specify #pragma unmanaged before all their functions that are implemented with native code?
No. You can, but it's not necessary. If you decide to use #pragma unmanaged/unmanaged, they
effect code from that point on, until another is encountered, or the end of file is reached.
That means they only need to be at the top of a source file (under the #includes), not around
every function. This worked well for me going from a large MFC code base to adding managed
code. That also means you can mix native/CLR compilation in the same source file.
Arris7 wrote: And regarding MFC applications, following directives
#using
#using
using namespace System;
using namespace System::Windows::Forms;
are to be added in the stdafx.h file.
I suppose you could put those in the precompiled header. I'm not sure what most people do.
I personally include just the ones I need on a per-.cpp/.h file basis, especially with namespaces.
Did the TreeView struct stuff work out ok?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Mark,
Thank you so much for those great details, I have added #pragma unmanaged on the top of all my classes under #include. Now it compiles and execute very fine.
I just noticed that compilation and buid process has slow down.
This time I agree it is JIW;)
|
|
|
|
|
You're welcome! I hope I could help.
The only real slowdown I've noticed is when starting mixed-mode apps in the debugger
Cheers!
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Why does te following C++ code flag error?
# include <iostream.h>
const int i=10;
void main()
{
const int i = 20;
cout << i << endl << ::i;
cout << &i;
}
The error flagged is "Illegal structure operation in main"
Compiler use : Borland C++ 4.5
How can I access the address of the local and global constant 'i's?
Please help me.
Thanks,
Biju
|
|
|
|
|
This is the C++/CLI forum. Borland C++ 4.5 does not do C++/CLI, nor is this snippet using managed extensions. Try the visual C++ forum.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
How can i create an Image object from the standard output , basicly i want to do the following :
1 - redirect the stdout stream to anything else.
2 - create an IStream.
3 - create an Image from the IStream.
Thanks in advance.
A.Barakat
|
|
|
|
|
You'd have to capture the text and draw it onto your bitmap, yourself. There's no stream type that does this for you.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i want insert like this text.mohan's.how can i insert this in sqlserver
|
|
|
|
|
Sounds like a good question for the SQL/ADO/ADO.NET board![^]
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all,
The other day I developed a small test application in VS2005 CLI and include an ODBC class that I downloaded from CP to be more specific it was this: A set of ODBC Classes[^]
I included it into my project and changed a few setting of the project and everything worked. Untill I ran it on another computer. When I received a "application configuration is incorrect..." so I removed the ODBC class from the project, without changing any of the settings and tried again and this time it ran on the other computer.
Why did this happen ??? Can anyone please help.
Many thanks
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
|
Hi,
I have a dll written in C# that works well when i use it in .net environment. i need to load it from unmanaged code. according to MSDN documents i have used "REGASM /tlb.... " and "GACUTIL /i ..." for calling managed code from unmanaged code. it worked in some of my samples. but unfortunately i have an odd problem now.
i have created an OCX control in VB (not vb.net) an i called some functions of my managed DLL. when the managed function is called, it doesn't works completely well. i mean some of processes in managed code work well but some others don't work well. for example where i use RASCryptoServiceProvider Class it fails. the odd thing is that this dll works perfect when i call it from .net environment.
it has taken a lot of time from me. do you have any advice? HELP!
thanks
ps: there is no data passed between managed and unmanaged code then i thins it is not a subject of marshaling
|
|
|
|
|
This is the managed C++ board. You may want to post this question on the Visual Basic board[^].
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hi again,
i want to transfer my code from console to form application.
for console:
void main(int argc, char *argv[])
{
//variables here...
}
for form:
btnConnect_Click(System::Object^ sender, System::EventArgs^ e)
{
}
//how to put in the code of argc and argv[]
******************************
to know
everything
is to know
yourself...
|
|
|
|
|
The arguments are passed in to your main method, if they are passed in at all. I thought they were, they sure are long gone by the time you get to a button event.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Hi all,
I have read the article on MSDN about Redistributing Visual C++ Files, but was left wondering whether there isn't another way of compiling ones application (fiddling in the project properties or something) so that it can run on another computer (without having to run any of the Microsoft Visual C++ 2005 Redistributable Packages) ??
Many Thanks
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
Sure, try Googling: Fiddle with Project Properties
Seriously though, you can't avoid installing the C Runtime library but most of the others (MFC, ATL, etc.) can be statically linked by "fiddling".
|
|
|
|