Exemple #1
0
        /// <summary>
        /// Returns one packet of Wintab data from the packet queue.
        /// </summary>
        /// <param name="hCtx_I">Wintab context to be used when asking for the data</param>
        /// <param name="pktID_I">Identifier for the tablet event packet to return.</param>
        /// <returns>Returns a data packet with non-null context if successful.</returns>
        public WintabPacket GetDataPacket(HCTX hCtx_I, UInt32 pktID_I)
        {
            IntPtr       buf    = CMemUtils.AllocUnmanagedBuf(Marshal.SizeOf(typeof(WintabPacket)));
            WintabPacket packet = new WintabPacket();

            if (pktID_I == 0)
            {
                throw new Exception("GetDataPacket - invalid pktID");
            }

            CheckForValidHCTX("GetDataPacket");

            if (CWintabFuncs.WTPacket(hCtx_I, pktID_I, buf))
            {
                packet = (WintabPacket)Marshal.PtrToStructure(buf, typeof(WintabPacket));
            }
            else
            {
                //
                // If fails, make sure context is zero.
                //
                packet.pkContext = HCTX.Zero;
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return(packet);
        }
Exemple #2
0
        /// <summary>
        /// Sets an extension control property image (if supported by tablet).
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="propertyID_I">ID of the property being set</param>
        /// <param name="value_I">value of the property being set (a string)</param>
        /// <returns>true if successful</returns>
        public static bool ControlPropertySetImage(
            HCTX context_I,
            byte extTagIndex_I,
            byte tabletIndex_I,
            byte controlIndex_I,
            byte functionIndex_I,
            ushort propertyID_I,
            String imageFilePath_I
            )
        {
            bool retStatus = false;
            WTExtensionImageProperty extProperty = new WTExtensionImageProperty();
            IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty);

            try
            {
                byte[] imageBytes             = null;
                System.Drawing.Image newImage = Image.FromFile(imageFilePath_I);

                if (newImage == null)
                {
                    MessageBox.Show("Oops - couldn't find/read image: " + imageFilePath_I);
                    return(false);
                }

                using (MemoryStream ms = new MemoryStream())
                {
                    newImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    imageBytes = ms.ToArray();
                }

                extProperty.extBase.version       = 0;
                extProperty.extBase.tabletIndex   = tabletIndex_I;
                extProperty.extBase.controlIndex  = controlIndex_I;
                extProperty.extBase.functionIndex = functionIndex_I;
                extProperty.extBase.propertyID    = propertyID_I;
                extProperty.extBase.reserved      = 0;
                extProperty.extBase.dataSize      = (uint)imageBytes.Length;
                extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyImageMaxDataBytes];

                // Send image as an array of bytes.
                System.Buffer.BlockCopy(imageBytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize);

                Marshal.StructureToPtr(extProperty, buf, false);

                retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return(retStatus);
        }
Exemple #3
0
        /// <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.
            HWND hwnd = MessageEvents.WindowHandle;

            m_hCTX = CWintabFuncs.WTOpen(hwnd, ref m_logContext, true);

            return(m_hCTX.IsValid);
        }
Exemple #4
0
        /// <summary>
        /// Open a Wintab context to the specified hwnd.
        /// </summary>
        /// <param name="hwnd_I">parent window for the context</param>
        /// <param name="enable_I">true to enable, false to disable</param>
        /// <returns>Returns non-zero context handle if successful.</returns>
        public HCTX Open(HWND hwnd_I, bool enable_I)
        {
            try {
                m_hCTX = WNativeMethods.WTOpen(hwnd_I, ref m_logContext, enable_I);
            } catch (Exception ex) {
                throw new Exception("FAILED OpenContext: " + ex.ToString());
            }

            return(m_hCTX);
        }
