C # Updatelayeredwindow Profiled window

Source: Internet
Author: User

#regionUpdatelayeredwindow#regionOverriding the CreateParams property of a formprotected Overridecreateparams CreateParams {Get{createparams cp=Base.                CreateParams; Cp. ExStyle|=0x00080000;//ws_ex_layered Extended Styles//No Border taskbar window minimized                Const intWs_minimizebox =0x00020000;//defined in Winuser.h//createparams CP = base. CreateParams;Cp. Style = CP. Style | Ws_minimizebox;//allow minimization of operations                returnCP; }        }        #endregion        #regionAPI calls Public voidSetbits (Bitmap Bitmap)//Call the Updatelayeredwindow () method. This. BackgroundImage is a transparent picture that you prepared beforehand.         {            //if (!havehandle) return;            if(! Bitmap.iscanonicalpixelformat (Bitmap. PixelFormat) | | !Bitmap.isalphapixelformat (Bitmap. PixelFormat))Throw NewApplicationException ("the picture must be a 32-bit picture with ALHPA channels. "); INTPTR oldbits=IntPtr.Zero; INTPTR SCREENDC=Win32.getdc (IntPtr.Zero); INTPTR Hbitmap=IntPtr.Zero; INTPTR MEMDC=Win32.createcompatibledc (SCREENDC); Try{win32.point Toploc=NewWin32.point (left, Top); Win32.size bitmapsize=Newwin32.size (bitmap. Width, Bitmap.                Height); Win32.blendfunction Blendfunc=Newwin32.blendfunction (); Win32.point Srcloc=NewWin32.point (0,0); Hbitmap= Bitmap. Gethbitmap (Color.FromArgb (0)); Oldbits=Win32.selectobject (MEMDC, HBITMAP); Blendfunc.blendop=Win32.ac_src_over; Blendfunc.sourceconstantalpha=255; Blendfunc.alphaformat=Win32.ac_src_alpha; Blendfunc.blendflags=0; Win32.updatelayeredwindow (Handle, SCREENDC,refToploc,refBitmapsize, MEMDC,refSrcloc,0,refBlendfunc, Win32.ulw_alpha); }            finally            {                if(Hbitmap! =IntPtr.Zero) {win32.selectobject (MEMDC, oldbits);                Win32.deleteobject (HBITMAP);                } win32.releasedc (IntPtr.Zero, SCREENDC);            Win32.deletedc (MEMDC); }        }        #endregion        #endregion
         Public mainform ()        {            InitializeComponent ();             New Bitmap (this. Height);             = graphics.fromimage (BG);            G.drawimage (IMG, x, Y, img). Width, IMG. Height);            G.dispose ();            Setbits (BG);        }

C # Updatelayeredwindow Profiled window

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.