示例#1
0
        private void Delay(uint ms)
        {
            var tickCount = HelpWin32.GetTickCount();

            while (HelpWin32.GetTickCount() - tickCount < ms)
            {
                Thread.Sleep(1);
                Application.DoEvents();
            }
        }
示例#2
0
        public void SetBits(Bitmap bitmap)
        {
            var flag  = Image.IsCanonicalPixelFormat(bitmap.PixelFormat) && Image.IsAlphaPixelFormat(bitmap.PixelFormat);
            var flag2 = flag;
            var flag3 = flag2;
            var flag4 = flag3;
            var flag5 = flag4;
            var flag6 = flag5;
            var flag7 = flag6;
            var flag8 = flag7;
            var flag9 = flag8;

            if (flag9)
            {
                var hObj    = IntPtr.Zero;
                var dc      = HelpWin32.GetDC(IntPtr.Zero);
                var intPtr  = IntPtr.Zero;
                var intPtr2 = HelpWin32.CreateCompatibleDC(dc);
                try
                {
                    var point         = new HelpWin32.Point(Left, Top);
                    var size          = new HelpWin32.Size(bitmap.Width, bitmap.Height);
                    var blendFunction = default(HelpWin32.BLENDFUNCTION);
                    var point2        = new HelpWin32.Point(0, 0);
                    intPtr = bitmap.GetHbitmap(Color.FromArgb(0));
                    hObj   = HelpWin32.SelectObject(intPtr2, intPtr);
                    blendFunction.BlendOp             = 0;
                    blendFunction.SourceConstantAlpha = byte.MaxValue;
                    blendFunction.AlphaFormat         = 1;
                    blendFunction.BlendFlags          = 0;
                    HelpWin32.UpdateLayeredWindow(Handle, dc, ref point, ref size, intPtr2, ref point2, 0, ref blendFunction, 2);
                    return;
                }
                finally
                {
                    var flag10 = intPtr != IntPtr.Zero;
                    var flag11 = flag10;
                    var flag12 = flag11;
                    var flag13 = flag12;
                    var flag14 = flag13;
                    var flag15 = flag14;
                    var flag16 = flag15;
                    var flag17 = flag16;
                    var flag18 = flag17;
                    if (flag18)
                    {
                        HelpWin32.SelectObject(intPtr2, hObj);
                        HelpWin32.DeleteObject(intPtr);
                    }
                    HelpWin32.ReleaseDC(IntPtr.Zero, dc);
                    HelpWin32.DeleteDC(intPtr2);
                }
            }
            throw new ApplicationException("图片必须是32位带Alhpa通道的图片。");
        }
示例#3
0
        public static bool CaptureWindow(Control control, ref Bitmap bitmap)
        {
            Graphics graphics = Graphics.FromImage(bitmap);
            IntPtr   lParam   = new IntPtr(12);
            IntPtr   hdc      = graphics.GetHdc();

            HelpWin32.SendMessage(control.Handle, 791, hdc, lParam);
            graphics.ReleaseHdc(hdc);
            graphics.Dispose();
            return(true);
        }
示例#4
0
 public void PlaySong(string file)
 {
     HelpWin32.mciSendString("close media", null, 0, IntPtr.Zero);
     HelpWin32.mciSendString("open \"" + file + "\" type mpegvideo alias media", null, 0, IntPtr.Zero);
     HelpWin32.mciSendString("play media notify", null, 0, Handle);
 }
示例#5
0
 public static IntPtr SendMessage(IntPtr hWnd, int msg, int wParam)
 {
     return(HelpWin32.SendMessage(hWnd, msg, wParam, ""));
 }