1 / 12

Lecture 10

Lecture 10. Multiple Document Interface (MDI). MDI - introduction. User can work with more than one document at one time Each document is displayed in child window Each child window is contained within client area of application’s main window. MDI - windows. MDI - windows.

osric
Download Presentation

Lecture 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 10 Multiple Document Interface (MDI)

  2. MDI - introduction • User can work with more than one document at one time • Each document is displayed in child window • Each child window is contained within client area of application’s main window

  3. MDI - windows

  4. MDI - windows • Frame window is main application window, it has • sizing border • title bar, window menu • minimize and maximze buttons • Frame window must be registered by application (by call to RegisterClass or RegisterClassEx)

  5. MDI - windows • MDI client window • uses predefined class MDICLIENT • it serves as background for child windows • it manages child windows, it can: • create child window • activate child window • maximize and minimize child windows • cascade and tile child windows

  6. MDI - windows • MDI child window • MDI child window has: • sizing border • title bar • minimize, maximize buttons • MDI child window class must be registered by application

  7. MDI – window procedures • MDI application must register at least two window classes and use two window procedures: • for the frame window • for the MDI child window • Frame window procedure must call DefFrameProc instead of DefWindowProc • MDI child window procedure must call DefMDIChildProc instead of DefWindowProc

  8. MDI – step by step • Create frame window procedure • Create MDI child window procedure • Register frame window class • Register MDI child window class • Create main application window • Create MDI client window • Modify message loop and add call to TranslateMDISysAccel

  9. Create MDI client window case WM_CREATE: { CLIENTCREATESTRUCT ccs; ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), 1); ccs.idFirstChild = 10000; hMDIClient = CreateWindow( "MDICLIENT", "", WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE, 0, 0, 0, 0, hWnd, (HMENU)1, hInst, &ccs); } ... default: return DefFrameProc(hWnd, hMDIClient, message, wParam, lParam);

  10. Modify message loop while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateMDISysAccel(hMDIClient, &msg) && !TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } }

  11. MDI menu • MDI child window names are automatically added to window menu. • Selecting menu item corresponding to MDI child window activates the window • Handle to menu where MDI child window names should be added is passed to MDICLIENT window • If there are more than 10 MDI child windows – “more windows” menu item is displayed

  12. Standard MDI commands • Standard MDI commands like Cascade, Tile are handled by sending messages to MDI child window • case ID_WINDOW_TILE_HORZ: • SendMessage( hMDIClient, WM_MDITILE, • MDITILE_HORIZONTAL, 0 ); • break; • case ID_WINDOW_CASCADE: • SendMessage( hMDIClient, WM_MDICASCADE, 0, 0 ); • break; • case ID_WINDOW_ARRANGE: • SendMessage( hMDIClient, WM_MDIICONARRANGE, 0, 0 ); • break;

More Related