Click here to Skip to main content
15,885,216 members
Home / Discussions / C#
   

C#

 
GeneralC# and Managed DirectX Invalid Rectangle Pin
EvilDingo2-Jun-03 2:10
EvilDingo2-Jun-03 2:10 
GeneralRe: C# and Managed DirectX Invalid Rectangle Pin
James T. Johnson2-Jun-03 10:59
James T. Johnson2-Jun-03 10:59 
GeneralRe: C# and Managed DirectX Invalid Rectangle Pin
EvilDingo3-Jun-03 1:36
EvilDingo3-Jun-03 1:36 
GeneralRe: C# and Managed DirectX Invalid Rectangle Pin
Anonymous3-Jun-03 1:58
Anonymous3-Jun-03 1:58 
GeneralRe: C# and Managed DirectX Invalid Rectangle Pin
James T. Johnson3-Jun-03 2:00
James T. Johnson3-Jun-03 2:00 
GeneralRe: C# and Managed DirectX Invalid Rectangle Pin
EvilDingo3-Jun-03 4:27
EvilDingo3-Jun-03 4:27 
GeneralSelected row from a ListView Pin
quicksilver02022-Jun-03 1:03
quicksilver02022-Jun-03 1:03 
Generalexisting code from c++ Pin
stonee741-Jun-03 22:26
stonee741-Jun-03 22:26 
Hi There,

I hope somebody can give me some good advices:

I need to use an existing Programming Interface which is available whether as a 'COM object dll' or' 2 C++ header files' under .NET.
I used the COM object, this works quite nice in VB.NET and as well in C#, using the System.Runtime.InteropServices.TypeLibConverter class.
In fact everything will be done automatically and i can use my Interface like in the unmanaged world, great!

The main problem is, I develop an application on a PocketPC, under the .NET Compact Framwork.
Since this System.Runtime.InteropServices.TypeLibConverter class does not exist under the .NET CF, i need to use the C++ interface, but this gives me headache.

So far I found out the following:

1)use (unmanaged) C++ Code in the managed world of .NET
2)use the built-in .NET runtime interop facilities to talk directly to the existing code.
3)wrap the code using the managed extensions to C++.
4)rewrite the code in a .NET language.

I wanted to go in direction 4) originally, but I'm no longer sure what makes really sense on this one...

My interface is consisting of 3 header files. 2 of them are simply describing enumerations and structs.
The third one consists of helper classes in C++ which are easing the use of this interface a lot.


I assume that when I would go the wrapping way, that I would only need to wrap the classes I directly touch from my App in c#?

If yes then I woud need to wrap only 2 classes?

What way to go would be the best, wrapping interop, rewrite?
But how would I do that best? Could somebody give me an idea how to do that?


Thanks a lot,

stonee




Attached the sample classes:

