Serialization of Mouse cursors over network
Posted
by Ehtsham
on Stack Overflow
See other posts from Stack Overflow
or by Ehtsham
Published on 2010-06-09T07:16:59Z
Indexed on
2010/06/09
7:22 UTC
Read the original article
Hit count: 260
c#
|serialization
hi I am working a client/server application in C#. My server Capture current Mouse Cursors and send these to client so that Cursor of the cleint also chage accordingly.I can detect windows Cursors and serialize them over binaryformatter. it works fine but but problem is there are many cursors that can not be detected like mspaint cursors so i have to take its handler and create the cursor and its x nad y hotspots and add them in an arraylist and serialize it over network but after 10 to 15 minute it thorws exception "Error HRESULT E_FAIL has been returned from a call to a COM Compeonet" and cleint throws the exception of "method of invocation" Can anybody guid me what going wrong ort some better way to do like this Some code is here
IntPtr curInfo = GetCurrentCursor();
Cursor cur;
Icon ic;
byte cursor = 0;
if (curInfo != null && curInfo.ToInt32() != 0)
{
cur = CheckForCusrors(curInfo);
try
{
if (!isLinuxClient)
{
if (cur == null)
{
PlatformInvokeUSER32.GetIconInfo(curInfo, out temp);
ic = Icon.FromHandle(curInfo);
//bitmap = ic.ToBitmap();
ArrayList ar = new ArrayList();
ar.Add(ic);
ar.Add(temp.xHotspot);
ar.Add(temp.yHotspot);
b.Serialize(stm, ar);
}
else
{
ArrayList ar = new ArrayList();
ar.Add(cur);
b.Serialize(stm, ar);
}
}
public Cursor CheckForCusrors(IntPtr hCur)
{
if (hCur == Cursors.AppStarting.Handle)
return Cursors.AppStarting;
else if (hCur == Cursors.Arrow.Handle)
return Cursors.Arrow;
.
.
.
else if (hCur == Cursors.PanWest.Handle)
return Cursors.PanWest;
return null;
}
`
© Stack Overflow or respective owner