Exemple #5
0
        /// <summary>
        /// Open a Wintab context to the specified hwnd.
        /// </summary>
        /// <param name="hwnd_I">parent window for the context</param>
        /// <param name="enable_I">true to enable, false to disable</param>
        /// <returns>Returns non-zero context handle if successful.</returns>
        public HCTX Open(HWND hwnd_I, bool enable_I)
        {
            try
            {
                m_hCTX = CWintabFuncs.WTOpenA(hwnd_I, ref m_logContext, enable_I);
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED OpenContext: " + ex.ToString());
            }

            return(m_hCTX);
        }
Exemple #6
0
        /// <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);
        }
Exemple #7
0
        /// <summary>
        /// Close the context for this object.
        /// </summary>
        /// <returns>true if context successfully closed</returns>
        public bool Close()
        {
            bool status = false;

            if (!m_hCTX.IsValid)
            {
                throw new Exception("CloseContext: invalid context");
            }

            status       = CWintabFuncs.WTClose(m_hCTX);
            m_hCTX       = HCTX.Zero;
            m_logContext = new WintabLogContext();

            return(status);
        }
Exemple #8
0
        /// <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.
            HWND hwnd = MessageEvents.WindowHandle;

            try
            {
                m_hCTX = CWintabFuncs.WTOpenA(hwnd, ref m_logContext, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED OpenContext: " + ex.ToString());
            }

            return(m_hCTX > 0);
        }
Exemple #9
0
        /// <summary>
        /// Sets an extension control property string.
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="propertyID_I">ID of the property being set</param>
        /// <param name="value_I">value of the property being set (a string)</param>
        /// <returns>true if successful</returns>
        public static bool ControlPropertySet(
            HCTX context_I,
            byte extTagIndex_I,
            byte tabletIndex_I,
            byte controlIndex_I,
            byte functionIndex_I,
            ushort propertyID_I,
            String value_I
            )
        {
            bool retStatus = false;
            WTExtensionProperty extProperty = new WTExtensionProperty();
            IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty);

            try
            {
                // Convert unicode string value_I to UTF8-encoded bytes
                byte[] utf8Bytes = System.Text.Encoding.Convert(Encoding.Unicode, Encoding.UTF8, Encoding.Unicode.GetBytes(value_I));

                extProperty.extBase.version       = 0;
                extProperty.extBase.tabletIndex   = tabletIndex_I;
                extProperty.extBase.controlIndex  = controlIndex_I;
                extProperty.extBase.functionIndex = functionIndex_I;
                extProperty.extBase.propertyID    = propertyID_I;
                extProperty.extBase.reserved      = 0;
                extProperty.extBase.dataSize      = (uint)utf8Bytes.Length;
                extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyMaxDataBytes];

                // Send input value as an array of UTF8-encoded bytes.
                System.Buffer.BlockCopy(utf8Bytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize);

                Marshal.StructureToPtr(extProperty, buf, false);

                retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return(retStatus);
        }
