/// <summary> /// Open a Wintab context that will send packet events to a message window. /// </summary> /// <returns>Returns true if successful.</returns> public bool Open() { // Get the handle of the anonymous MessageEvents window. This is a // static (global) object, so there's only one of these at a time. WMessageEvents.Start(); HWND hwnd = WMessageEvents.WindowHandle; try { m_hCTX = WNativeMethods.WTOpen(hwnd, ref m_logContext, true); } catch (Exception ex) { throw new Exception("FAILED OpenContext: " + ex.ToString()); } return(m_hCTX.IsValid); }
/// <summary> /// Initialize this data object. /// </summary> /// <param name="context_I">logical context for this data object</param> private void Init(WContext context_I) { try { if (context_I == null) { throw new Exception("Trying to init CWintabData with null context."); } m_context = context_I; // Watch for the Wintab WT_PACKET event. WMessageEvents.WatchMessage((int)EWintabEventMessage.WT_PACKET); } catch (Exception ex) { throw new Exception("FAILED CWintabData.Init: " + ex.ToString()); } }
/// <summary> /// Close the context for this object. /// /// </summary> /// <returns>true if context successfully closed</returns> public bool Close() { bool status = false; try { if (!m_hCTX.IsValid) { throw new Exception("CloseContext: invalid context"); } status = WNativeMethods.WTClose(m_hCTX); m_hCTX = HCTX.Zero; m_logContext = new WintabLogContext(); WMessageEvents.Close(); } catch (Exception ex) { throw new Exception("FAILED CloseContext: " + ex.ToString()); } return(status); }