Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

830 lines
23 KiB

  1. /*
  2. * pmwprocs.c - window procs for program manager
  3. *
  4. * Copyright (c) 1991, Microsoft Corporation
  5. *
  6. * DESCRIPTION
  7. *
  8. * This file is for support of program manager under NT Windows.
  9. * This file is/was ported from pmwprocs.c (program manager).
  10. *
  11. * MODIFICATION HISTORY
  12. * Initial Version: x/x/90 Author Unknown, since he didn't feel
  13. * like commenting the code...
  14. *
  15. * NT 32b Version: 1/18/91 Jeff Pack
  16. * Intitial port to begin.
  17. *
  18. *
  19. */
  20. #include "progman.h"
  21. #include "dde.h"
  22. extern BOOL bInNtSetup;
  23. /****************************************************************************
  24. *
  25. * SetProgmanProperties(DWORD dwDdeId, WORD wHotKey)
  26. *
  27. * Called when a new instance of progman was started from a Progman group
  28. * item. This will set the properties of the first instance of Progman,
  29. * setting the hotkey, the window title, the icon, and minimize Progman
  30. * if the item has Run Mimimized set.
  31. *
  32. * Called when Progman receives WM_EXECINSTANCE message send from 2nd progman
  33. * instance.
  34. *
  35. * 08-28-92 JohanneC Created.
  36. *
  37. ****************************************************************************/
  38. BOOL SetProgmanProperties(DWORD dwDdeId, WORD wHotKey)
  39. {
  40. LPGROUPDEF lpgd;
  41. LPITEMDEF lpid;
  42. PGROUP pGroup = NULL;
  43. PITEM pItem = NULL;
  44. HWND hwndT;
  45. BOOL Found = FALSE;
  46. HICON hIcon;
  47. BOOL bWasIconic = FALSE;
  48. //
  49. // Set Progman's hotkey.
  50. //
  51. SendMessage(hwndProgman, WM_SETHOTKEY, wHotKey, 0L);
  52. //
  53. // Find the group and the item corresponding to this information.
  54. //
  55. for (hwndT = GetWindow(hwndMDIClient, GW_CHILD);
  56. hwndT;
  57. hwndT = GetWindow(hwndT, GW_HWNDNEXT)) {
  58. if (GetWindow(hwndT, GW_OWNER))
  59. continue;
  60. pGroup = (PGROUP)GetWindowLongPtr(hwndT, GWLP_PGROUP);
  61. for (pItem = pGroup->pItems; pItem; pItem = pItem->pNext) {
  62. if (pItem->dwDDEId == dwDdeId) {
  63. //
  64. // Found a match.
  65. //
  66. Found = TRUE;
  67. break;
  68. }
  69. }
  70. if (Found)
  71. break;
  72. }
  73. if (!Found)
  74. return(FALSE);
  75. //
  76. // Set Progman Properties using the properties of its item.
  77. //
  78. //
  79. // Set the new icon.
  80. //
  81. hIcon = DuplicateIcon(hAppInstance, GetItemIcon(pGroup->hwnd, pItem));
  82. if (hIcon) {
  83. HICON hiconOld = (HICON)GetClassLongPtr(hwndProgman, GCLP_HICON);
  84. if (hiconOld)
  85. {
  86. DestroyIcon(hiconOld);
  87. }
  88. SetClassLongPtr(hwndProgman, GCLP_HICON, (LONG_PTR)hIcon);
  89. }
  90. if (IsIconic(hwndProgman))
  91. bWasIconic = TRUE;
  92. //
  93. // Check the minimize flag.
  94. //
  95. lpgd = GlobalLock(pGroup->hGroup);
  96. if (lpgd) {
  97. lpid = ITEM(lpgd, pItem->iItem);
  98. SetWindowText(hwndProgman, (LPTSTR) PTR(lpgd, lpid->pName));
  99. if (GroupFlag(pGroup, pItem, (WORD)ID_MINIMIZE))
  100. ShowWindow(hwndProgman, SW_SHOWMINNOACTIVE);
  101. GlobalUnlock(pGroup->hGroup);
  102. }
  103. if (bWasIconic) {
  104. //
  105. // to update the icon and text.
  106. //
  107. ShowWindow(hwndProgman, SW_HIDE);
  108. ShowWindow(hwndProgman, SW_SHOW);
  109. }
  110. return(TRUE);
  111. }
  112. void NEAR PASCAL RedoAllIconTitles()
  113. // Stomps on all the title rects.
  114. {
  115. HWND hwndGroup;
  116. PGROUP pGroup;
  117. PITEM pItem;
  118. HDC hdc;
  119. int cch;
  120. HFONT hFontT;
  121. LPRECT lprcTitle;
  122. LPTSTR lpText;
  123. LPGROUPDEF lpgd;
  124. LPITEMDEF lpid;
  125. POINT pt;
  126. for (hwndGroup=GetWindow(hwndMDIClient, GW_CHILD); hwndGroup; hwndGroup=GetWindow(hwndGroup, GW_HWNDNEXT))
  127. {
  128. if (GetWindow(hwndGroup, GW_OWNER))
  129. continue;
  130. pGroup = (PGROUP)GetWindowLongPtr(hwndGroup, GWLP_PGROUP);
  131. lpgd = LockGroup(hwndGroup);
  132. if (!lpgd)
  133. {
  134. continue;
  135. }
  136. for (pItem = pGroup->pItems; pItem; pItem = pItem->pNext)
  137. {
  138. lprcTitle = &(pItem->rcTitle);
  139. lpid = ITEM(lpgd, pItem->iItem);
  140. lpText = (LPTSTR) PTR(lpgd, lpid->pName);
  141. pt.x = pItem->rcIcon.left;
  142. pt.y = pItem->rcIcon.top;
  143. cch = lstrlen(lpText);
  144. hdc = GetDC(pGroup->hwnd);
  145. hFontT = SelectObject(hdc,hFontTitle);
  146. // compute the icon rect using DrawText
  147. SetRectEmpty(lprcTitle);
  148. lprcTitle->right = cxArrange - (2 * cxOffset);
  149. DrawText(hdc, lpText, -1,
  150. lprcTitle, bIconTitleWrap ?
  151. DT_CALCRECT | DT_WORDBREAK | DT_NOPREFIX :
  152. DT_CALCRECT | DT_WORDBREAK | DT_NOPREFIX | DT_SINGLELINE);
  153. if (hFontT)
  154. SelectObject(hdc,hFontT);
  155. ReleaseDC(pGroup->hwnd,hdc);
  156. lprcTitle->right += cxOffset*2;
  157. lprcTitle->bottom+= dyBorder*2;
  158. OffsetRect
  159. (
  160. lprcTitle,
  161. (pt.x+(cxIconSpace/2)-((lprcTitle->right
  162. -lprcTitle->left)/2)),
  163. (pt.y+cyIconSpace-dyBorder)
  164. );
  165. }
  166. UnlockGroup(hwndGroup);
  167. }
  168. }
  169. /*** GetRealParent --
  170. *
  171. *
  172. * HWND APIENTRY GetRealParent(HWND hWnd)
  173. *
  174. * ENTRY - HWND hWnd
  175. *
  176. * EXIT - HWND
  177. *
  178. * SYNOPSIS - ???
  179. *
  180. * WARNINGS -
  181. * EFFECTS -
  182. *
  183. */
  184. HWND APIENTRY GetRealParent(HWND hwnd)
  185. {
  186. /* run up the parent chain until you find a hwnd */
  187. /* that doesn't have WS_CHILD set*/
  188. /* BUG BUG, these should work as is????*/
  189. while (GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD){
  190. hwnd = (HANDLE) GetWindowLongPtr(hwnd, GWLP_HWNDPARENT);
  191. }
  192. return hwnd;
  193. }
  194. /*** AnyWriteable --
  195. *
  196. *
  197. * BOOL APIENTRY AnyWriteable()
  198. *
  199. * ENTRY - none
  200. *
  201. * EXIT - BOOL xxx - TRUE if read only, FALSE if not
  202. *
  203. * SYNOPSIS - ???
  204. *
  205. * WARNINGS -
  206. * EFFECTS -
  207. *
  208. */
  209. BOOL APIENTRY AnyWriteable()
  210. {
  211. PGROUP pGroup;
  212. for (pGroup=pFirstGroup; pGroup; pGroup = pGroup->pNext)
  213. if (!pGroup->fRO){
  214. return TRUE;
  215. }
  216. return FALSE;
  217. }
  218. /*** ProgmanProc -- window procedure for program manager
  219. *
  220. *
  221. * LONG APIENTRY ProgmanWndProc(register HWND hwnd, UINT uiMsg,
  222. * register WPARAM wParam, LONG lParam)
  223. *
  224. * ENTRY - HWND hWnd
  225. * WORD uiMsg
  226. * WPARAM wParam
  227. * LONG lParam
  228. * EXIT - LONG xxx - returns info, or zero, for nothing to return
  229. *
  230. * SYNOPSIS - ???
  231. *
  232. * WARNINGS -
  233. * EFFECTS -
  234. *
  235. */
  236. LRESULT APIENTRY ProgmanWndProc(
  237. HWND hWnd,
  238. UINT uiMsg,
  239. WPARAM wParam,
  240. LPARAM lParam)
  241. {
  242. switch (uiMsg) {
  243. case WM_CREATE:
  244. {
  245. RECT rc;
  246. CLIENTCREATESTRUCT ccs;
  247. hwndProgman = hWnd;
  248. ccs.hWindowMenu = GetSubMenu(GetMenu(hWnd), IDM_WINDOW);
  249. ccs.idFirstChild = IDM_CHILDSTART;
  250. GetClientRect(hwndProgman, &rc);
  251. /*
  252. * Don't show the MDI client until all groups have
  253. * been created to avoid ungly painting.
  254. */
  255. hwndMDIClient = CreateWindow(TEXT("MDIClient"),
  256. NULL,
  257. WS_CLIPCHILDREN | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_BORDER,
  258. rc.left - 1, rc.top - 1,
  259. rc.right + 2, rc.bottom + 2,
  260. hWnd, (HMENU)1, hAppInstance,
  261. (LPTSTR)&ccs);
  262. if (!hwndMDIClient) {
  263. return -1;
  264. }
  265. break;
  266. }
  267. case WM_ENDSESSION:
  268. if (wParam != 0) { // nonzero means the session is being ended.
  269. EndSession:
  270. /* Don't close if restricted. */
  271. if (fNoClose)
  272. break;
  273. if (bSaveSettings)
  274. WriteINIFile();
  275. else
  276. SaveGroupsContent(FALSE);
  277. //
  278. // should Flush and close all registry keys here.
  279. //
  280. RegFlushKey(HKEY_CURRENT_USER);
  281. if (hkeyProgramManager) {
  282. if (hkeyPMSettings) {
  283. RegCloseKey(hkeyPMSettings);
  284. }
  285. if (hkeyPMGroups) {
  286. RegCloseKey(hkeyPMGroups);
  287. }
  288. RegCloseKey(hkeyProgramManager);
  289. }
  290. if (hkeyProgramGroups) {
  291. RegCloseKey(hkeyProgramGroups);
  292. }
  293. if (hkeyCommonGroups) {
  294. RegFlushKey(hkeyCommonGroups);
  295. RegCloseKey(hkeyCommonGroups);
  296. }
  297. /* Free the commdlg */
  298. if (hCommdlg)
  299. FreeLibrary(hCommdlg);
  300. ExitProcess(0);
  301. }
  302. break;
  303. case WM_CLOSE:
  304. /*
  305. * if wParam != 0, then this is shutdown. We don't want to logoff
  306. * again in this case, because we're already in the middle of
  307. * logoff. We just want to exit now.
  308. */
  309. if (wParam != 0)
  310. goto EndSession;
  311. /* Don't close if restricted. */
  312. if (fNoClose)
  313. return FALSE;
  314. if (GetKeyState(VK_SHIFT) < 0) {
  315. WriteINIFile();
  316. return TRUE;
  317. }
  318. /* Check if we've already tried to exit once... */
  319. if (fExiting) {
  320. SetCurrentDirectory(szOriginalDirectory);
  321. ExitWindows(0, 0);
  322. }
  323. fExiting = TRUE; // Stop LockGroup from trying to do a RELOAD
  324. // if the a lock fails due to group being
  325. // out of date.
  326. SetWindowLong (hwndProgman, GWL_EXITING, 1);
  327. if (bExitWindows) {
  328. if (lParam != (LPARAM)-1) {
  329. //
  330. // The user double-clicked on the system menu, use the new
  331. // logoff dialog.
  332. //
  333. if (MyDialogBox(NEWLOGOFFDLG,
  334. hwndProgman,
  335. NewLogoffDlgProc)) {
  336. }
  337. }
  338. else {
  339. if (MyDialogBox(IDD_END_WINDOWS_SESSION,
  340. hwndProgman,
  341. ExitDlgProc)) {
  342. SetCurrentDirectory(szOriginalDirectory);
  343. ExitWindows(0, 0);
  344. }
  345. }
  346. /* User clicked cancel or some app refused the ExitWindows... */
  347. fExiting = FALSE;
  348. SetWindowLong (hwndProgman, GWL_EXITING, 0);
  349. break;
  350. }
  351. else {
  352. if (bSaveSettings)
  353. WriteINIFile();
  354. else {
  355. //
  356. // If we are in setup, the groups and settings
  357. // will have already been saved in the
  358. // ExitProgman(1) dde handler.
  359. //
  360. if (!bInNtSetup)
  361. SaveGroupsContent(FALSE);
  362. }
  363. goto CallDFP;
  364. }
  365. case WM_LOGOFF:
  366. DestroyWindow(hwndProgman);
  367. return 0;
  368. case WM_DESTROY:
  369. if (!WinHelp(hwndProgman, szProgmanHelp, HELP_QUIT, 0L)) {
  370. MyMessageBox(hwndProgman, IDS_APPTITLE, IDS_WINHELPERR, NULL, MB_OK | MB_ICONEXCLAMATION | MB_SYSTEMMODAL);
  371. }
  372. /* Free font. */
  373. DeleteObject(hFontTitle);
  374. /* Free the commdlg junk. */
  375. if (hCommdlg)
  376. FreeLibrary(hCommdlg);
  377. /*
  378. * If user hit CTRL-ALT-DEL to logoff, restart or shutdown,
  379. * we still need to save the settings.
  380. */
  381. if (!fExiting && bSaveSettings) {
  382. WriteINIFile();
  383. }
  384. else
  385. SaveGroupsContent(FALSE);
  386. if (hbrWorkspace) {
  387. DeleteObject(hbrWorkspace);
  388. hbrWorkspace = NULL;
  389. }
  390. /*
  391. * Stop all translations
  392. */
  393. hwndMDIClient = NULL;
  394. hwndProgman = NULL;
  395. PostQuitMessage(0);
  396. break;
  397. case WM_DDE_TERMINATE:
  398. case WM_DDE_EXECUTE:
  399. case WM_DDE_ACK:
  400. case WM_DDE_REQUEST:
  401. case WM_DDE_DATA:
  402. case WM_DDE_ADVISE:
  403. case WM_DDE_UNADVISE:
  404. case WM_DDE_POKE:
  405. case WM_DDE_INITIATE:
  406. #ifdef DEBUG_PROGMAN_DDE
  407. {
  408. TCHAR szDebug[300];
  409. wsprintf (szDebug, TEXT("%d PROGMAN: Received DDE msg 0x%x\r\n"),
  410. GetTickCount(), uiMsg);
  411. OutputDebugString(szDebug);
  412. }
  413. #endif
  414. if (!bDisableDDE)
  415. {
  416. return (DDEMsgProc(hWnd, uiMsg, wParam, lParam));
  417. }
  418. goto CallDFP;
  419. case WM_INITMENU:
  420. {
  421. BOOL bGroup;
  422. WORD wEnable;
  423. INT i;
  424. PGROUP pGroup;
  425. bGroup = (SelectionType() != TYPE_ITEM);
  426. /*
  427. * Disable Delete/Properties if there aren't any groups.
  428. */
  429. if (!pCurrentGroup) {
  430. wEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED;
  431. } else {
  432. wEnable = MF_BYCOMMAND | MF_ENABLED;
  433. }
  434. EnableMenuItem((HMENU)wParam, IDM_PROPS, wEnable);
  435. if ((pCurrentGroup && pCurrentGroup->fRO) || dwEditLevel >= 2
  436. || (dwEditLevel == 1 && bGroup)) {
  437. wEnable = MF_BYCOMMAND | MF_GRAYED | MF_DISABLED;
  438. }
  439. EnableMenuItem((HMENU)wParam, IDM_DELETE, wEnable);
  440. /* Handle ArrangeItems menu... */
  441. if (pCurrentGroup && pCurrentGroup->fRO && !bGroup)
  442. wEnable = MF_BYCOMMAND | MF_GRAYED | MF_DISABLED;
  443. else
  444. wEnable = MF_BYCOMMAND | MF_ENABLED;
  445. EnableMenuItem((HMENU)wParam, IDM_ARRANGEICONS, wEnable);
  446. /*
  447. * Disable Move/Copy if 1. There aren't any groups,
  448. * 2. There aren't any items in the group,
  449. * 3. A group is selected.
  450. * 4. The group is read only.
  451. * 5. Restrictions do not permit it.
  452. * 6.There is only one group - just move
  453. * disabled.
  454. */
  455. if (!pCurrentGroup || !pCurrentGroup->pItems ||
  456. bGroup || !AnyWriteable() || dwEditLevel >= 2) {
  457. wEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED;
  458. } else {
  459. wEnable = MF_BYCOMMAND | MF_ENABLED;
  460. }
  461. EnableMenuItem((HMENU)wParam, IDM_COPY, wEnable);
  462. if (pCurrentGroup && pCurrentGroup->fRO) {
  463. wEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED;
  464. }
  465. EnableMenuItem((HMENU)wParam, IDM_MOVE, wEnable);
  466. i = 0;
  467. for (pGroup=pFirstGroup; pGroup; pGroup = pGroup->pNext) {
  468. if (!pGroup->fRO)
  469. i++;
  470. }
  471. if (i<2) {
  472. wEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED;
  473. EnableMenuItem((HMENU)wParam, IDM_MOVE, wEnable);
  474. }
  475. /*
  476. * Disable Open if 1. There aren't any groups,
  477. * 2. An empty, non-minimized group is selected.
  478. */
  479. if ((!pCurrentGroup) || (!bGroup && (!pCurrentGroup->pItems)
  480. && (!IsIconic(pCurrentGroup->hwnd)))) {
  481. wEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED;
  482. } else {
  483. wEnable = MF_BYCOMMAND | MF_ENABLED;
  484. }
  485. EnableMenuItem((HMENU)wParam, IDM_OPEN, wEnable);
  486. /*
  487. * Grey new if
  488. * can't create items, or
  489. * can't create groups and either the group is read only (can't
  490. * create an item in it) or a group is selected
  491. */
  492. if (dwEditLevel >= 2 || (dwEditLevel >= 1 &&
  493. (bGroup || pCurrentGroup->fRO))) {
  494. wEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED;
  495. } else {
  496. wEnable = MF_BYCOMMAND | MF_ENABLED;
  497. }
  498. EnableMenuItem((HMENU)wParam, IDM_NEW, wEnable);
  499. if (fNoRun) {
  500. EnableMenuItem((HMENU)wParam, IDM_RUN,
  501. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  502. }
  503. if (fNoClose) {
  504. EnableMenuItem((HMENU)wParam, IDM_EXIT,
  505. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  506. wParam = (WPARAM)GetSystemMenu(hWnd, FALSE);
  507. EnableMenuItem((HMENU)wParam, (WORD)SC_CLOSE,
  508. MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  509. }
  510. break;
  511. }
  512. case WM_SIZE:
  513. if (wParam != SIZEICONIC) {
  514. MoveWindow(hwndMDIClient, -1, -1, LOWORD(lParam) + 2,
  515. HIWORD(lParam) + 2, TRUE);
  516. }
  517. break;
  518. case WM_SYSCOLORCHANGE:
  519. if (hbrWorkspace) {
  520. DeleteObject(hbrWorkspace);
  521. }
  522. hbrWorkspace = CreateSolidBrush(GetSysColor(COLOR_APPWORKSPACE));
  523. //
  524. // Fall thru
  525. //
  526. case WM_WININICHANGE:
  527. {
  528. PGROUP pGroup;
  529. BOOL bOldIconTitleWrap;
  530. PVOID pEnv ;
  531. if (lstrcmpi((LPTSTR)lParam,TEXT("Environment")) ==0) {
  532. //
  533. // Check if the user's environment variables have changed, if so
  534. // regenerate the environment.
  535. //
  536. RegenerateUserEnvironment(&pEnv, TRUE);
  537. break;
  538. }
  539. bOldIconTitleWrap = bIconTitleWrap;
  540. SystemParametersInfo(SPI_ICONHORIZONTALSPACING, 0, (PVOID)&cxArrange, FALSE);
  541. SystemParametersInfo(SPI_ICONVERTICALSPACING, 0, (PVOID)&cyArrange, FALSE);
  542. SystemParametersInfo(SPI_GETICONTITLEWRAP, 0, (PVOID)&bIconTitleWrap, FALSE);
  543. // Handle title wrapping.
  544. if (bOldIconTitleWrap != bIconTitleWrap)
  545. RedoAllIconTitles();
  546. for (pGroup = pFirstGroup; pGroup; pGroup = pGroup->pNext) {
  547. NukeIconBitmap(pGroup);
  548. if (bAutoArrange) {
  549. ArrangeItems(pGroup->hwnd);
  550. }
  551. }
  552. InvalidateRect(hWnd, NULL, TRUE);
  553. break;
  554. }
  555. case WM_MENUSELECT:
  556. if (lParam) { /*make sure menu handle isn't null*/
  557. wMenuID = GET_WM_COMMAND_ID(wParam, lParam); /*get cmd from loword of wParam*/
  558. hSaveMenuHandle = (HANDLE)lParam; /*Save hMenu into one variable*/
  559. wSaveFlags = HIWORD(wParam);/*Save flags into another*/
  560. if (wMenuID >= IDM_CHILDSTART && wMenuID < IDM_HELPINDEX) {
  561. wMenuID = IDM_CHILDSTART;
  562. }
  563. bFrameSysMenu = (hSaveMenuHandle == GetSystemMenu(hwndProgman, FALSE));
  564. if (!bFrameSysMenu && wMenuID >= 0xf000) {
  565. //
  566. // According to winhelp: GetSystemMenu, uMenuID >= 0xf000
  567. // means system menu items!
  568. //
  569. // The group window is maximized, and group system menu
  570. // was selected
  571. //
  572. wSaveFlags |= MF_SYSMENU;
  573. }
  574. }
  575. break;
  576. case WM_EXECINSTANCE:
  577. {
  578. /*
  579. * Another instance of program manager has been started.
  580. * This can not be checked using the Windows 3.1 way because
  581. * starting apps is done asynchronously in NT, and the values
  582. * of pExecingGroup, pExecingItem and fInExec will always be FALSE.
  583. *
  584. * So we use the lpReserved field in the startupInfo structure
  585. * of the other instance to make sure is was called from progman.
  586. * This string is of the format "dde.%d,hotkey.%d" and it is
  587. * parsed in the other instance to extract the dde id and the hotkey.
  588. * These are passed as wParam and lParam respectively in the
  589. * WM_EXECINSTANCE message.
  590. *
  591. * - johannec 8/28/92
  592. */
  593. if (wParam) {
  594. SetProgmanProperties((DWORD)wParam, (WORD)lParam);
  595. }
  596. else {
  597. /*
  598. * The user isn't trying to run progman from within progman
  599. * so just show them that there's a progman already running...
  600. */
  601. if (IsIconic(hWnd))
  602. ShowWindow(hWnd,SW_SHOWNORMAL);
  603. SetForegroundWindow(hWnd);
  604. BringWindowToTop(hWnd);
  605. BringWindowToTop(GetLastActivePopup(hWnd));
  606. }
  607. break;
  608. }
  609. case WM_UNLOADGROUP:
  610. UnloadGroupWindow((HWND)wParam);
  611. break;
  612. case WM_RELOADGROUP:
  613. {
  614. TCHAR szGroupKey[MAXKEYLEN+1];
  615. WORD idGroup;
  616. BOOL bCommonGroup;
  617. lstrcpy(szGroupKey,((PGROUP)wParam)->lpKey);
  618. idGroup = ((PGROUP)wParam)->wIndex;
  619. bCommonGroup = ((PGROUP)wParam)->fCommon;
  620. UnloadGroupWindow(((PGROUP)wParam)->hwnd);
  621. fLowMemErrYet = FALSE;
  622. LoadGroupWindow(szGroupKey,idGroup, bCommonGroup);
  623. MyMessageBox(hwndProgman, IDS_GROUPFILEERR, IDS_GRPHASCHANGED,
  624. /* szGroupKey */ NULL, MB_OK | MB_ICONEXCLAMATION);
  625. break;
  626. }
  627. case WM_SYSCOMMAND:
  628. if (fNoClose && wParam == SC_CLOSE ||
  629. fNoClose && wParam == IDM_EXIT ||
  630. fNoClose && wParam == IDM_SHUTDOWN ) {
  631. break;
  632. }
  633. if (wParam == IDM_EXIT) {
  634. if (fNoFileMenu)
  635. break;
  636. PostMessage(hwndProgman, WM_CLOSE, 0, (LPARAM)-1);
  637. break;
  638. }
  639. if (wParam == IDM_SHUTDOWN) {
  640. if (fNoFileMenu)
  641. break;
  642. if (bExitWindows) {
  643. fExiting = TRUE;
  644. SetWindowLong (hwndProgman, GWL_EXITING, 1);
  645. /* Call the ShutdownDialog API. */
  646. ShutdownDialog(hAppInstance, hwndProgman);
  647. /* User clicked cancel or some app refused the ExitWindows... */
  648. fExiting = FALSE;
  649. SetWindowLong (hwndProgman, GWL_EXITING, 0);
  650. }
  651. break;
  652. }
  653. goto CallDFP;
  654. case WM_COMMAND:
  655. if (ProgmanCommandProc(hWnd, wParam, lParam)) {
  656. break;
  657. }
  658. goto CallDFP;
  659. default:
  660. if (uiMsg == uiActivateShellWindowMessage) {
  661. if (IsIconic(hwndProgman))
  662. ShowWindow(hwndProgman, SW_RESTORE);
  663. else
  664. BringWindowToTop(hwndProgman);
  665. } else if (uiMsg == uiConsoleWindowMessage) {
  666. PostMessage((HWND)wParam, uiConsoleWindowMessage, (WPARAM)hWnd, 0);
  667. } else if (uiMsg == uiSaveSettingsMessage) {
  668. WriteINIFile();
  669. } else if (uiMsg == uiHelpMessage) {
  670. if (wParam == MSGF_MENU) {
  671. /*
  672. * Get outta menu mode if help for a menu item.
  673. */
  674. if (wMenuID && hSaveMenuHandle) {
  675. wSaveMenuIDAroundSendMessage = wMenuID; /* save*/
  676. hSaveMenuHandleAroundSendMessage = hSaveMenuHandle;
  677. wSaveFlagsAroundSendMessage = wSaveFlags;
  678. SendMessage(hWnd, WM_CANCELMODE, 0, 0L);
  679. wMenuID = wSaveMenuIDAroundSendMessage; /* restore*/
  680. hSaveMenuHandle = hSaveMenuHandleAroundSendMessage;
  681. wSaveFlags = wSaveFlagsAroundSendMessage;
  682. }
  683. if (!(wSaveFlags & MF_POPUP)) {
  684. if (wSaveFlags & MF_SYSMENU){
  685. dwContext = bFrameSysMenu ? IDH_SYSMENU : IDH_SYSMENUCHILD;
  686. }
  687. else {
  688. dwContext = wMenuID + IDH_HELPFIRST;
  689. }
  690. PMHelp(hWnd);
  691. }
  692. }
  693. else if (wParam == MSGF_DIALOGBOX) {
  694. /* context range for message boxes*/
  695. if (dwContext >= IDH_MBFIRST && dwContext <= IDH_MBLAST){
  696. PMHelp(hWnd);
  697. }
  698. /* let dialog box deal with it*/
  699. PostMessage(GetRealParent((HWND)lParam), uiHelpMessage, 0, 0L);
  700. }
  701. }
  702. else{
  703. CallDFP:
  704. return DefFrameProc(hWnd, hwndMDIClient, uiMsg, wParam, lParam);
  705. }
  706. }
  707. return 0L;
  708. }