C#動態創建子窗口時被父窗口中定義的一些button等覆蓋

最近做個項目,動態創建子窗口後發現被父窗口中的一些button所覆蓋,晚上查了好久,後來在一個帖子中找到了答案,再次將該帖子整理下,帖子地址(http://bbs.csdn.net/topics/330055738

子窗口被覆蓋的效果圖如下:



後來hululuzhu網友給出了一個答案,我試了一下,是正確的,代碼如下

using System.Runtime.InteropServices;

[DllImport("user32")]
public static extern int SetParent(int hWndChild, int hWndNewParent);

//價格temp2是你的子form
temp2.MdiParent = this;
temp2.Show();
SetParent((int)temp2.Handle, (int)this.Handle);




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章