<br />
//sender.h<br />
<br />
Class1 to wrap:<br />
// Macro to compact duplicate code<br />
<br />
#define DATA_PACKET &Data.DataPacket, sizeof(Data.DataPacket)<br />
<br />
class Command<br />
<br />
{<br />
<br />
public:<br />
<br />
CESAPICommand() {TRACE(_T("CESAPICommand()\n"));}<br />
<br />
<br />
virtual bool SendPacket(void* PacketStart, long PacketSize) <br />
<br />
{ <br />
<br />
TRACE(_T("Virtual SendPacket() called!\n"));<br />
<br />
<br />
return false; <br />
<br />
};<br />
<br />
<br />
// Send commands <br />
<br />
bool inline Init() {CInit Data; return SendPacket(DATA_PACKET);}<br />
<br />
<br />
<br />
<br />
bool inline SetBox(double dX1, double dY1, double dZ1, double dX2, double dY2, double dZ2)<br />
<br />
{CSetBox Data(dX1, dY1, dZ1, dX2, dY2, dZ2); return SendPacket(DATA_PACKET);}<br />
<br />
<br />
};<br />
<br />
<br />
<br />
Class2 to wrap:<br />
<br />
///Receiver.h<br />
<br />
class Receive<br />
<br />
{<br />
<br />
public:<br />
<br />
Receive() {TRACE(_T("Receive()\n"));}<br />
<br />
protected:<br />
<br />
<br />
<br />
bool ReceiveData(void* packetStart, long packetSize) <br />
<br />
{ <br />
<br />
<br />
if (packetStart && packetSize > 0)<br />
<br />
return ProcessData(packetStart, packetSize); <br />
<br />
else<br />
<br />
return false;<br />
<br />
};<br />
<br />
protected:<br />
<br />
virtual void OnInitializeAnswer() {TRACE(_T("virtual OnInitializeAnswer() call\n"));}<br />
<br />
virtual void OnGetBoxAnswer(const BoxRegionDataT& boxRegionData) {TRACE(_T("virtual OnGetBoxRegionParamsAnswer() call\n"));}<br />
<br />
<br />
<br />
protected:<br />
<br />
// It is supposed that one and only one and COMPLETE data <br />
<br />
// packet is being passed to this function.<br />
<br />
// Parameter 'lBytes' just passed for diagnostics purpose<br />
<br />
//<br />
<br />
virtual bool ProcessData(void *pDataArrived, long lBytes)<br />
<br />
{<br />
<br />
<br />
<br />
        PacketHeaderT *pData = (PacketHeaderT*)pDataArrived;<br />
<br />
// Diagnostics and overflow prevention.<br />
<br />
        if (pData->lPacketSize != lBytes)<br />
<br />
{<br />
<br />
            TRACE2("PacketSize (%ld) differs from TotalBytes (%ld) !\n", pData->lPacketSize, lBytes);<br />
<br />
            return false; // causes to signal a data receive error<br />
<br />
} // if<br />
<br />
switch (pData->type)<br />
<br />
{<br />
<br />
case ES_DT_Command: // A 'command- type' answer has arrived<br />
<br />
{<br />
<br />
// call general virtual function for commands<br />
<br />
//<br />
<br />
<br />
<br />
OnCommandAnswer(*(BasicCommandRT *)pData); // uses reference parameter. see comment in header file<br />
<br />
// decode type of command<br />
<br />
BasicCommandRT *pData2 = (BasicCommandRT *)pData;<br />
<br />
// handle error<br />
<br />
if (pData2->status != ES_RS_AllOK)<br />
<br />
return true; // Exit here, but make sure pData2->status gets forwared somehow.<br />
<br />
// This is done on using the general OnCommandAnswer() function above. <br />
<br />
<br />
switch (pData2->command)<br />
<br />
{<br />
<br />
case ES_C_ExitApplication:<br />
<br />
OnExitApplicationAnswer();<br />
<br />
break;<br />
<br />
<br />
case ES_C_GetSystemStatus:<br />
<br />
OnGetSystemStatusAnswer(((GetSystemStatusRT*)pDataArrived)->lastResultStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->trackerProcessorStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->laserStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->admStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->esVersionNumber,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->weatherMonitorStatus,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->lFlagsValue,<br />
<br />
((GetSystemStatusRT*)pDataArrived)->lTrackerSerialNumber);<br />
<br />
break;<br />
<br />
<br />
<br />
<br />
<br />
case Init<br />
<br />
OnInitializeAnswer();<br />
<br />
break;<br />
<br />
<br />
<br />
case ES_C_GetReflectors:<br />
<br />
OnGetReflectorsAnswer(((GetReflectorsRT*)pDataArrived)->iTotalReflectors,<br />
<br />
((GetReflectorsRT*)pDataArrived)->iInternalReflectorId,<br />
<br />
((GetReflectorsRT*)pDataArrived)->targetType,<br />
<br />
((GetReflectorsRT*)pDataArrived)->dSurfaceOffset,<br />
<br />
((GetReflectorsRT*)pDataArrived)->cReflectorName);<br />
<br />
break;<br />
<br />
<br />
// Do not treat unknown packets as error - just ignore them<br />
<br />
TRACE(_T("Unexpected data received (ignored)\n"));<br />
<br />
break;<br />
<br />
} // switch<br />
<br />
return true;<br />
<br />
} // ProcessData()<br />
<br />
};

GeneralGif compression using Save method on bitmap class Pin
christiantoivola1-Jun-03 22:08
christiantoivola1-Jun-03 22:08 
GeneralRe: Gif compression using Save method on bitmap class Pin
Richard Deeming1-Jun-03 23:33
mveRichard Deeming1-Jun-03 23:33 
Generalshow tooltip Pin
grv5751-Jun-03 20:16
grv5751-Jun-03 20:16 
GeneralRe: show tooltip Pin
Singh, Manish2-Jun-03 20:44
Singh, Manish2-Jun-03 20:44 
GeneralSystem.NullReferenceException in RichTextBox while dynamically adding text Pin
CNU1-Jun-03 19:58
CNU1-Jun-03 19:58 
GeneralCreate a remort object in C# Pin
Gaurika Wijeratne1-Jun-03 17:54
Gaurika Wijeratne1-Jun-03 17:54 
GeneralRe: Create a remort object in C# Pin
Kannan Kalyanaraman1-Jun-03 22:17
Kannan Kalyanaraman1-Jun-03 22:17 
GeneralRe: Create a remort object in C# Pin
Gaurika Wijeratne1-Jun-03 22:39
Gaurika Wijeratne1-Jun-03 22:39 
Generalurgent help needed, event handler Pin
mtrx1-Jun-03 17:35
mtrx1-Jun-03 17:35 
GeneralRe: urgent help needed, event handler Pin
Ray Cassick1-Jun-03 17:55
Ray Cassick1-Jun-03 17:55 
GeneralRe: urgent help needed, event handler Pin
mtrx2-Jun-03 3:41
mtrx2-Jun-03 3:41 
GeneralRe: urgent help needed, event handler Pin
shaunAustin3-Jun-03 1:25
shaunAustin3-Jun-03 1:25 
GeneralCustom Control Events Pin
Tym!1-Jun-03 12:05
Tym!1-Jun-03 12:05 
GeneralSome Progress, Sound good? Pin
Tym!1-Jun-03 13:23
Tym!1-Jun-03 13:23 
QuestionGDI+, How to stop antialias? Pin
FruitBatInShades31-May-03 23:51
FruitBatInShades31-May-03 23:51 
AnswerRe: GDI+, How to stop antialias? Pin
leppie1-Jun-03 0:07
leppie1-Jun-03 0:07 
GeneralRe: GDI+, How to stop antialias? Pin
FruitBatInShades1-Jun-03 0:44
FruitBatInShades1-Jun-03 0:44 

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.