資源簡(jiǎn)介
C#界面任意分屏,可以平均分屏(即所有屏幕大小相同,按照設(shè)定數(shù)量平均分配);也可以按照自己的任意想法,把某些屏幕設(shè)置得與其他屏幕大小不一樣(即可以設(shè)置幾個(gè)大的,幾個(gè)小的)。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Diagnostics;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Runtime.InteropServices;
using?System.Drawing;
namespace?再次實(shí)驗(yàn)控件特性
{
????public?partial?class?DateTimePickerAdd?:?DateTimePicker
????{
????????const?string?DllPath?=?@“user32.dll“;
????????[DllImport(DllPath?EntryPoint?=?“SendMessageA“)]
????????private?static?extern?int?SendMessageA(IntPtr?hwnd?int?wMsg?IntPtr?wParam?object?lParam);
????????[DllImport(DllPath)]
????????private?static?extern?IntPtr?GetWindowDC(IntPtr?hWnd);
????????[DllImport(DllPath)]
????????private?static?extern?int?ReleaseDC(IntPtr?hWnd?IntPtr?hDC);
????????const?int?WM_ERASEBKGND?=?0x14;
????????const?int?WM_NC_PAINT?=?0x85;
????????const?int?WM_PAINT?=?0xF;
????????const?int?WM_PRINTCLIENT?=?0x318;
????????//邊框顏色
????????private?Pen?BorderPen?=?new?Pen(SystemColors.ControlDark?2);
????????///?
????????///?定義背景色私有變量
????????///?
????????private?Color?_backColor?=?Color.White;
????????///?
????????///?定義背景色屬性
????????///?
????????public?override?Color?BackColor
????????{
????????????get
????????????{
????????????????return?_backColor;
????????????}
????????????set
????????????{
????????????????_backColor?=?value;
????????????}
????????}
????????protected?override?void?WndProc(ref?System.Windows.Forms.Message?m)
????????{
????????????IntPtr?hDC?=?IntPtr.Zero;
????????????Graphics?gdc?=?null;
????????????switch?(m.Msg)
????????????{
????????????????//畫(huà)背景色
????????????????case?WM_ERASEBKGND:
????????????????????gdc?=?Graphics.FromHdc(m.WParam);
????????????????????gdc.FillRectangle(new?SolidBrush(_backColor)?new?Rectangle(0?0?this.Width?this.Height));
????????????????????gdc.Dispose();
????????????????????break;
????????????????case?WM_NC_PAINT:
????????????????????hDC?=?GetWindowDC(m.HWnd);
????????????????????gdc?=?Graphics.FromHdc(hDC);
????????????????????SendMessageA(this.Handle?WM_ERASEBKGND?hDC?0);
????????????????????SendPrintClientMsg();
????????????????????SendMessageA(this.Handle?WM_PAINT?IntPtr.Zero?0);
????????????????????m.Result?=?(IntPtr)1;????//?indicate?msg?has?been?processed
????????????????????ReleaseDC(m.HWnd?hDC);
????????????????????gdc.Dispose();
????????????????????break;
????????????????//畫(huà)邊框
????????????????case?WM_PAINT:
????????????????????base.WndProc(ref?m);
????????????????????hDC?=?GetWindowDC(m.HWnd);
????????????????????gdc?=?Graphics.FromHdc(hDC);
????????????????????OverrideControlBorder(gdc);
????????????????????ReleaseDC(m.HWnd?hDC);
????????????????????gdc.Dispose();
????????????????????break;
????????????????default:
????????????????????base.WndProc(ref?m);
????????????????????break;
????????????}
????????}
????????private?void?SendPrintClientMsg()
????????{
????????????//?We?send?this?message?for?the?control?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????1485??2016-03-16?17:01??C#界面分屏展示\bin\Debug\BallMachine_2.png
?????文件?????811520??2010-11-20?20:21??C#界面分屏展示\bin\Debug\user32.dll
?????文件??????24064??2016-12-07?14:52??C#界面分屏展示\bin\Debug\再次實(shí)驗(yàn)控件特性.exe
?????文件??????36352??2016-12-07?14:52??C#界面分屏展示\bin\Debug\再次實(shí)驗(yàn)控件特性.pdb
?????文件??????11600??2017-02-21?09:07??C#界面分屏展示\bin\Debug\再次實(shí)驗(yàn)控件特性.vshost.exe
?????文件????????490??2015-12-02?08:23??C#界面分屏展示\bin\Debug\再次實(shí)驗(yàn)控件特性.vshost.exe.manifest
?????文件?????811520??2010-11-20?20:21??C#界面分屏展示\bin\Release\user32.dll
?????文件??????23552??2016-09-14?18:24??C#界面分屏展示\bin\Release\再次實(shí)驗(yàn)控件特性.exe
?????文件??????34304??2016-09-14?18:24??C#界面分屏展示\bin\Release\再次實(shí)驗(yàn)控件特性.pdb
?????文件???????3935??2016-03-16?10:56??C#界面分屏展示\C#界面分屏展示.csproj
?????文件????????881??2017-02-21?09:06??C#界面分屏展示\C#界面分屏展示.sln
????..A..H.?????18432??2017-02-21?09:07??C#界面分屏展示\C#界面分屏展示.suo
?????文件???????3545??2016-12-07?14:52??C#界面分屏展示\DateTimePickerAdd.cs
?????文件???????1063??2016-03-16?10:52??C#界面分屏展示\DateTimePickerAdd.Designer.cs
?????文件??????21561??2016-12-07?14:52??C#界面分屏展示\Form1.cs
?????文件??????13340??2016-12-07?14:52??C#界面分屏展示\Form1.Designer.cs
?????文件??????11952??2016-12-07?14:52??C#界面分屏展示\Form1.resx
?????文件????????192??2017-02-21?09:07??C#界面分屏展示\obj\x86\Debug\C#界面分屏展示.csproj.FileListAbsolute.txt
?????文件??????19770??2016-12-07?14:51??C#界面分屏展示\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????6344??2017-02-21?09:06??C#界面分屏展示\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????3190??2017-02-21?09:03??C#界面分屏展示\obj\x86\Debug\再次實(shí)驗(yàn)控件特性.csproj.FileListAbsolute.txt
?????文件????????975??2016-12-07?14:52??C#界面分屏展示\obj\x86\Debug\再次實(shí)驗(yàn)控件特性.csproj.GenerateResource.Cache
?????文件??????16177??2016-07-11?11:28??C#界面分屏展示\obj\x86\Debug\再次實(shí)驗(yàn)控件特性.csprojResolveAssemblyReference.cache
?????文件??????24064??2016-12-07?14:52??C#界面分屏展示\obj\x86\Debug\再次實(shí)驗(yàn)控件特性.exe
?????文件???????3963??2016-12-07?14:52??C#界面分屏展示\obj\x86\Debug\再次實(shí)驗(yàn)控件特性.Form1.resources
?????文件??????36352??2016-12-07?14:52??C#界面分屏展示\obj\x86\Debug\再次實(shí)驗(yàn)控件特性.pdb
?????文件????????180??2016-03-16?10:56??C#界面分屏展示\obj\x86\Debug\再次實(shí)驗(yàn)控件特性.Properties.Resources.resources
?????文件???????6478??2016-09-14?18:24??C#界面分屏展示\obj\x86\Release\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????1044??2016-09-14?18:24??C#界面分屏展示\obj\x86\Release\再次實(shí)驗(yàn)控件特性.csproj.FileListAbsolute.txt
?????文件????????975??2016-09-14?18:24??C#界面分屏展示\obj\x86\Release\再次實(shí)驗(yàn)控件特性.csproj.GenerateResource.Cache
............此處省略24個(gè)文件信息
評(píng)論
共有 條評(píng)論