|
Hi all
I'm trying to use a UnmanagedC++ class in my MC++ application.The unmanaged class internally using CString class as member variables.I'm converting the String to LPCTSTR and passing it as a parameter to the methods of the unmanaged class.There i'm getting access voilations on CString class GetData()method(this is inside the class CString).Can anybody help me how to solve this problem and what are all the other settings needed.(in project options i have enbaled using MFC as dynamic libraries).
Thanks You
Rgds
Krishna
|
|
|
|
|
Hello
Is there some way how to use windows forms or some third party .net controls and components in my MFC application?
I have a application, with MFC and COM controls and I' d like to use there some third party .NET components.
In all MS examples for MC++, there is only shown,. how to create applicatino, that opens new window with this windows forms controls.
Thanks
|
|
|
|
|
I've subclassed a textbox to create a texbox box that only allows numbers. I am using Version 2003 and I was wondering how I can get the subclassed text box to be visible in the form view, so that I can add them in the form view.
Thanks
|
|
|
|
|
Can you still use delete instead of leaving memory for the Garbage Collector? If so and you delete an object will the GC still work normally?
|
|
|
|
|
You can call the delete function of a managed object, but it won't actually be deleted until the next GC cycle.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
I heard that the compiler is confussed whith the use of MessageBox in Windows::Forms. Can anybody tell me what is the correct precompiler directive for the correct use of MessageBox Class in Windows::Forms???
THANK YOU, VERY MUCH
|
|
|
|
|
If you're trying to use the MessageBox class in a mixed mode app you'll run into compiler error because the WinUser.h file contains a #define that maps the MessageBox name to either the MessageBoxA (marshals the passed string to ANSI) or MessageBoxW (marshals the passed string to wide character format, or Unicode) function based on the project's defined character set option. If this is the case you have two options:
1) If you'll never use the Win32 MessageBox function, simply #undef it in the stdafx.h file.
<br />
#undef MessageBox<br />
2) If you only want to #undef the MessageBox within a given context, you can do the following:
<br />
#pragma push_macro("MessageBox")<br />
#undef MessageBox<br />
#pragma pop_macro("MessageBox")<br />
If you're writing a purely managed application, I don't think it's an issue but I never write managed only C++ apps so I'm not sure.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Thank you Tom. It's OK :
|
|
|
|
|
hi, i'm playing with CCW now - written a dummy managed C++ class lib, wrap it up in COM using RegAsm.exe - which generated a tlb (type library) file. The tlb is #import'ed into my WIN32 C++ client application.
#import "..\shared_bin\Sh*tty.tlb"
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
USES_CONVERSION;
NetLib::INetLibPtr obj( __uuidof(NetLib::NetLibServ));
char * msg = OLE2A(obj->NetLibMethod(0));
printf("Response from NetLib: %s\n", msg);
return 0;
}
I got it working, but that's after a long hard struggle: THE PROBLEM IS:
if namespace in "class library" is different from "project name", Intellisense won't give you the exposed "class":
ie. this won't work and you'll get compiler error:
NetLib::NetLibServ (this is referencing the exposed "class". Intellisense won't work also)
Any idea? It was okay after I changed namespace of class library to that of project name, things work just fine.
norm
|
|
|
|
|
norm wrote:
I got it working, but that's after a long hard struggle: THE PROBLEM IS:
if namespace in "class library" is different from "project name", Intellisense won't give you the exposed "class":
ie. this won't work and you'll get compiler error:
NetLib::NetLibServ (this is referencing the exposed "class". Intellisense won't work also)
Any idea?
I did my work through an interface, maybe my article: Creating a CCW for COM enabled non .NET applications[^] would help? Check under the MFC example I list at the bottom. HTH.
-Nick Parker
|
|
|
|
|
i got my code working, just dont understand why if "namespace"!="project name", then your "class" don't get registered by Intellisense. As a result, you cant call __uuid.
Weird. Was looking for people who had experienced same thing.
norm
|
|
|
|
|
I recommend Visual Assist .NET if you find Ms intelisense doesn't make sense to you. It is a nifty tool.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi, anyone can convert this C# statement to C++?
object [] objArgs = new object[] {123,23,45,265};
The following didn't work:
Object * args[] = new Object[] {1,2,3,4,5};
Thanks.
norm
|
|
|
|
|
|
|
Just so you know how Tom's example works - you must box value types before you pass them as objects, because object is a reference type. C# does this for you, but MC++ doesn't.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
What do you mean "object is a reference type"?
I C++:
int SomeFunc(int ¶m);
param is passed to SomeFunc by "reference" as opposed to "by value". But what's a "Reference Type"?
norm
|
|
|
|
|
Different usage. In .NET terms, a reference type is one that is allocated on the CLR heap (and not the local C++ heap). A value type is one that is allocated on the local stack. A literal number as you had is a value type and has to be boxed into a reference type before it can be used in a managed function.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
it's expecting an Object i suppose. I read __box docs. Actually I came across it before, but forgot about it. Thanks anyway.
norm
|
|
|
|
|
Playing with ATL server and RCW/Interop:
QUESTION 1. Can you pass custom defined object through COM interface? If you "Add Function" (right click classview on an ATL object/class), "Add Member Function Wizard" pops up. One can "choose" parameter type from the list of options available.
But what if I want to pass across interface the following:
a. A result set?
b. A user-defined class:
CMyClass
{
};
How can I do that? And can I do that in the first place?
QUESTION 2: What's the diff between "retval" and "out":
[propget, id(3), helpstring("property ComputerName")] HRESULT ComputerName([out, retval] BSTR* pVal);
"retval" IS "out" isn't it? If pVal is passed as a pointer, why do you need to marked the parameter as [out][retval]?
QUESTION 3: With ATL server projects, how can you add multiple interface? When you add "ATL simple object", the first interface is created for you by the wizard. Do you have do add to IDL file manually for subsequent interfaces? Is all that you need to do is to add to IDL? Any additional steps?
QUESTION 4: I tried to get a "double" across interface - but it always return "zero" to the client for some reason:
[id(1),helpstring("method GetRandNum")] HRESULT GetRandNum([out,retval] DOUBLE *RandNum);
STDMETHODIMP CCATLSimple::GetRandNum(DOUBLE* RandNum)
{
// TODO: Add your implementation code here
srand( (unsigned) time(NULL) );
double randy = rand();
RandNum = &randy;
return S_OK;
}
What could be the problem?
Thanks a lot, that's a long posting.
|
|
|
|
|
I am developing a game.Now my problem is that when the stick hits the balls lying on table balls are rotating and not moving.I want them to move and get into holes in the table.I am doing this in graphics in C.Can somebody tell me what should i do to solve this problem
Thanks
|
|
|
|
|
|
|
|