Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
2
Erster Beitrag:
vor 7 Jahren, 9 Monaten
Letzter Beitrag:
vor 4 Jahren, 10 Monaten
Beteiligte Autoren:
Jeff Graham, Leo

.NET DLL - event's arguments and object collections

Startbeitrag von Leo am 01.11.2010 18:27

Hi,

I'm trying to use a .NET DLL into a windev 12 project (tell me if my problem could be solved with 14 or 15). I have to issues i can't work around:

1) I have an event in my .net library that returns an Image as an argument. I'd like to catch that event, but I cant figure how to add the event with the argument in windev. My .NET argument has this signature:

Public Event evtMyNetEvent(ByVal MyImage As Drawing.Bitmap)

As the windev documentation says, i have to add the event handler. If I define something like this, the project compiles and I can run the application:

MyObject:add_evtMyNetEvent (DotNetDelegate("MyEvent", "MyNetObject.evtMyNetEvent"))

But I get a run time error, something about the missing argument. The windev documentation says that the definition should be something like this:

MyObject:add_evtMyNetEvent (DotNetDelegate("MyEvent", "MyNetObject.evtMyNetEvent"))

I can't define the without getting a design time error. I don't know what should be en this case. Anyone could help? And how does my windev's procedure definition has to be to capture that event an put that image in a picture control?

2) My .NET libraries has several functions returning object collections:

System.Collections.ObjectModel.Collection(Of MyObject)

How can I retrieve that collection in windev, and how can I iterate its elements?


Regards!

Antworten:

Old Post -Re: .NET DLL - event's arguments and object collections

Greetings C# Developers,

I am having a similar problem with DotNetDelegate. I can't create a delegate that is accepted by the .NET assembly. I have a C# example that works. I can access many of the initialization functions in the .NET assembly except for setting the callbacks. See below. I show only the "Streaming" callback for example purposes.

If anyone can help, I would gladly pay for help as long as I can afford it!

Thanks,
Jeff

My WD code and procedure:

// Test button code
nResult is int

nResult = gclPalm.DNET_BioAPI_SetGUICallbacks(gnHandle, ...
DotNetDelegate(StreamingCallback, "DNET_BIOAPI_GUI_STREAMING_CALLBACK"),WIN_Pvs_Net, ...
DotNetDelegate(StateCallback, "DNET_BIOAPI_GUI_STATE_CALLBACK"),WIN_Pvs_Net)
IF nResult = PalmSecureConstant::DNET_BioAPI_OK
IF gbVerbose THEN Info("Set_GUI_Callbacks OK #1")
ReturnToCapture()
ELSE
ShowError(nResult,"DNET_BioAPI_SetGUICallbacks #1")
END

// Local procedure
PROCEDURE StreamingCallback(pclGuiStreamingCallbackCtx is object dynamic, pclBitmap is DNET_BioAPI_GUI_BITMAP)
IMG_Palm = pclBitmap.Bitmap.Data
iResult is unsigned int = 0
RESULT iResult


C# Example code:

//Set delegate methods
///////////////////////////////////////////////////////////////////////////
try
{
stResult.result = m_PalmSecureIf.DNET_BioAPI_SetGUICallbacks(
m_ModuleHandle,
StreamingCallback,
this,
StateCallback,
this
);
if (stResult.result != PalmSecureConstant.DNET_BioAPI_OK)
{
m_PalmSecureIf.DNET_PvAPI_GetErrorInfo(stResult.errInfo);
Ps_Sample_Apl_CS_ErrorMessage(stResult.errInfo);
return false;
}
}
catch (PalmSecureException e)
{
MessageBox.Show(
e.Message
+ "Error No: " + e.ErrNumber
);
return false;
}
///////////////////////////////////////////////////////////////////////////


///
/// Process when streaming callback function is called.
/// This callback only show bitmap image.
///
/// Context set by BioAPI_SetGUICallback()
/// Silhouette image
///
uint StreamingCallback(
object GuiStreamingCallbackCtx,
DNET_BioAPI_GUI_BITMAP Bitmap
)
{
//Handle a guidance image
///////////////////////////////////////////////////////////////////////////
MemoryStream silhouetteInfo = null;

silhouetteInfo = new MemoryStream();
silhouetteInfo.Write(
Bitmap.Bitmap.Data,
0,
(int)Bitmap.Bitmap.Length
);

Ps_Sample_Apl_CS_ShowSilhouette(silhouetteInfo);

silhouetteInfo.Dispose();
///////////////////////////////////////////////////////////////////////////

return PalmSecureConstant.DNET_BioAPI_OK;
}


von Jeff Graham - am 05.10.2013 16:04
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.