默認的MDI父控件有一個大的「桌面」區域,可以顯示多個子窗體。用戶可以將表單拖動到此桌面區域的邊緣,以便大多數子表單不在屏幕上。 (一個滾動條出現在MDI父項中)我不喜歡這個特性。有沒有辦法鎖定桌面區域的邊緣,以便子窗體保持完全可見?Winforms MDI「桌面」區域邊界
4
A
回答
3
- 禁用MDI窗口滾動條
- 掛鉤所有子窗口的OnMove事件。如果窗口移動到邊界之外,沿着x和y「回彈」它,直到它回到父窗口的內部。
3
爲了澄清,你說的是MDI客戶端的「桌面」區域是客戶區。
您可以處理子窗體的調整大小/移動事件處理程序,然後在超出MDI客戶區的邊界時調整/限制子的移動。
5
我用來實現我上面選擇的答案代碼:
Public alreadyMoved As Boolean = False
Public Const HEIGHT_OF_MENU_STATUS_BARS As Integer = 50
Public Const WIDTH_OF_MENU_STATUS_BARS As Integer = 141
Private Sub Form_Move(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Move
If Not alreadyMoved Then
alreadyMoved = True
'If I'm over the right boundry, drop back to right against that edge
If Me.Location.X + Me.Width > _
MdiParent.ClientRectangle.Width - WIDTH_OF_MENU_STATUS_BARS Then
MyBase.Location = New System.Drawing.Point(_
(MdiParent.ClientRectangle.Width - Me.Width - _
WIDTH_OF_MENU_STATUS_BARS), MyBase.Location.Y)
End If
'If I'm over the bottom boundry, drop back to right against that edge
If Me.Location.Y + Me.Height > _
MdiParent.ClientRectangle.Height - HEIGHT_OF_MENU_STATUS_BARS Then
MyBase.Location = New System.Drawing.Point(_
MyBase.Location.X, (MdiParent.ClientRectangle.Height - _
Me.Height - HEIGHT_OF_MENU_STATUS_BARS))
End If
'If I'm over the top boundry, drop back to the edge
If Me.Location.Y < 0 Then
MyBase.Location = New System.Drawing.Point(MyBase.Location.X, 0)
End If
'If I'm over the left boundry, drop back to the edge
If Me.Location.X < 0 Then
MyBase.Location = New System.Drawing.Point(0, MyBase.Location.Y)
End If
End If
alreadyMoved = False
End Sub
相關問題
- 1. 從邊界計算區域
- 2. 矩形區域和邊界
- 3. 獲取四邊形邊界的邊界區域
- 4. Winforms MDI客戶端區域的大小/位置
- 5. MDI應用程序與展望界面像顯示winforms c#
- 6. 谷歌地圖區域邊界的邊界
- 7. Winforms MDI和TreeView
- 8. Winforms + MDI兒童
- 9. 如何將邊界放在區域?
- 10. 來自邊界的區域集合
- 11. kml邊界以外的陰影區域
- 12. 提取邊界內的圖像區域
- 13. 如何在邊界區域顯示pdf?
- 14. 區域邊界的GIS數據
- 15. 如何計算邊界框區域?
- 16. 從矩陣獲取區域/區域邊界
- 17. 的WinForms - 無邊界的DateTimePicker
- 18. 幻影邊界桌子裏面的桌子Css
- 19. 桌面屏幕捕獲目標區域
- 20. 在桌面上選擇區域矩形
- 21. WinForms MDI子窗體
- 22. 桌面PC和Android界面
- 23. 轉換簡化離散區域邊界多邊形
- 24. 相交多邊形的非重疊區域的邊界
- 25. 查找包圍一組點的邊界多邊形的區域
- 26. 流域邊界緊密圍繞一個區域
- 27. 色面邊界
- 28. OpenStreetMap:如何顯示國家/地區的區域邊界?
- 29. 訪問谷歌地圖區域座標(郊區邊界)
- 30. javafx支持MDI(多文檔界面)嗎?
看我下面的代碼包含的代碼做到這一點。 – Jeff 2009-03-02 21:19:08