惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

博客园 - 空军

过多边形边上某点的任意直线等分面积 VisualAPL Installer for Visual Studio 2008 [ZT] Create a Microsoft Access Database Using ADOX and Visual Basic .NET 数的分解,据说是清华的一道复试上机题 f(f(x)) = -x [zt]〖Math〗构造函数使得任意小的区间所对应的值域都是整个实数域 [zt]鸟巢、水立方:同一个地方,同一梦想 〖Math〗据传,任意锐角等于0° 爱因斯坦的超级问题(谁养鱼)SQL解法 “槑囧圐圙”您认得这些汉字吗? 根据URL提取页面的Title,根据网页的charset自动判断Encoding MSDN“MidpointRounding 枚举”中文翻译有误 C# 2.0 新特性(泛型、可空类型)应用一例 表达式计算器 Google速记 Google中国编程挑战赛第一轮 Google中国编程挑战赛资格赛 数学家 数据库访问模块
为System.Windows.Forms.FontDialog类添加Location属性
空军 · 2009-10-13 · via 博客园 - 空军

FontDialog类继承自CommonDialog,没有Location及Size属性,其他自CommonDialog派生的类,如ColorDialog、FileDialog等也是如此。

继承层次结构

System.Object
    System.MarshalByRefObject
        System.ComponentModel.Component
            System.Windows.Forms.CommonDialog
                System.Windows.Forms.ColorDialog
                System.Windows.Forms.FileDialog
                System.Windows.Forms.FolderBrowserDialog
                System.Windows.Forms.FontDialog
                System.Windows.Forms.PageSetupDialog
                System.Windows.Forms.PrintDialog

API函数GetWindowRect、SetWindowPos可以获取和设置窗体的位置和大小。

 1using System;
 2using System.Drawing;
 3using System.Windows.Forms;
 4using System.Runtime.InteropServices;
 5
 6class FontDialog : System.Windows.Forms.FontDialog
 7{
 8  public int   Left     get return r.Left    ; } set { r.Left     = value; } }
 9  public int   Top      get return r.Top     ; } set { r.Top      = value; } }
10  public int   Width    get return r.Width   ; } set { r.Width    = value; } }
11  public int   Height   get return r.Height  ; } set { r.Height   = value; } }
12  public Point Location get return r.Location; } set { r.Location = value; } }
13  public Size  Size     get return r.Size    ; } }
14
15  Rect r;
16
17  const uint SWP_NOSIZE   = 1;
18  const uint SWP_NOZORDER = 4;
19
20  [DllImport("user32.dll")]   
21  static extern IntPtr GetWindowRect(IntPtr hWnd, ref Rect rect);
22
23  [DllImport("user32.dll")]
24  static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
25
26  [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
27  protected override IntPtr HookProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
28  {
29    SetWindowPos(hWnd, (IntPtr)0, Left, Top, 00, SWP_NOSIZE | SWP_NOZORDER);
30    GetWindowRect(hWnd, ref r);
31    return base.HookProc(hWnd, msg, wParam, lParam);
32  }

33}

34
35class Form1 : Form
36{
37  Form1()
38  {
39    Button btn = new Button();
40    btn.Parent = this;
41    btn.Text   = "&Font";
42    btn.Click += delegate
43    {
44      FontDialog fd = new FontDialog();
45      fd.Location = new Point(1050);
46      fd.ShowDialog();
47    }
;
48  }

49
50  static void Main()
51  {
52    Application.Run(new Form1());
53  }

54}

55
56[StructLayout(LayoutKind.Sequential)]
57public struct Rect 
58
59  public int Left; 
60  public int Top; 
61  public int Right; 
62  public int Bottom;
63
64  public int Width  get return Right - Left; } set { Right = Left + value; } }
65  public int Height get return Bottom - Top; } set { Bottom = Top + value; } }
66
67  public Size Size
68  {
69    get return new Size(Width, Height); }
70    set { Width = value.Width; Height = value.Height; }
71  }

72
73  public Point Location
74  {
75    get return new Point(Left, Top); }
76    set { Right -= (Left - value.X); Bottom -= (Bottom - value.Y); Left = value.X; Top = value.Y; }
77  }

78
79  public override string ToString()
80  {
81    return string.Format("{{X={0},Y={1},Width={2},Height={3}}}", Left, Top, Width, Height);
82  }

83}

84