Exemple #10
0
        /// <summary>
        /// Get a property value from an extension.
        /// </summary>
        /// <param name="context_I">Wintab context</param>
        /// <param name="extTagIndex_I">extension index tag</param>
        /// <param name="tabletIndex_I">tablet index</param>
        /// <param name="controlIndex_I">control index on the tablet</param>
        /// <param name="functionIndex_I">function index on the control</param>
        /// <param name="propertyID_I">ID of the property requested</param>
        /// <param name="result_O">value of the property requested</param>
        /// <returns>true if property obtained</returns>
        public static bool ControlPropertyGet(
            HCTX context_I,
            byte extTagIndex_I,
            byte tabletIndex_I,
            byte controlIndex_I,
            byte functionIndex_I,
            ushort propertyID_I,
            ref UInt32 result_O
            )
        {
            bool retStatus = false;
            WTExtensionProperty extProperty = new WTExtensionProperty();
            IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty);

            extProperty.extBase.version       = 0;
            extProperty.extBase.tabletIndex   = tabletIndex_I;
            extProperty.extBase.controlIndex  = controlIndex_I;
            extProperty.extBase.functionIndex = functionIndex_I;
            extProperty.extBase.propertyID    = propertyID_I;
            extProperty.extBase.reserved      = 0;
            extProperty.extBase.dataSize      = (uint)System.Runtime.InteropServices.Marshal.SizeOf(result_O);

            Marshal.StructureToPtr(extProperty, buf, false);

            try
            {
                bool status = CWintabFuncs.WTExtGet((UInt32)context_I, (UInt32)extTagIndex_I, buf);

                if (status)
                {
                    WTExtensionProperty retProp = (WTExtensionProperty)Marshal.PtrToStructure(buf, typeof(WTExtensionProperty));
                    result_O  = retProp.data[0];
                    retStatus = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED ControlPropertyGet: " + ex.ToString());
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return(retStatus);
        }
Exemple #11
0
        /// <summary>
        /// Sets an extension control property value.
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="propertyID_I">ID of the property being set</param>
        /// <param name="value_I">value of the property being set</param>
        /// <returns>true if successful</returns>
        public static bool ControlPropertySet(
            HCTX context_I,
            byte extTagIndex_I,
            byte tabletIndex_I,
            byte controlIndex_I,
            byte functionIndex_I,
            ushort propertyID_I,
            UInt32 value_I
            )
        {
            bool retStatus = false;
            WTExtensionProperty extProperty = new WTExtensionProperty();
            IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty);

            try
            {
                byte[] valueBytes = BitConverter.GetBytes(value_I);

                extProperty.extBase.version       = 0;
                extProperty.extBase.tabletIndex   = tabletIndex_I;
                extProperty.extBase.controlIndex  = controlIndex_I;
                extProperty.extBase.functionIndex = functionIndex_I;
                extProperty.extBase.propertyID    = propertyID_I;
                extProperty.extBase.reserved      = 0;
                extProperty.extBase.dataSize      = (uint)System.Runtime.InteropServices.Marshal.SizeOf(value_I);
                extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyMaxDataBytes];

                // Send input value as an array of bytes.
                System.Buffer.BlockCopy(valueBytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize);

                Marshal.StructureToPtr(extProperty, buf, false);

                retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return(retStatus);
        }
Exemple #12
0
        /// <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);
        }
Exemple #13
0
        /// <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 == 0)
                {
                    throw new Exception("CloseContext: invalid context");
                }

                status       = CWintabFuncs.WTClose(m_hCTX);
                m_hCTX       = 0;
                m_logContext = new WintabLogContext();
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED CloseContext: " + ex.ToString());
            }

            return(status);
        }
