示例#1
0
        private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == (int)EWintabEventMessage.WT_PACKET)
            {
                packet   = WintabManager.GetPacket(lParam, (uint)wParam.ToInt32());
                usingPen = true;

                uint button = packet.pkButtons & 0x00000001;
                if (button == 1)
                {
                    uint highWord = (packet.pkButtons & 0xFFFF0000) >> 16;

                    if ((highWord & 2) != 0)
                    {
                        ButtonPressed = true;
                    }
                    else if ((highWord & 1) != 0)
                    {
                        ButtonPressed = false;
                    }
                }
            }
            return(IntPtr.Zero);
        }
示例#2
0
        /// <summary>
        /// パケットの取得
        /// </summary>
        /// <param name="hCtx"></param>
        /// <param name="pktID"></param>
        /// <returns></returns>
        public static WintabPacket GetPacket(IntPtr hCtx, UInt32 pktID)
        {
            WintabPacket packet  = new WintabPacket();
            IntPtr       pPacket = WintabMemoryUtility.AllocUnmanagedBuffer(packet);

            try
            {
                bool result = WintabFunctions.WTPacket(hCtx, pktID, pPacket);
                packet = WintabMemoryUtility.MarshalUnmanagedBuffer <WintabPacket>(
                    pPacket,
                    (uint)WintabMemoryUtility.SizeOf(typeof(WintabPacket)));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("GetPacket : " + ex.Message);
                throw ex;
            }
            finally
            {
                WintabMemoryUtility.FreeUnmanagedBuffer(pPacket);
            }

            return(packet);
        }