netripper

netripper

Jun 29th, 2009
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1.     public class MyMessageWindow : MessageWindow
  2.     {
  3.         private FMTest fmtest = null;
  4.  
  5.         public MyMessageWindow(FMTest fmtest)
  6.         {
  7.             this.fmtest = fmtest;
  8.         }
  9.  
  10.         protected override void WndProc(ref Message m)
  11.         {
  12.             base.WndProc(ref m);
  13.  
  14.             if (m.Msg == GFMAPI.WM_FMNOTIFICATION)
  15.             {
  16.                 // m.WParam holds the IntPtr to FMDevice in case you're writing a multi-device application
  17.                 fmtest.ReceivedNotification();
  18.             }
  19.         }
  20.     }
  21.  
  22.     public class FMTest : IDisposable
  23.     {
  24.         private IntPtr FMDevice = IntPtr.Zero;
  25.  
  26.         public void Init()
  27.         {
  28.             FMDevice = GFMAPI.FMOpen(0);
  29.             GFMAPI.FMRegisterNotification(FMDevice, new MyMessageWindow(this).Hwnd, GFMAPI.WM_FMNOTIFICATION);
  30.         }
  31.  
  32.         public void ReceivedNotification()
  33.         {
  34.             TagFM_NOTIFICATION notification;
  35.             GFMAPI.FMGetNotification(FMDevice, out notification);
  36.         }
  37.  
  38.         public void Dispose()
  39.         {
  40.             if (FMDevice != IntPtr.Zero)
  41.             {
  42.                 GFMAPI.FMClose(FMDevice);
  43.                 FMDevice = IntPtr.Zero;
  44.             }
  45.         }
  46.     }
Add Comment
Please, Sign In to add comment