Exemple #14
0
        /// <summary>
        /// Returns one packet of WintabPacketExt data from the packet queue.
        /// </summary>
        /// <param name="hCtx_I">Wintab context to be used when asking for the data</param>
        /// <param name="pktID_I">Identifier for the tablet event packet to return.</param>
        /// <returns>Returns a data packet with non-null context if successful.</returns>
        public WintabPacketExt GetDataPacketExt(HCTX hCtx_I, UInt32 pktID_I)
        {
            int    size = (int)(Marshal.SizeOf(new WintabPacketExt()));
            IntPtr buf  = CMemUtils.AllocUnmanagedBuf(size);

            WintabPacketExt[] packets = null;

            try
            {
                bool status = false;

                if (pktID_I == 0)
                {
                    throw new Exception("GetDataPacket - invalid pktID");
                }

                CheckForValidHCTX("GetDataPacket");
                status = CWintabFuncs.WTPacket(hCtx_I, pktID_I, buf);

                if (status)
                {
                    packets = CMemUtils.MarshalDataExtPackets(1, buf);
                }
                else
                {
                    // If fails, make sure context is zero.
                    packets[0].pkBase.nContext = HCTX.Zero;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED GetDataPacketExt: " + ex.ToString());
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return(packets[0]);
        }
        /// <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 == 0)
                {
                    throw new Exception("CloseContext: invalid context");
                }

                status = CWintabFuncs.WTClose(m_hCTX);
                m_hCTX = 0;
                m_logContext = new WintabLogContext();
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED CloseContext: " + ex.ToString());
            }

            return status;
        }
        /// <summary>
        /// Sets an extension control property image (if supported by tablet).
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="propertyID_I">ID of the property being set</param>
        /// <param name="value_I">value of the property being set (a string)</param>
        /// <returns>true if successful</returns>
        public static bool ControlPropertySetImage(
            HCTX context_I,
            byte extTagIndex_I,
            byte tabletIndex_I,
            byte controlIndex_I,
            byte functionIndex_I,
            ushort propertyID_I,
            String imageFilePath_I
            )
        {
            bool retStatus = false;
            WTExtensionImageProperty extProperty = new WTExtensionImageProperty();
            IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty);

            try
            {
                byte[] imageBytes = null;
                System.Drawing.Image newImage = Image.FromFile(imageFilePath_I);

                if (newImage == null)
                {
                    MessageBox.Show("Oops - couldn't find/read image: " + imageFilePath_I);
                    return false;
                }

                using (MemoryStream ms = new MemoryStream())
                {
                    newImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    imageBytes = ms.ToArray();
                }

                extProperty.extBase.version = 0;
                extProperty.extBase.tabletIndex = tabletIndex_I;
                extProperty.extBase.controlIndex = controlIndex_I;
                extProperty.extBase.functionIndex = functionIndex_I;
                extProperty.extBase.propertyID = propertyID_I;
                extProperty.extBase.reserved = 0;
                extProperty.extBase.dataSize = (uint)imageBytes.Length;
                extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyImageMaxDataBytes];

                // Send image as an array of bytes.
                System.Buffer.BlockCopy(imageBytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize);

                Marshal.StructureToPtr(extProperty, buf, false);

                retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return retStatus;
        }
        /// <summary>
        /// Sets an extension control property string.
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="propertyID_I">ID of the property being set</param>
        /// <param name="value_I">value of the property being set (a string)</param>
        /// <returns>true if successful</returns>
        public static bool ControlPropertySet(
            HCTX context_I,
            byte extTagIndex_I,
            byte tabletIndex_I,
            byte controlIndex_I,
            byte functionIndex_I,
            ushort propertyID_I,
            String value_I
            )
        {
            bool retStatus = false;
            WTExtensionProperty extProperty = new WTExtensionProperty();
            IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty);

            try
            {
                // Convert unicode string value_I to UTF8-encoded bytes
                byte[] utf8Bytes = System.Text.Encoding.Convert(Encoding.Unicode, Encoding.UTF8, Encoding.Unicode.GetBytes(value_I));

                extProperty.extBase.version = 0;
                extProperty.extBase.tabletIndex = tabletIndex_I;
                extProperty.extBase.controlIndex = controlIndex_I;
                extProperty.extBase.functionIndex = functionIndex_I;
                extProperty.extBase.propertyID = propertyID_I;
                extProperty.extBase.reserved = 0;
                extProperty.extBase.dataSize = (uint)utf8Bytes.Length;
                extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyMaxDataBytes];

                // Send input value as an array of UTF8-encoded bytes.
                System.Buffer.BlockCopy(utf8Bytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize);

                Marshal.StructureToPtr(extProperty, buf, false);

                retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return retStatus;
        }
        /// <summary>
        /// Sets an extension control property value.
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="propertyID_I">ID of the property being set</param>
        /// <param name="value_I">value of the property being set</param>
        /// <returns>true if successful</returns>
        public static bool ControlPropertySet(
            HCTX context_I,
            byte extTagIndex_I,
            byte tabletIndex_I,
            byte controlIndex_I,
            byte functionIndex_I,
            ushort propertyID_I,
            UInt32 value_I
        )
        {
            bool retStatus = false;
            WTExtensionProperty extProperty = new WTExtensionProperty();
            IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty);

            try
            {
                byte[] valueBytes = BitConverter.GetBytes(value_I);

                extProperty.extBase.version = 0;
                extProperty.extBase.tabletIndex = tabletIndex_I;
                extProperty.extBase.controlIndex = controlIndex_I;
                extProperty.extBase.functionIndex = functionIndex_I;
                extProperty.extBase.propertyID = propertyID_I;
                extProperty.extBase.reserved = 0;
                extProperty.extBase.dataSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(value_I);
                extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyMaxDataBytes];

                // Send input value as an array of bytes.
                System.Buffer.BlockCopy(valueBytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize);

                Marshal.StructureToPtr(extProperty, buf, false);

                retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return retStatus;
        }
        /// <summary>
        /// Get a property value from an extension.
        /// </summary>
        /// <param name="context_I">Wintab context</param>
        /// <param name="extTagIndex_I">extension index tag</param>
        /// <param name="tabletIndex_I">tablet index</param>
        /// <param name="controlIndex_I">control index on the tablet</param>
        /// <param name="functionIndex_I">function index on the control</param>
        /// <param name="propertyID_I">ID of the property requested</param>
        /// <param name="result_O">value of the property requested</param>
        /// <returns>true if property obtained</returns>
        public static bool ControlPropertyGet(
            HCTX context_I,
            byte extTagIndex_I,
            byte tabletIndex_I,
            byte controlIndex_I,
            byte functionIndex_I,
            ushort propertyID_I,
            ref UInt32 result_O
            )
        {
            bool retStatus = false;
            WTExtensionProperty extProperty = new WTExtensionProperty();
            IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty);

            extProperty.extBase.version = 0;
            extProperty.extBase.tabletIndex = tabletIndex_I;
            extProperty.extBase.controlIndex = controlIndex_I;
            extProperty.extBase.functionIndex = functionIndex_I;
            extProperty.extBase.propertyID = propertyID_I;
            extProperty.extBase.reserved = 0;
            extProperty.extBase.dataSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(result_O);

            Marshal.StructureToPtr(extProperty, buf, false);

            try
            {
                bool status = CWintabFuncs.WTExtGet((UInt32)context_I, (UInt32)extTagIndex_I, buf);

                if (status)
                {
                    WTExtensionProperty retProp = (WTExtensionProperty)Marshal.PtrToStructure(buf, typeof(WTExtensionProperty));
                    result_O = retProp.data[0];
                    retStatus = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED ControlPropertyGet: " + ex.ToString());
            }

            CMemUtils.FreeUnmanagedBuf(buf);

            return retStatus;
        }
        /// <summary>
        /// Open a Wintab context to the specified hwnd.
        /// </summary>
        /// <param name="hwnd_I">parent window for the context</param>
        /// <param name="enable_I">true to enable, false to disable</param>
        /// <returns>Returns non-zero context handle if successful.</returns>
        public HCTX Open(HWND hwnd_I, bool enable_I)
        {
            try
            {
                m_hCTX = CWintabFuncs.WTOpenA(hwnd_I, ref m_logContext, enable_I);
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED OpenContext: " + ex.ToString());
            }

            return m_hCTX;
        }
        /// <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.
            HWND hwnd = MessageEvents.WindowHandle;

            try
            {
                m_hCTX = CWintabFuncs.WTOpenA(hwnd, ref m_logContext, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED OpenContext: " + ex.ToString());
            }

            return (m_hCTX > 0);
        }
Exemple #22
0
        /// <summary>
        /// Open a Wintab context to the specified hwnd.
        /// </summary>
        /// <param name="hwnd_I">parent window for the context</param>
        /// <param name="enable_I">true to enable, false to disable</param>
        /// <returns>Returns non-zero context handle if successful.</returns>
        public HCTX Open(HWND hwnd_I, bool enable_I)
        {
            m_hCTX = CWintabFuncs.WTOpen(hwnd_I, ref m_logContext, enable_I);

            return(m_hCTX);
        }