Пример #1
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);
        }