在C#WinForms(或Win32 API)中是否有一种方法可以偏移表单子控件的原点{0,0}坐标,而无需将控件添加为父级而不扩展窗口边框?
这就是我的意思:
Win32 API是否具有类似SetChildOffset()函数的功能?我希望窗口边框保持不变。
没有API可以做到这一点。而是使用这个:
private void SetChildOffset(int offset) {
//get all immediate children of form
var children = this.Controls.OfType<Control>();
foreach( Control child in children ) {
child.Location = new Point( child.Location.X + offset, child.Location.Y + offset );
}
}