Chuong 7 mdi

34 0 0
Chuong 7   mdi

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

MDI (Multiple Document Interfaces) Tổng quát • Phần lớn ứng dụng Windows rơi vào loại sau:  Single Document Interfaces (SDI)  Explorer Interfaces  Multiple Document Interfaces (MDI) Single Document Interface • Mỗi tài liệu thể cửa sổ đơn • Trong Windows tiêu biểu cho loại giao diện Notepad hay Wordpad Cửa sổ SDI Explorer Interface • Đây cửa sổ mà thơng tin hiển thị theo hệ thống phân cấp • Thông thường TreeView control dùng để hiển thị hệ thống phân cấp • Thơng tin chi tiết nút TreeView chọn hiển thị ListView control Cửa sổ Explorer Interface Khái niệm MDI • Multiple Document Interface (MDI) đặc tả quản lý tài liệu Microsoft Windows • Mơ tả cấu trúc cửa sổ giao diện người dùng, cho phép người sử dụng làm việc với nhiều tài liệu ứng dụng đơn Cửa sổ MDI Ví dụ • Windows trì nhiều ứng dụng Windows hình đơn • Một ứng dụng MDI trì nhiều cửa sổ tài liệu vùng client đơn Khái niệm MDI • Đặc tả MDI xuất từ Windows 2.0, ứng dụng MDI lúc khó viết cần nhiều cơng sức lập trình • Từ Windows 3.0 trở đi, nhiều chức mở rộng hỗ trợ đưa vào MDI NET private void Parent_Load (object sender, System.EventArgs e) { Child frmChild = new Child(); frmChild.MdiParent = this; frmChild.Show(); } Minh hoạ MDI Form Các lớp thường dùng Lớp Form Loại Tên Properties ActiveMdiChild Gets the MDI child window that is currently active IsMdiChid Gets whether the form is an MDI child IsMdiContainer Gets whether the form is an MDI container form MdiChildren Gets the set of MDI children contained by this form as an array of Form object MdiParent Gets or sets the MDI container for this form If set, then this form is an MDI child form MergedMenu Gets the MainMenu object representing the current merged menu for an MDI container form LayoutMdi Arranges the MDI children within this form using a given layout style Methods Mô tả Lớp Loại Events Menu Tên MdiChildActive Mô tả Occurs when an MDI child form is actived or deactived with an MDI aplication Note that MDI children not receive the Actived and Deatived events Properties MdiListItem Gets the MenuItem object contained by this menu that displays a list of MDI child forms for the associated from object Method Merges the MenuItem objects in a given menu with those contained by this menu MergeMenu MenuIte Properties MdiList m Gets or sets whether this menu should be populated with a list of MDI child forms contained by the associated form MergeOrder Gets or sets the relative position of this menu item when it is merged with another menu MergeType Gets or sets how this menu should be merged with other menus The default is MergeType.Add MDI NET • Trong project có nhiều MDI Parent • Có thể chuyển đổi MDI Child từ MDI Parent sang MDI Parent khác cách thay đổi thuộc tính MdiParent Sắp xếp MDI Child • Để tạo danh sách MDI Child, cần thêm top-level menu item (thường mang tên Window), cho thuộc tính MdiList = true • Bộ máy Windows.Forms tự động thêm item vào cuối submenu cho cửa sổ MDI Child Người dùng chuyển từ cửa sổ sang cửa sổ khác cách sử dụng trình đơn Sắp xếp Child Form • Có nhiều xếp child form parent form – Cascade – TileHorizontal – TileVertical – ArrangeIcons Cascade TileHorizontal TileVertical Sắp xếp Child Form • Nếu muốn xếp theo kiểu Cascade Tile, cần thêm chức vào trình đơn • Mỗi MDI container hổ trợ hàm LayoutMdi(), hàm nhận giá trị từ Enumeration MdiLayout xếp tự động cửa sổ Sắp xếp Child Form • Đoạn chương trình xếp theo kiểu Cascade private void mnuCascade_Click ( Object sender, System.EventArgs e) { this.LayoutMdi (MdiLayout.Cascade) } • Đoạn chương trình xếp theo kiểu Tile Horizontal private void mnuTileH_Click ( Object sender , System.EventArgs e) { this.LayoutMdi (MdiLayout.TileHorizontal) } Sắp xếp Child Form • Ngồi ra, tạo cách xếp riêng tùy theo ứng dụng • Ví dụ, đoạn chương trình sau cho phép thu nhỏ lại tất cửa sổ mở private void mnuMinimizeAll_Click (Object sender, System.EventArgs e) { foreach (Form frm in this.MdiChildren) { frm.WindowState = FormWindowState.Minized; } } Merge Menu • Nếu Parent Form Child Form có menu Child Form show, menu Child Form thêm vào phía sau menu Parent Form • Nếu Child Form Parent Form có menu item có caption giống xuất menu item menu (vd có menu File menu) Merge Menu • Để tránh tình trạng ta trộn chung menu Parent Form Child Form lại với nhau: mnu_PFile.MergeType = MenuMerge.MergeItems; //Parent mnu_CFile.MergeType = MenuMerge.MergeItems; //Child • Có thể định vị trí cho item sau trộn thuộc tính MergeOrder mnu_Exit.MergeOrder = 2; Menu chưa merge Menu merge ... MergeType.Add MDI NET • Trong project có nhiều MDI Parent • Có thể chuyển đổi MDI Child từ MDI Parent sang MDI Parent khác cách thay đổi thuộc tính MdiParent Sắp xếp MDI Child • Để tạo danh sách MDI Child,... Minh hoạ MDI Form Các lớp thường dùng Lớp Form Loại Tên Properties ActiveMdiChild Gets the MDI child window that is currently active IsMdiChid Gets whether the form is an MDI child IsMdiContainer... Cửa sổ MDI Ví dụ • Windows trì nhiều ứng dụng Windows hình đơn • Một ứng dụng MDI trì nhiều cửa sổ tài liệu vùng client đơn Khái niệm MDI • Đặc tả MDI xuất từ Windows 2.0, ứng dụng MDI lúc

Ngày đăng: 25/02/2023, 18:04

Tài liệu cùng người dùng

Tài liệu liên quan