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

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
博客园 - 【当耐特】
WordPress大学
WordPress大学
爱范儿
爱范儿
美团技术团队
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
量子位
Hugging Face - Blog
Hugging Face - Blog
B
Blog RSS Feed
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 聂微东
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
博客园 - 叶小钗
GbyAI
GbyAI
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
F
Full Disclosure
G
Google Developers Blog
D
Docker
T
Tailwind CSS Blog
C
Check Point Blog
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
B
Blog
博客园 - 三生石上(FineUI控件)
博客园 - Franky
H
Help Net Security
MyScale Blog
MyScale Blog
U
Unit 42
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
L
LangChain Blog
有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog

博客园 - 冯小磊

女人的面相 只有mdf文件的恢复技术 冒泡,选择,插入,希尔 vb.net c#.net 代码相互转换 [转]C# 参考之转换关键字:operator、explicit与implicit 【转载】SQL查询中区分大小写的方法 Dev里面DataGid控件使用方法之一 对于sql数据库中重复的记录... (word导出问题)解决:服务器出现意外情况。 (异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT))的解决方法 白骨精写给孙悟空的绝世情书 DBCC CHECKDB (检查指定数据库中的所有对象的分配和结构完整性) sqlserver附加数据库错误823的解决方案 改变DevExpress控件的字体 按某一字段分组取最大(小)值所在行的数据 mssql1069错误(由于登录失败而无法启动服务)解决方法 C# 判断中文字符(字符串) 函数datediff MSSQL中取字符中的汉字或双字节字符 用SqlCommandBuilder 实现批量更新
c# 限制窗体
冯小磊 · 2008-05-30 · via 博客园 - 冯小磊

第1种: 用API去掉系统菜单的“移动”菜单项, 完美的解决方案 
using System; 
using System.Windows.Forms; 
using System.Runtime.InteropServices; 

class Test : Form 

  
const int MF_BYPOSITION = 0x0400
  
const int MF_REMOVE     = 0x1000

  [DllImport(
"user32.dll",EntryPoint="GetSystemMenu")] 
  
extern static IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert); 

  [DllImport(
"user32.dll",EntryPoint="RemoveMenu")] 
  
extern static int RemoveMenu(IntPtr hMenu, int nPos, int flags); 

  Test() 
  

    Text            
=  "不能移动和改变大小的窗口"
    FormBorderStyle 
= FormBorderStyle.FixedSingle; 
    MaximizeBox     
= false
    MinimizeBox     
= false
    RemoveMenu(GetSystemMenu(Handle,IntPtr.Zero),
1,MF_BYPOSITION|MF_REMOVE); 
  }
 

  
static void Main() 
  

    Application.Run(
new Test()); 
  }
 
}
 


 
第2种: 去掉标题栏的系统菜单, 点右键自然无效, 不推荐

using System.Windows.Forms;
class Test : Form 

  Test() 
  

    Text            
= "去掉系统菜单的标题栏"
    FormBorderStyle 
= FormBorderStyle.FixedSingle; 
    MaximizeBox     
= false
    MinimizeBox     
= false
  }
 
  
const int WS_SYSMENU = 0x00080000;
  
protected override CreateParams CreateParams 
  

    
get 
    

      CreateParams cp 
=  base.CreateParams; 
      cp.Style 
= cp.Style & ~WS_SYSMENU; 
      
return cp; 
    }
 
  }
 
  
static void Main() 
  

    Application.Run(
new Test()); 
  }
 
}
 

第3种:除了可以点击关闭按钮以外,任何针对标题栏的操作都无效
protected override void WndProc(ref Message m) 

if (m.Msg == 0xa1 && (int)m.WParam == 0x3

return
}
 
if (m.Msg == 0xa3 && ((int)m.WParam == 0x3 || (int)m.WParam == 0x2)) 

return
}
 
if (m.Msg == 0xa4 && ((int)m.WParam == 0x2 || (int)m.WParam == 0x3)) 

return
}
 
if (m.Msg == 0x112 && (int)m.WParam == 0xf100

return
}
 
base.WndProc(ref m); 
}
 

第4种:不让拖动的标题栏, 双击标题栏无反应
        
using System;
        
using System.Windows.Forms;
        
        
public class Test : Form
        
{
            Test() 
            
{
                Text            
= "不让拖动的标题栏, 双击标题栏无反应";
                FormBorderStyle 
= FormBorderStyle.FixedDialog;
                MaximizeBox     
= false;
                MinimizeBox     
= false;
            }

            
protected override void WndProc(ref Message m)
            
{
                
base.WndProc(ref m);
                
if(m.Msg == 0x84 && m.Result == (IntPtr)2// 不让拖动标题栏
                {
                    m.Result 
= (IntPtr)1;
                }

                
if (m.Msg == 0xA3)                         // 双击标题栏无反应
                {
                    m.WParam 
= System.IntPtr.Zero;
                }

            }


            
static void Main()
            
{
                Application.Run(
new Test());
            }

        }