1. Trang chủ
  2. » Công Nghệ Thông Tin

Bài giảng Lập trình môi trường Window: Chương 7 - Ngô Thanh Hùng

29 13 0

Đ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

Nội dung

Chương 7 của bài giảng trình bày nội dung về Multi-Document Interface (MDI): khái niệm và các thành phần của MDI; các loại MDI; minh họa các thao tác thường dùng. Mời các bạn xem chi tiết bài giảng.

MDI (Multiple Document Interfaces) Click to edit Master subtitle style 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt 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) 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt 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 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt Cửa sổ SDI 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt 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 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt Cửa sổ Explorer Interface 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt 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 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt 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 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt • • Đặ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 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt Các thành phần MDI • Cửa sổ ứng dụng chương trình MDI theo kiểu cổ điển gồm có  Thanh tiêu đề  Một trình đơn  Một đường viền thay đổi kích thước  Một icon trình đơn hệ thống  Các nút minimize/maximize/close 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt MDI or more child windows enables the More Windows option Separator bar and child windows 2/28/10 1515 Child windows list CuuDuongThanCong.com https://fb.com/tailieudientucntt ArrangeIcons 2/28/10 TileHorizontal CuuDuongThanCong.com Cascade TileVertical https://fb.com/tailieudientucntt • • Trên NET, việc phân biệt cửa sổ bình thường cửa sổ MDI khơng thật rõ ràng Có thể biến đổi cửa sổ thành cửa sổ MDI Parent cách đặt this.IsMdiContainer = true; 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt • • Khi hiển thị MDI container, biểu mẫu trở thành màu xám Muốn thêm cửa sổ MDI Child, cần đặt thuộc tính MDI Parent biểu mẩu Child hàm Parent_Load() 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt private void Parent_Load (object sender, System.EventArgs e) { Child frmChild = new Child(); frmChild.MdiParent = this; frmChild.Show(); } 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt Minh hoạ MDI Form 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt Các thao tác thường dùng Thuộc tính/Hàm ActiveMdiChild IsMdiChild Mơ tả Gets the MDI child window that is currently active Gets whether the form is an MDI child IsMdiContainer MdiChildren Gets whether the form is an MDI container form Gets the set of MDI children contained by this form as an array of Form object Gets or sets the MDI container for this MdiParent form If set, then this form is an MDI child form Gets the MainMenu object representing MergedMenu 2/28/10 CuuDuongThanCong.com the current merged menu for an MDI container form Arranges the MDI children within this https://fb.com/tailieudientucntt Thuộc tính/Hàm Mô tả Occurs when an MDI child form is actived or closed MdiChildActivate with an MDI aplication Note that MDI children not receive the Actived and Deatived events Merges the MenuItem objects in a given menu with MergeMenu those contained by this menu Gets or sets whether this menu should be populated MdiList with a list of MDI child forms contained by the associated form Gets or sets the relative position of this menu item MergeOrder when it is merged with another menu Gets or sets how this menu should be merged with MergeType other menus The default is MergeType.Add 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt • • 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 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt 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 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt Người dùng chuyển từ cửa sổ sang cửa sổ khác cách sử dụng trình đơn 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt Sắp xếp theo kiểu Cascade Tile • • 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ổ 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt • Đ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) } 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt • • 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; } } 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt Merge Menu Khi cần trộn menu Container với menu MDIChild hành Tự tìm hiểu 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt ... 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 2/28/10 CuuDuongThanCong.com https://fb.com/tailieudientucntt Các thành phần MDI • Cửa sổ ứng dụng chương trình MDI... để hiển thị output chương trình Workspace khơng chứa hay chứa nhiều cửa sổ con, cửa sổ hiển thị tài liệu Các cửa sổ giống cửa sổ ứng dụng bình thường cửa sổ ứng dụng chương trình MDI Ở thời điểm,... https://fb.com/tailieudientucntt • Đ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

Ngày đăng: 17/04/2022, 09:53

TỪ KHÓA LIÊN QUAN