資源簡介
透明圖片作winform的背景去鋸齒,絕對有效。采用雙層窗體。能拖動

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Drawing.Drawing2D;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
namespace?WindowsFormsApp1
{
????public?partial?class?Skin?:?Form
????{
????????public?FormShow?show;
????????public?Skin(FormShow?show)
????????{
????????????InitializeComponent();
????????????this.show?=?show;
????????????this.BackgroundImage?=?WindowsFormsApp3.Properties.Resource1.log_bg;//將背景圖應用到皮膚層
????????????this.BackgroundImageLayout?=?ImageLayout.Stretch;//自動拉伸背景圖以適應窗口
????????????this.Size?=?show.Size;//統一大小
????????????show.Owner?=?this;//設置控件層的擁有皮膚層
????????????Location?=?new?Point(show.Location.X?show.Location.Y);//統一控件層和皮膚層的位置
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????FormBorderstyle?=?FormBorderstyle.None;//取消窗口邊框
????????????SetBits(new?Bitmap(BackgroundImage?new?Size(135?70)));//設置不規則窗體
????????????FormMovableEvent();
????????}
????????bool?haveHandle?=?false;//窗體句柄創建完成
????????private?void?Initializestyles()
????????{
????????????Setstyle(
????????????????Controlstyles.UserPaint?|
????????????????Controlstyles.AllPaintingInWmPaint?|
????????????????Controlstyles.OptimizedDoubleBuffer?|
????????????????Controlstyles.ResizeRedraw?|
????????????????Controlstyles.SupportsTransparentBackColor?true);
????????????Setstyle(Controlstyles.Selectable?false);
????????????Updatestyles();
????????}
????????protected?override?void?OnHandleCreated(EventArgs?e)
????????{
????????????Initializestyles();//設置窗口樣式、雙緩沖等
????????????base.OnHandleCreated(e);
????????????haveHandle?=?true;
????????}
????????protected?override?CreateParams?CreateParams
????????{
????????????get
????????????{
????????????????CreateParams?cParms?=?base.CreateParams;
????????????????cParms.Exstyle?|=?0x00080000;?//?WS_EX_layerED
????????????????return?cParms;
????????????}
????????}
????????public?void?SetBits(Bitmap?bitmap)
????????{
????????????if?(!haveHandle)?return;
????????????if?(!Bitmap.IsCanonicalPixelFormat(bitmap.PixelFormat)?||?!Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
????????????????throw?new?ApplicationException(“The?picture?must?be?32bit?picture?with?alpha?channel.“);
????????????IntPtr?oldBits?=?IntPtr.Zero;
????????????IntPtr?screenDC?=?Win32.GetDC(IntPtr.Zero);
????????????IntPtr?hBitmap?=?IntPtr.Zero;
????????????IntPtr?memDc?=?Win32.CreateCompatibleDC(screenDC);
????????????try
????????????{
????????????????Win32.Point?topLoc?=?new?Win32.Point(Left?Top);
????????????????Win32.Size?bitMapSize?=?new?Win32.Size(bitmap.Width?bitmap.Height);
????????????????Win32.BLENDFUNCTION?blendFunc?=?new?Win32.BLENDFUNCTION();
????????????????Win32.Point?srcLoc?=?new?Win32.Point(0?0);
????????????????hBitmap?=?bitmap.GetHbitmap(Color.FromArgb(0));
????????????????oldBits?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????54272??2018-04-21?17:13??不規則鋸齒問題\.vs\WindowsFormsApp3\v15\.suo
?????文件??????????0??2018-04-21?10:35??不規則鋸齒問題\.vs\WindowsFormsApp3\v15\Server\sqlite3\db.lock
?????文件????1171456??2018-04-21?17:13??不規則鋸齒問題\.vs\WindowsFormsApp3\v15\Server\sqlite3\storage.ide
?????文件????????184??2018-04-21?10:44??不規則鋸齒問題\WindowsFormsApp3\App.config
?????文件??????39936??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\bin\Debug\WindowsFormsApp3.exe
?????文件????????184??2018-04-21?10:44??不規則鋸齒問題\WindowsFormsApp3\bin\Debug\WindowsFormsApp3.exe.config
?????文件??????34304??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\bin\Debug\WindowsFormsApp3.pdb
?????文件???????6534??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\FormMinSkin.cs
?????文件???????2045??2018-04-21?11:23??不規則鋸齒問題\WindowsFormsApp3\FormMinSkin.designer.cs
?????文件??????24936??2018-04-21?11:23??不規則鋸齒問題\WindowsFormsApp3\FormMinSkin.resx
?????文件????????974??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\FormShow.cs
?????文件???????2126??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\FormShow.designer.cs
?????文件???????5817??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\FormShow.resx
?????文件???????1164??2018-04-21?10:44??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????7123??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件??????????0??2018-04-21?10:35??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件??????????0??2018-04-21?10:35??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件??????????0??2018-04-21?10:35??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????文件???????3584??2018-04-21?10:47??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\TempPE\Properties.Resource1.Designer.cs.dll
?????文件???????3584??2018-04-21?11:26??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件????????180??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\WindowsFormsApp1.FormShow.resources
?????文件??????13040??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\WindowsFormsApp1.Skin.resources
?????文件?????????42??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\WindowsFormsApp3.csproj.CoreCompileInputs.cache
?????文件???????1262??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\WindowsFormsApp3.csproj.FileListAbsolute.txt
?????文件???????1192??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\WindowsFormsApp3.csproj.GenerateResource.cache
?????文件??????39936??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\WindowsFormsApp3.exe
?????文件??????34304??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\WindowsFormsApp3.pdb
?????文件??????13010??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\WindowsFormsApp3.Properties.Resource1.resources
?????文件????????180??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\WindowsFormsApp3.Properties.Resources.resources
?????文件?????????42??2018-04-21?17:12??不規則鋸齒問題\WindowsFormsApp3\obj\Debug\不規則窗體.csproj.CoreCompileInputs.cache
............此處省略35個文件信息
評論
共有 條評論