|
Well the solution depends on the dependencies between DLL.
Assuming that Clarion is using a DLL with C++/CLI code and that DLL is using a C# DLL, then you would also define an interface in C# DLL that will be implementend by C++ code when calling back into C++.
Delegates or events could also be used in some cases. This is particulary interesting if for each C# method, you already know which (single) method would be called during processing.
Philippe Mori
|
|
|
|
|
Yes. This is what I had in mind..
But I'm not sure how to implement a C# interface in C++. As far as I know, the C# Interface is not C++ compatible becasue C++ actually dont have interfaces (i'm a noob in C++ so this statement is based on things I have read etc.)
-----------------------------
Speaking nordic language?
Why not visiting irc.c-c.no and join #C# or #VisualBasic
-----------------------------
|
|
|
|
|
To implement the interface just derive from it as you would do in C#.
Philippe Mori
|
|
|
|
|
I wil take this under consideration If I reopen the project. As by now, the whole thing is done using a .NET EXE and parameters
-----------------------------
Ole Morten Heien
HD Software / Advisor AS
-----------------------------
|
|
|
|
|
Hi
I am using UnDecorateSymbolName() method get function name and argument data type. but i want actual argument variable name? i try this code like
void ExtractCppSymbol(char *szDecoratedName)
{
char szFunc[512];
if ( UnDecorateSymbolName(szDecoratedName, szFunc, 512, UNDNAME_COMPLETE > 0 ))
{
cout<
|
|
|
|
|
Please do not post the same question in multiple forums. This has already been answered under C++.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi,
In my C++ app I'm recieving callbacks from managed code when some events are raised in a .NET control.
void CGraphControlView::ObjectDoubleClicked(System::Object^ sender, Northwoods::Go::GoObjectEventArgs^ e)
{
TRACE(_T(" Graph object double clicked\n"));
}
- How do I determine if the e->Object is of some class inherited from System::Object e.g. a GraphNode declared as:
public class GraphNode : GoBasicNode
?
/Juri
modified on Saturday, November 20, 2010 11:58 AM
|
|
|
|
|
Call GetType and then check the IsClass property.
|
|
|
|
|
Hi Nish,
I'm more or less a newbe in .NET and C#, could you show an example of how to do that.
Like
if (e->GetType() ..... then what ?
Regards
/Juri
|
|
|
|
|
if(e->Object->GetType()->IsClass)
{
}
|
|
|
|
|
Well if Object is declared as an object, e->Object will always inherit from an object (or be an object or a boxed object).
Do you have any sample of what you are trying to do?
Philippe Mori
|
|
|
|
|
Hi,
i'm working with a itextsharp dll and trying to put a watermark ,but this error of compilation i don't how handled it .
Working in c# is fine but with vc++ 2003 show me Error C2691: 'int __gc[]'
line : iTextSharp::text::pdf::BaseFont *watermarkFont = NULL;
what i should do ?
any ideas please .
private: void WaterMark (String *newPdf,String *PdfIndex,String *TmpPath)
{
iTextSharp::text::pdf::BaseFont *watermarkFont = NULL;
Single watermarkFontSize = 14;
Single watermarkFontOpacity = 0.9;
Single watermarkRotation = 45.0;
String *watermarkText1=NULL;
iTextSharp::text::pdf::PdfReader *reader = NULL;
iTextSharp::text::pdf::PdfStamper *stamper = NULL;
iTextSharp::text::pdf::PdfContentByte *underContent = NULL;
iTextSharp::text::Rectangle *rect = NULL;
iTextSharp::text::pdf::PdfReader *pages = NULL;
try
{
iTextSharp::text::pdf::PdfReader *reader = new iTextSharp::text::pdf::PdfReader(PdfIndex);
int Pages = reader->NumberOfPages;
iTextSharp::text::pdf::PdfStamper *stamper = new iTextSharp::text::pdf::PdfStamper(reader, new System::IO::FileStream(String::Concat(TmpPath,newPdf),System::IO::FileMode::Create));
for (int j = 1; j <= Pages; j++)
{
watermarkText1 = j.ToString();
underContent = stamper->GetOverContent(j);
underContent->BeginText();
watermarkFont = iTextSharp::text::pdf::BaseFont::CreateFont(iTextSharp::text::pdf::BaseFont::HELVETICA, System::Text::Encoding::ASCII->EncodingName , false);
underContent->SetFontAndSize(watermarkFont,6);
underContent->SetColorFill(iTextSharp::text::BaseColor::BLACK);
underContent->ShowTextAligned(iTextSharp::text::pdf::PdfContentByte::ALIGN_CENTER, watermarkText1, 300, 700, 0);
underContent->EndText();
}
stamper->Close();
reader->Close();
}
catch (Exception *ex)
{
throw ex;
}
}
|
|
|
|
|
I am using an old dll which is written in VC6 MFC( Builded with mfc42u.lib), I need to reuse the same in my C++/CLI application which is in VS2008( it use mf90u.lib)
while copying a string buufer to that old dll it cause an exception like "try to read/writing in protected meory"
String^ csMyString = gcnew String( "some value" );
MyClass* fromOldDll = new MyClass();
fromOldDll->m_csSomeString = static_cast<TCHAR*>(Marshal::StringToHGlobalUni(csMyString).ToPointer());
Is any other idea for implementing the same, it is not possible to modify the old dll
Thanks
Radhakrishnan G.
|
|
|
|
|
Unfortunately, you cannot always mix DLLs like that. One solution would be to recompile the old DLL using VC 2008.
|
|
|
|
|
hi all
in neural networks algo of face detection a term is used a lot " training neural network". what does it mean? and a file is used with extension of NNCP which is loaded first. as for as i know that file contains different patterns of faces. i wana implement the neural network algorithm but i don't understand how to train neural network and how to make this NNCp file which contains different face paterens.
any suggestions links will be appreciated.
thanks
|
|
|
|
|
See reply to other reposts.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I have a function pointer with the following signature:
typedef bool (__stdcall *CB_CheckStatus)(unsigned);
When used as follows in a native app.
bool __stdcall UpdateStatus(unsigned pctCompl)
{
printf("\r%d%%...", pctCompl);
return false;
}
And as an parameter in a native function which uses it:
DLLAPI HRESULT __stdcall ReadFile(size_t Size, BYTE* Buff, CB_CheckStatus UpdateStatus)
Can I change the parameter as a void parameter? I want to map a delegate to this function pointer so I can utilize a BackgroundWorker for a mixed-mode wrapper
How would you do that?
Thanks
|
|
|
|
|
|
I know that seemed like a bit vague, let me explain. I have in native code a callback that is used for passing to a function for means of acting as a percent complete mechanism in a native console app. The signature is as follows:
typedef bool (APIENTRY *CBUpdateValue)(unsigned PercentComplete);
That is passed as a parameter to a function that uses it for file reads and writes:
DLLAPI HRESULT APIENTRY GetFile(size_t FileSize, BYTE* Data, CBUpdateValue CompletStatus)
In the native code that uses the callback, an example of the use of the callback is
bool APIENTRY UpdateStatus(unsigned PercentComplete)
{
printf("\r%d%%...", PercentComplete);
return false;
}
The goal is to use this signature, but replace the printf call to send information to a BackgroundWorker object. It takes an unsigned and returns a bool. Because of this constraint, is it possible to use this for a BGW? I realize I have to map the function pointer to a delegate. Has anyone used something like this?
Thanks in advance
|
|
|
|
|
Hi,
this article[^] of mine explains P/Invoke, including native code calling callbacks. While all examples use C# or VB.NET, similar things are possible using C++/CLI. Pay special attention to the STDCALL keyword.
|
|
|
|
|
I should have mentioned that I am using IJW. The article provided no help but thanks anyway
|
|
|
|
|
OK. Seems like IJW is a bit of a misnomer then?
Anyway, managed methods are always called in STDCALL (there is no way to change that), your native code must adhere to that.
|
|
|
|
|
Well perhaps, but compared to using a P/Invoke solution, it seems more natural to use C++/CLI especially when interoperation with native code is required.
|
|
|
|
|
So what part are you stuck on? Converting between the function pointer/delegate? Or handling the background worker?
|
|
|
|
|
Handling the Backgroundworker!
At the risk of being wordy, let me give a little more detail. It may help.
In native code, I have a callback used as a percent complete mechanism. Its signature is below:
typedef bool (APIENTRY *CB_UpdateStatus)(unsigned PercentComplete);
The function is below:
bool APIENTRY UpdateStatus(unsigned PercentComplete)
{
printf("\r%d%%...", PercentComplete);
return false;
}
Passed as an arg to a native function: HRESULT Result = NativeFileRead(Size, Data, UpdateStatus);
I need to wrap this function so it can be used as-is in native code but when wrapped will allow use in a graphical program by use of the background worker to get status back to a UI.
I modified the function pointer signature:
typedef bool (APIENTRY *CB_UpdateStatus)(unsigned PercentComplete, void* context);
and its use by the calling function:
bool APIENTRY UpdateStatus(unsigned PercentComplete, void* context)
{
printf("\r%d%%...", PercentComplete);
return false;
}
The native function that uses the callback now has an added parameter "void* context" - it's signature is below:
DLLAPI HRESULT APIENTRY NativeFileRead(size_t DataSize, BYTE* Data, CB_UpdateStatus UpdateStatus, void* context)
In native code I just pass a NULL so it causes no harm during debug and development. In managed code I need to wrap the function and use a BGW.
In my wrapper class I have this function signature:
Wrapper::FileRead(UInt32 DataSize, String^ managedFileHandle, BackgroundWorker^ worker)
My callback in the wrapper class now looks like:
bool __stdcall UpdateStatus(unsigned PercentComplete, void* context)
{
BackgroundWorker^ worker = static_cast<BackgroundWorker^>(&context);
worker->ReportProgress(PercentComplete);
return false;
}
I want to pass in the worker to the native function.
HRESULT Result = NativeFileRead(DataSize, Data, UpdateStatus, context);
The problem is now handling the BGW for a function that expects a void pointer.
Thanks Nish
|
|
|
|