|
|
1.1 root 1: /***************************************************************************\
2: * mdi.c - MDI application
3: *
4: * Created by Microsoft Corporation, 1989
5: \***************************************************************************/
6:
7: #define INCL_WINSYS
8: #define INCL_WINCOMMON
9: #define INCL_WINMESSAGEMGR
10: #define INCL_WINPOINTERS
11: #define INCL_WININPUT
12: #define INCL_WINMENUS
13: #define INCL_WINFRAMEMGR
14: #define INCL_WINWINDOWMGR
15: #define INCL_WINRECTANGLES
16: #define INCL_WINHEAP
17:
18: #include <os2.h>
19: #include "app.h"
20: #include "appdata.h"
21: #include "mdi.h"
22: #include "mdidata.h"
23:
24:
25: VOID MDIDesktopSize(HWND hwnd, MPARAM mp1, MPARAM mp2)
26: {
27: HWND hwndDoc;
28: RECTL rclWindow;
29: POINTL ptlBorderSize;
30: HENUM henum;
31: SWP swp;
32: ULONG ulStyle;
33:
34: /*
35: * This code keeps maximized MDI windows maximized within the
36: * main client window and bottom-left aligns minimized windows.
37: */
38: WinQueryWindowRect(hwnd, (PRECTL)&rclWindow);
39:
40: WinSendMsg(hwndMDIFrame, WM_QUERYBORDERSIZE, (MPARAM)&ptlBorderSize,
41: 0L);
42: WinInflateRect(NULL, (PRECTL)&rclWindow, (SHORT)ptlBorderSize.x,
43: (SHORT)ptlBorderSize.y);
44: rclWindow.yTop += cyTitlebar;
45:
46: swp.hwndInsertBehind = NULL;
47:
48: henum = WinBeginEnumWindows(hwnd);
49: while (hwndDoc = WinGetNextWindow(henum)) {
50: WinLockWindow(hwndDoc, FALSE);
51: ulStyle = WinQueryWindowULong(hwndDoc, QWL_STYLE);
52: if (ulStyle & WS_MAXIMIZED) {
53: swp.hwnd = hwndDoc;
54: swp.x = (SHORT)rclWindow.xLeft;
55: swp.y = (SHORT)rclWindow.yBottom;
56: swp.cx = (SHORT)rclWindow.xRight - (SHORT)rclWindow.xLeft;
57: swp.cy = (SHORT)rclWindow.yTop - (SHORT)rclWindow.yBottom;
58: swp.fs = SWP_MOVE | SWP_SIZE;
59: WinSetMultWindowPos(NULL, (PSWP)&swp, 1);
60: } else if (ulStyle & WS_MINIMIZED) {
61: WinQueryWindowPos(hwndDoc, &swp);
62: swp.y -= (SHORT2FROMMP(mp2) - SHORT2FROMMP(mp1));
63: swp.fs = SWP_MOVE;
64: WinSetMultWindowPos(NULL, (PSWP)&swp, 1);
65: }
66: }
67: WinEndEnumWindows(henum);
68:
69: /*
70: * Adjust yNextNewDoc to keep it top-left aligned.
71: */
72: yNextNewDoc += (SHORT2FROMMP(mp2) - SHORT2FROMMP(mp1));
73: }
74:
75:
76: VOID MDIDesktopSetFocus(HWND hwnd, MPARAM mp2)
77: {
78: HWND hwndTopDoc;
79:
80: /*
81: * If we're getting the focus and there is a document window,
82: * set the focus to the top-most document window so the main
83: * client window never has the focus.
84: */
85: if ((SHORT1FROMMP(mp2) != FALSE) &&
86: (hwndTopDoc = WinQueryWindow(hwnd, QW_TOP, FALSE))) {
87: WinSetFocus(HWND_DESKTOP, hwndTopDoc);
88: }
89: }
90:
91:
92: VOID MDIDesktopActivateDoc(SHORT idMenuitem)
93: {
94: register NPDOC npdoc;
95:
96: npdoc = npdocFirst;
97: while (npdoc != NULL) {
98: if (npdoc->idMI == idMenuitem) {
99: WinSetFocus(HWND_DESKTOP, npdoc->hwndFrame);
100:
101: /*
102: * If the document is minimized then
103: * restore it as well.
104: */
105: if (WinQueryWindowULong(npdoc->hwndFrame, QWL_STYLE) &
106: WS_MINIMIZED) {
107: WinSetWindowPos(npdoc->hwndFrame, NULL,
108: 0, 0, 0, 0, SWP_RESTORE);
109: }
110: break;
111: }
112: npdoc = npdoc->npdocNext;
113: }
114: }
115:
116:
117: MRESULT CALLBACK MainFrameWndProc(HWND hwnd, USHORT msg, MPARAM mp1,
118: MPARAM mp2)
119: {
120: switch (msg) {
121:
122: case WM_NEXTMENU:
123: /*
124: * Connect child sysmenu with application menus
125: */
126: if (fAabSysMenu == TRUE) {
127: /* child sysmenu is already in app menu */
128: break;
129: }
130:
131: #define hwndCurrent HWNDFROMMP(mp1)
132:
133: if (((hwndCurrent == hwndSysMenu) && !SHORT1FROMMP(mp2)) ||
134: ((hwndCurrent == hwndAppMenu) && SHORT1FROMMP(mp2))) {
135: if (hwndActiveDoc)
136: return (WinWindowFromID(hwndActiveDoc, FID_SYSMENU));
137: }
138:
139: #undef hwndCurrent
140:
141: break;
142: }
143: return (*pfnMainFrameWndProc)(hwnd, msg, mp1, mp2);
144: }
145:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.