Click here to Skip to main content
15,867,756 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionDateTime->Parse Pin
VonHagNDaz16-May-11 4:34
VonHagNDaz16-May-11 4:34 
AnswerRe: DateTime->Parse [modified] Pin
Mark Salsbery16-May-11 7:26
Mark Salsbery16-May-11 7:26 
GeneralRe: DateTime->Parse Pin
VonHagNDaz16-May-11 10:56
VonHagNDaz16-May-11 10:56 
GeneralRe: DateTime->Parse Pin
Mark Salsbery16-May-11 12:57
Mark Salsbery16-May-11 12:57 
GeneralRe: DateTime->Parse Pin
VonHagNDaz17-May-11 1:57
VonHagNDaz17-May-11 1:57 
Question[C++/CLI]problem with unmanaged C library and callback functions Pin
re dei giovani16-May-11 3:39
re dei giovani16-May-11 3:39 
AnswerRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
John Schroedl16-May-11 5:22
professionalJohn Schroedl16-May-11 5:22 
GeneralRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
re dei giovani17-May-11 3:27
re dei giovani17-May-11 3:27 
Hi John,
thanks to help me.
I followed your advice and I've read How to: "Marshal Callbacks and Delegates Using C++ Interop"
I've tried to work on my application.
I' ve done this:

1) I decided to create a simple example without wrapper.h. So I' working only in a Form1.h.
2) Since my form1.exe work with the library of an electronic device and I constantly receive
the events returned by this device, I thinked to put the define of delegate, IntPtr and the callback unmanaged function as form1 private attributes and I declared them in the Form1 constructor:

Form1(void)
{
InitializeComponent();
_native_handle=new gcroot<Form1^>();
evento=gcnew eventRegistered(cdeclEventCallback);
gch =GCHandle::Alloc(evento);
ip=Marshal::GetFunctionPointerForDelegate(evento);
cb=static_cast<eventCallback_t>(ip.ToPointer());
GC::Collect();
this->registerEvent();

}

3) After, in constructor, I call the function registerEvent(). In this function I put the calling at the library function "TED_PixRad_RegisterEventCallback":

void Form1::registerEvent()
{
error_status er_return=TED_PixRad_RegisterEventCallback(cb,_native_handle);
if (this->TestError(er_return)){
this->button2->Visible=true;
}

}


4) the callback implementation in my Form1 is this:
void cdeclEventCallback(const event_id eventID, const Event *eventData, void* customData )
{
gcroot<Form1^> & native_handle = *((gcroot<Form1^>*)customData);
native_handle->processEvent(eventID,"evento");
}

Oss1: I think I must using _native_handle and not passing this (Form1 refer).
Oss3: processEvent is an internal function of Form1 that receive the code eventID and write the code mean in a form1 label.
Oss2: The compilation is without errors or warnings.

Assuming that I can not debug because the device connected to a machine other than the development,I have seen that the device gives me error event handling return
In particular, writing message on Form1 labels I' ve seen that I cannot enter in cdeclEventCallback function and I cannot call processEvent().

I can not understand what could be in error and this is a logic error in using Marshal:: GetFunctionPointerForDelegate in my example.


Have you got any advice for me?

Thanks for the help
GeneralRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
re dei giovani17-May-11 3:55
re dei giovani17-May-11 3:55 
AnswerRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
Luc Pattyn17-May-11 4:22
sitebuilderLuc Pattyn17-May-11 4:22 
GeneralRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
re dei giovani18-May-11 2:15
re dei giovani18-May-11 2:15 
AnswerRe: [C++/CLI]problem with unmanaged C library and callback functions Pin
Luc Pattyn18-May-11 2:46
sitebuilderLuc Pattyn18-May-11 2:46 
QuestionChanging a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
TrevorPT13-May-11 7:20
TrevorPT13-May-11 7:20 
AnswerRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
John Schroedl13-May-11 11:01
professionalJohn Schroedl13-May-11 11:01 
GeneralRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
TrevorPT13-May-11 11:59
TrevorPT13-May-11 11:59 
GeneralRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
John Schroedl13-May-11 14:31
professionalJohn Schroedl13-May-11 14:31 
GeneralRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
TrevorPT16-May-11 11:19
TrevorPT16-May-11 11:19 
AnswerRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
jschell13-May-11 12:32
jschell13-May-11 12:32 
AnswerRe: Changing a C++/CLI project from static lib to DLL causing app to crash under Win7 but works under WinXP Pin
TrevorPT17-May-11 6:12
TrevorPT17-May-11 6:12 
QuestionPassing an ArrayList by Reference? [modified] Pin
VonHagNDaz13-May-11 2:39
VonHagNDaz13-May-11 2:39 
AnswerRe: Passing an ArrayList by Reference? Pin
John Schroedl13-May-11 3:29
professionalJohn Schroedl13-May-11 3:29 
GeneralRe: Passing an ArrayList by Reference? Pin
VonHagNDaz13-May-11 4:15
VonHagNDaz13-May-11 4:15 
QuestionTimer() - anything faster? Pin
Cyclone_S12-May-11 10:47
Cyclone_S12-May-11 10:47 
AnswerRe: Timer() - anything faster? Pin
Sander Rossel12-May-11 10:57
professionalSander Rossel12-May-11 10:57 
GeneralRe: Timer() - anything faster? Pin
Cyclone_S12-May-11 13:49
Cyclone_S12-May-11 13:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.