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.

2525 lines
60 KiB

  1. // File: confroom.cpp
  2. #include "precomp.h"
  3. #include "TopWindow.h"
  4. class CParticipant;
  5. #include "dbgMenu.h"
  6. #include "conf.h"
  7. #include "FloatBar.h"
  8. #include "StatBar.h"
  9. #include "RToolbar.h"
  10. #include "GenControls.h"
  11. #include "resource.h"
  12. #include "cr.h"
  13. #include "taskbar.h"
  14. #include "confman.h"
  15. #include <EndSesn.h>
  16. #include "cmd.h"
  17. #include "MenuUtil.h"
  18. #include "ConfPolicies.h"
  19. #include "call.h"
  20. #include "setupdd.h"
  21. #include "VidView.h"
  22. #include "audiowiz.h"
  23. #include "NmLdap.h"
  24. #include "ConfWnd.h"
  25. #include <iappldr.h>
  26. #include "ConfApi.h"
  27. #include "confroom.h"
  28. #include "NmManager.h"
  29. #include "dlgAcd.h"
  30. #include "dlgCall2.h"
  31. static const TCHAR s_cszHtmlHelpFile[] = TEXT("conf.chm");
  32. extern bool g_bInitControl;
  33. BOOL IntCreateRDSWizard(HWND hwndOwner);
  34. INT_PTR CALLBACK RDSSettingDlgProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam);
  35. extern BOOL FUiVisible(void);
  36. extern BOOL FIsAVCapable();
  37. inline DWORD MenuState(BOOL bEnabled)
  38. {
  39. return(bEnabled ? MF_ENABLED : MF_DISABLED|MF_GRAYED);
  40. }
  41. /****************************************************************************
  42. *
  43. * CLASS: CConfRoom
  44. *
  45. * MEMBER: CConfRoom()
  46. *
  47. * PURPOSE: Constructor - initializes variables
  48. *
  49. ****************************************************************************/
  50. CTopWindow::CTopWindow():
  51. m_hFontMenu (NULL),
  52. m_pConfRoom (NULL),
  53. m_pSeparator (NULL),
  54. m_pMainUI (NULL),
  55. m_pStatusBar (NULL),
  56. m_hwndPrevFocus (NULL),
  57. m_fTaskbarDblClick (FALSE),
  58. m_fMinimized (FALSE),
  59. m_fClosing (FALSE),
  60. m_fEnableAppSharingMenuItem (FALSE),
  61. m_fExitAndActivateRDSMenuItem (FALSE)
  62. {
  63. DbgMsg(iZONE_OBJECTS, "Obj: %08X created CTopWindow", this);
  64. // Load cursors:
  65. m_hWaitCursor = ::LoadCursor(NULL, IDC_APPSTARTING);
  66. }
  67. /****************************************************************************
  68. *
  69. * CLASS: CConfRoom
  70. *
  71. * MEMBER: ~CConfRoom()
  72. *
  73. * PURPOSE: Destructor
  74. *
  75. ****************************************************************************/
  76. CTopWindow::~CTopWindow()
  77. {
  78. // Delete the menu font:
  79. DeleteObject(m_hFontMenu);
  80. // Empty the tools menu list:
  81. CleanTools(NULL, m_ExtToolsList);
  82. CloseChildWindows();
  83. DbgMsg(iZONE_OBJECTS, "Obj: %08X destroyed CTopWindow", this);
  84. }
  85. // This gets called from OnClose and from the destructor (just in case)
  86. VOID CTopWindow::CloseChildWindows(void)
  87. {
  88. HWND hwnd = GetWindow();
  89. // Hide the main window as soon as possible
  90. if (NULL != hwnd)
  91. {
  92. ShowWindow(hwnd, SW_HIDE);
  93. }
  94. // Delete the UI elements:
  95. delete m_pStatusBar;
  96. m_pStatusBar = NULL;
  97. // BUGBUG georgep: This function is getting called twice
  98. if (NULL != m_pMainUI)
  99. {
  100. m_pMainUI->Release();
  101. m_pMainUI = NULL;
  102. }
  103. if (NULL != m_pSeparator)
  104. {
  105. m_pSeparator->Release();
  106. m_pSeparator = NULL;
  107. }
  108. if (NULL != hwnd)
  109. {
  110. ::DestroyWindow(hwnd);
  111. ASSERT(!GetWindow());
  112. }
  113. if (NULL != m_pConfRoom)
  114. {
  115. // Make sure we do not try this multiple times
  116. CConfRoom *pConfRoom = m_pConfRoom;
  117. m_pConfRoom = NULL;
  118. pConfRoom->Release();
  119. // BUGBUG georgep: We need true reference counting here
  120. delete pConfRoom;
  121. }
  122. }
  123. /****************************************************************************
  124. *
  125. * CLASS: CConfRoom
  126. *
  127. * MEMBER: UpdateUI(DWORD dwUIMask)
  128. *
  129. * PURPOSE: Updates the appropriate pieces of the UI
  130. *
  131. ****************************************************************************/
  132. VOID CTopWindow::UpdateUI(DWORD dwUIMask)
  133. {
  134. if ((CRUI_TOOLBAR & dwUIMask) && (NULL != m_pMainUI))
  135. {
  136. m_pMainUI->UpdateButtons();
  137. }
  138. if (CRUI_TITLEBAR & dwUIMask)
  139. {
  140. UpdateWindowTitle();
  141. }
  142. if (CRUI_STATUSBAR & dwUIMask)
  143. {
  144. UpdateStatusBar();
  145. }
  146. if (CRUI_CALLANIM & dwUIMask)
  147. {
  148. UpdateCallAnim();
  149. }
  150. }
  151. /****************************************************************************
  152. *
  153. * CLASS: CConfRoom
  154. *
  155. * MEMBER: UpdateWindowTitle()
  156. *
  157. * PURPOSE: Updates the titlebar with the appropriate message
  158. *
  159. ****************************************************************************/
  160. BOOL CTopWindow::UpdateWindowTitle()
  161. {
  162. TCHAR szTitle[MAX_PATH];
  163. TCHAR szBuf[MAX_PATH];
  164. BOOL bRet = FALSE;
  165. if (::LoadString(GetInstanceHandle(), IDS_MEDIAPHONE_TITLE, szBuf, sizeof(szBuf)))
  166. {
  167. lstrcpy(szTitle, szBuf);
  168. int nPart = m_pConfRoom->GetMemberCount();
  169. if (nPart > 2)
  170. {
  171. TCHAR szFormat[MAX_PATH];
  172. if (::LoadString(GetInstanceHandle(), IDS_MEDIAPHONE_INCALL, szFormat, sizeof(szFormat)))
  173. {
  174. wsprintf(szBuf, szFormat, (nPart - 1));
  175. lstrcat(szTitle, szBuf);
  176. }
  177. }
  178. else if (2 == nPart)
  179. {
  180. if (::LoadString(GetInstanceHandle(), IDS_MEDIAPHONE_INCALL_ONE, szBuf, sizeof(szBuf)))
  181. {
  182. lstrcat(szTitle, szBuf);
  183. }
  184. }
  185. else
  186. {
  187. if (::LoadString(GetInstanceHandle(), IDS_MEDIAPHONE_NOTINCALL, szBuf, sizeof(szBuf)))
  188. {
  189. lstrcat(szTitle, szBuf);
  190. }
  191. }
  192. HWND hwnd = GetWindow();
  193. if (NULL != hwnd)
  194. {
  195. bRet = ::SetWindowText(hwnd, szTitle);
  196. }
  197. }
  198. return bRet;
  199. }
  200. /****************************************************************************
  201. *
  202. * CLASS: CConfRoom
  203. *
  204. * MEMBER: Create()
  205. *
  206. * PURPOSE: Creates a window
  207. *
  208. ****************************************************************************/
  209. BOOL CTopWindow::Create(CConfRoom *pConfRoom, BOOL fShowUI)
  210. {
  211. ASSERT(NULL == m_pConfRoom);
  212. m_pConfRoom = pConfRoom;
  213. m_pConfRoom->AddRef();
  214. HICON hiBig = LoadIcon(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDI_CONFROOM));
  215. if (!CFrame::Create(
  216. NULL,
  217. g_szEmpty,
  218. (WS_OVERLAPPEDWINDOW&~(WS_THICKFRAME|WS_MAXIMIZEBOX)) | WS_CLIPCHILDREN,
  219. 0,
  220. 0, 0,
  221. 100,
  222. 100,
  223. _Module.GetModuleInstance(),
  224. hiBig,
  225. LoadMenu(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDR_CONFROOM_MENU)),
  226. g_szConfRoomClass
  227. ))
  228. {
  229. return(FALSE);
  230. }
  231. // Do a resize early so if the menu wraps, it will be taken into account
  232. // by the following GetDesiredSize call
  233. Resize();
  234. SIZE defSize;
  235. GetDesiredSize(&defSize);
  236. InitMenuFont();
  237. RegEntry reConf(UI_KEY, HKEY_CURRENT_USER);
  238. // NOTE: it isn't actually the width and the height of the
  239. // window - it is the right and the bottom.
  240. RECT rctSize;
  241. rctSize.right = defSize.cx;
  242. rctSize.bottom = defSize.cy;
  243. rctSize.left = reConf.GetNumber(REGVAL_MP_WINDOW_X, DEFAULT_MP_WINDOW_X);
  244. rctSize.top = reConf.GetNumber(REGVAL_MP_WINDOW_Y, DEFAULT_MP_WINDOW_Y);
  245. if (ERROR_SUCCESS != reConf.GetError())
  246. {
  247. // Center the window on the screen
  248. int dx = GetSystemMetrics(SM_CXFULLSCREEN);
  249. if (dx > rctSize.right)
  250. {
  251. rctSize.left = (dx - rctSize.right) / 2;
  252. }
  253. int dy = GetSystemMetrics(SM_CYFULLSCREEN);
  254. #if FALSE
  255. // BUGBUG georgep: Should this be in GetDesiredSize?
  256. // adjust default height if using large video windows on a LAN
  257. if (dy >= 553) // 800 x 600
  258. {
  259. RegEntry reAudio(AUDIO_KEY, HKEY_CURRENT_USER);
  260. if (BW_MOREKBS == reAudio.GetNumber(REGVAL_TYPICALBANDWIDTH,BW_DEFAULT))
  261. {
  262. ASSERT(DEFAULT_MP_WINDOW_HEIGHT == rctSize.bottom);
  263. rctSize.bottom = DEFAULT_MP_WINDOW_HEIGHT_LAN;
  264. }
  265. }
  266. #endif
  267. if (dy > rctSize.bottom)
  268. {
  269. rctSize.top = (dy - rctSize.bottom) / 2;
  270. }
  271. }
  272. rctSize.right += rctSize.left;
  273. rctSize.bottom += rctSize.top;
  274. WINDOWPLACEMENT wp;
  275. wp.length = sizeof(wp);
  276. HWND hwnd = GetWindow();
  277. ::GetWindowPlacement(hwnd, &wp);
  278. wp.flags = 0;
  279. if (!fShowUI)
  280. {
  281. // NOUI - must hide
  282. wp.showCmd = SW_HIDE;
  283. }
  284. else
  285. {
  286. wp.showCmd = SW_SHOWNORMAL;
  287. STARTUPINFO si;
  288. si.cb = sizeof(si);
  289. ::GetStartupInfo(&si);
  290. if ((STARTF_USESHOWWINDOW & si.dwFlags) &&
  291. (SW_SHOWMAXIMIZED != si.wShowWindow))
  292. {
  293. wp.showCmd = si.wShowWindow;
  294. }
  295. }
  296. wp.rcNormalPosition = rctSize;
  297. CNmManagerObj::OnShowUI(fShowUI);
  298. ::SetWindowPlacement(hwnd, &wp);
  299. switch (wp.showCmd)
  300. {
  301. case SW_SHOWMINIMIZED:
  302. case SW_MINIMIZE:
  303. case SW_SHOWMINNOACTIVE:
  304. case SW_FORCEMINIMIZE:
  305. case SW_HIDE:
  306. break;
  307. default:
  308. if (0 != ::SetForegroundWindow(hwnd))
  309. {
  310. // BUGBUG georgep: Shouldn't the system do this for us?
  311. FORWARD_WM_QUERYNEWPALETTE(GetWindow(), ProcessMessage);
  312. }
  313. break;
  314. }
  315. // Paint the window completely (bug 171):
  316. // ::UpdateWindow(hwnd);
  317. //
  318. // Call GetSystemMenu(m_hwnd, FALSE) to get the private copy
  319. // of the system menu created NOW before we enter menu mode the
  320. // first time.private copy created. That way calling
  321. // GetSystemMenu(m_hwnd, FALSE) in OnMenuSelect
  322. // won't wipe out the old menu and cause the sysmenu to be
  323. // positioned in the wrong place the first time.
  324. //
  325. ::GetSystemMenu(hwnd, FALSE);
  326. #ifdef DEBUG
  327. // Verify all of the menus have the proper text
  328. // TODO: Verify accelerator keys are unique per menu
  329. {
  330. HMENU hMenuMain = ::GetMenu(hwnd);
  331. for (int iMenu = 0; iMenu <= MENUPOS_HELP; iMenu++)
  332. {
  333. HMENU hMenuSub = ::GetSubMenu(hMenuMain, iMenu);
  334. for (int i = 0; ; i++)
  335. {
  336. TCHAR szMenu[MAX_PATH];
  337. MENUITEMINFO mii;
  338. InitStruct(&mii);
  339. mii.fMask = MIIM_TYPE | MIIM_DATA | MIIM_ID | MIIM_SUBMENU;
  340. mii.dwTypeData = szMenu;
  341. mii.cch = CCHMAX(szMenu);
  342. if (!GetMenuItemInfo(hMenuSub, i, TRUE, &mii))
  343. break; // out of for loop
  344. if (0 != (mii.fType & MFT_SEPARATOR))
  345. continue; // skip separators
  346. if (0 != (mii.hSubMenu))
  347. continue; // skip submenus
  348. }
  349. }
  350. }
  351. #endif /* DEBUG */
  352. UpdateStatusBar();
  353. return(TRUE);
  354. }
  355. /****************************************************************************
  356. *
  357. * CLASS: CConfRoom
  358. *
  359. * MEMBER: SaveSettings()
  360. *
  361. * PURPOSE: Saves UI settings in the registry
  362. *
  363. ****************************************************************************/
  364. VOID CTopWindow::SaveSettings()
  365. {
  366. DebugEntry(CConfRoom::SaveSettings);
  367. RegEntry reConf(UI_KEY, HKEY_CURRENT_USER);
  368. // Save window coords to registry:
  369. WINDOWPLACEMENT wp;
  370. wp.length = sizeof(WINDOWPLACEMENT);
  371. if (::GetWindowPlacement(GetWindow(), &wp))
  372. {
  373. reConf.SetValue(REGVAL_MP_WINDOW_X,
  374. wp.rcNormalPosition.left);
  375. reConf.SetValue(REGVAL_MP_WINDOW_Y,
  376. wp.rcNormalPosition.top);
  377. }
  378. // Save window elements to the registry:
  379. reConf.SetValue(REGVAL_SHOW_STATUSBAR, CheckMenu_ViewStatusBar(NULL));
  380. if (NULL != m_pMainUI)
  381. {
  382. m_pMainUI->SaveSettings();
  383. // Only write if a setting has changed, so we can have default
  384. // behavior as long as possible
  385. if (m_fStateChanged)
  386. {
  387. int state = 0;
  388. if (m_pMainUI->IsCompact())
  389. {
  390. state = State_Compact;
  391. }
  392. else if (m_pMainUI->IsDataOnly())
  393. {
  394. state = State_DataOnly;
  395. }
  396. else
  397. {
  398. state = State_Normal;
  399. }
  400. if (m_pMainUI->IsPicInPic())
  401. {
  402. state |= SubState_PicInPic;
  403. }
  404. if (m_pMainUI->IsDialing())
  405. {
  406. state |= SubState_Dialpad;
  407. }
  408. if (IsOnTop())
  409. {
  410. state |= SubState_OnTop;
  411. }
  412. reConf.SetValue(REGVAL_MP_WINDOW_STATE, state);
  413. }
  414. }
  415. // NOTE: CMainUI saves its settings in its destructor
  416. DebugExitVOID(CConfRoom::SaveSettings);
  417. }
  418. /****************************************************************************
  419. *
  420. * CLASS: CConfRoom
  421. *
  422. * MEMBER: BringToFront()
  423. *
  424. * PURPOSE: Restores the window (if minimized) and brings it to the front
  425. *
  426. ****************************************************************************/
  427. BOOL CTopWindow::BringToFront()
  428. {
  429. ShowUI();
  430. return TRUE;
  431. }
  432. /* S H O W U I */
  433. /*-------------------------------------------------------------------------
  434. %%Function: ShowUI
  435. Show the main NetMeeting window.
  436. -------------------------------------------------------------------------*/
  437. VOID CTopWindow::ShowUI(void)
  438. {
  439. HWND hwnd = GetWindow();
  440. if (NULL == hwnd)
  441. return; // no ui to show?
  442. if (!IsWindowVisible(hwnd))
  443. {
  444. CNmManagerObj::OnShowUI(TRUE);
  445. ShowWindow(hwnd, SW_SHOW);
  446. }
  447. WINDOWPLACEMENT wp;
  448. wp.length = sizeof(wp);
  449. if (::GetWindowPlacement(hwnd, &wp) &&
  450. ((SW_MINIMIZE == wp.showCmd) || (SW_SHOWMINIMIZED == wp.showCmd)))
  451. {
  452. // The window is minimized - restore it:
  453. ::ShowWindow(hwnd, SW_RESTORE);
  454. }
  455. ::SetForegroundWindow(hwnd);
  456. }
  457. /****************************************************************************
  458. *
  459. * CLASS: CConfRoom
  460. *
  461. * MEMBER: ProcessMessage(HWND, UINT, WPARAM, LPARAM)
  462. *
  463. * PURPOSE: Handles messages except WM_CREATE and WM_COMMAND
  464. *
  465. ****************************************************************************/
  466. LRESULT CTopWindow::ProcessMessage( HWND hWnd,
  467. UINT message,
  468. WPARAM wParam,
  469. LPARAM lParam)
  470. {
  471. static const UINT c_uMsgXchgConf = ::RegisterWindowMessage(_TEXT("Xchg_TAPIVideoRelease"));
  472. switch (message)
  473. {
  474. HANDLE_MSG(hWnd, WM_INITMENU , OnInitMenu);
  475. HANDLE_MSG(hWnd, WM_INITMENUPOPUP, OnInitMenuPopup);
  476. HANDLE_MSG(hWnd, WM_MEASUREITEM, OnMeasureItem);
  477. HANDLE_MSG(hWnd, WM_DRAWITEM, OnDrawItem);
  478. HANDLE_MSG(hWnd, WM_COMMAND , OnCommand);
  479. // The windowsx macro does not pass down the offset of the popup menu
  480. case WM_MENUSELECT:
  481. OnMenuSelect(hWnd, (HMENU)(lParam), (int)(LOWORD(wParam)),
  482. (UINT)(((short)HIWORD(wParam) == -1) ? 0xFFFFFFFF : HIWORD(wParam)));
  483. return(0);
  484. case WM_CREATE:
  485. {
  486. // We need to add our accelerator table before the children do
  487. m_pAccel = new CTranslateAccelTable(GetWindow(),
  488. ::LoadAccelerators(GetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATORS)));
  489. if (NULL != m_pAccel)
  490. {
  491. AddTranslateAccelerator(m_pAccel);
  492. }
  493. // AddModelessDlg(hWnd);
  494. CreateChildWindows();
  495. InitDbgMenu(hWnd);
  496. break;
  497. }
  498. case WM_ACTIVATE:
  499. {
  500. if ((WA_INACTIVE == LOWORD(wParam)) && (FALSE == m_fMinimized))
  501. {
  502. m_hwndPrevFocus = ::GetFocus();
  503. TRACE_OUT(("Losing activation, focus on hwnd 0x%08x",
  504. m_hwndPrevFocus));
  505. }
  506. else if (NULL != m_hwndPrevFocus)
  507. {
  508. ::SetFocus(m_hwndPrevFocus);
  509. }
  510. else
  511. {
  512. if (NULL != m_pMainUI)
  513. {
  514. ::SetFocus(m_pMainUI->GetWindow());
  515. }
  516. }
  517. break;
  518. }
  519. case WM_GETMINMAXINFO:
  520. {
  521. if (FALSE != m_fMinimized)
  522. {
  523. // if the window is minimized, we don't want to handle this
  524. break;
  525. }
  526. SIZE size;
  527. GetDesiredSize(&size);
  528. ((LPMINMAXINFO) lParam)->ptMinTrackSize.x = size.cx;
  529. ((LPMINMAXINFO) lParam)->ptMinTrackSize.y = size.cy;
  530. return 0;
  531. }
  532. case WM_STATUSBAR_UPDATE:
  533. UpdateStatusBar();
  534. break;
  535. case WM_SYSCOLORCHANGE:
  536. {
  537. if (NULL != m_pMainUI)
  538. {
  539. m_pMainUI->ForwardSysChangeMsg(message, wParam, lParam);
  540. }
  541. break;
  542. }
  543. case WM_WININICHANGE:
  544. {
  545. InitMenuFont();
  546. // Propagate the message to the child windows:
  547. if (NULL != m_pStatusBar)
  548. {
  549. m_pStatusBar->ForwardSysChangeMsg(message, wParam, lParam);
  550. }
  551. if (NULL != m_pMainUI)
  552. {
  553. m_pMainUI->ForwardSysChangeMsg(message, wParam, lParam);
  554. }
  555. // Force a resize:
  556. if (NULL != m_pStatusBar)
  557. {
  558. m_pStatusBar->Resize(SIZE_RESTORED, 0);
  559. }
  560. ResizeChildWindows();
  561. break;
  562. }
  563. case WM_HELP:
  564. {
  565. LPHELPINFO phi = (LPHELPINFO) lParam;
  566. ASSERT(phi);
  567. TRACE_OUT(("WM_HELP, iContextType=%d, iCtrlId=%d",
  568. phi->iContextType, phi->iCtrlId));
  569. break;
  570. }
  571. case WM_SETCURSOR:
  572. {
  573. switch (LOWORD(lParam))
  574. {
  575. case HTLEFT:
  576. case HTRIGHT:
  577. case HTTOP:
  578. case HTTOPLEFT:
  579. case HTTOPRIGHT:
  580. case HTBOTTOM:
  581. case HTBOTTOMLEFT:
  582. case HTBOTTOMRIGHT:
  583. {
  584. break;
  585. }
  586. default:
  587. {
  588. if (g_cBusyOperations > 0)
  589. {
  590. ::SetCursor(m_hWaitCursor);
  591. return TRUE;
  592. }
  593. }
  594. }
  595. // we didn't process the cursor msg:
  596. return CFrame::ProcessMessage(hWnd, message, wParam, lParam);
  597. }
  598. case WM_SIZE:
  599. {
  600. if (SIZE_MINIMIZED == wParam)
  601. {
  602. // transitioning to being minimized:
  603. m_fMinimized = TRUE;
  604. }
  605. else if ((SIZE_MAXIMIZED == wParam) || (SIZE_RESTORED == wParam))
  606. {
  607. if (m_fMinimized)
  608. {
  609. // transitioning from being minimized:
  610. m_fMinimized = FALSE;
  611. if (NULL != m_hwndPrevFocus)
  612. {
  613. ::SetFocus(m_hwndPrevFocus);
  614. }
  615. }
  616. if (NULL != m_pStatusBar)
  617. {
  618. m_pStatusBar->Resize(wParam, lParam);
  619. }
  620. ResizeChildWindows();
  621. }
  622. // The menu may have wrapped or unwrapped
  623. OnDesiredSizeChanged();
  624. break;
  625. }
  626. case WM_SYSCOMMAND:
  627. {
  628. if (SC_MINIMIZE == wParam)
  629. {
  630. m_hwndPrevFocus = ::GetFocus();
  631. TRACE_OUT(("Being minimized, focus on hwnd 0x%08x",
  632. m_hwndPrevFocus));
  633. }
  634. return CFrame::ProcessMessage(hWnd, message, wParam, lParam);
  635. }
  636. // Doing this in QUERYENDSESSION so all apps have more CPU to shut down
  637. case WM_QUERYENDSESSION:
  638. {
  639. if (FIsConferenceActive() &&
  640. (IDNO == ::ConfMsgBox( GetWindow(),
  641. (LPCTSTR) IDS_CLOSEWINDOW_PERMISSION,
  642. MB_SETFOREGROUND | MB_YESNO | MB_ICONQUESTION)))
  643. {
  644. return FALSE;
  645. }
  646. CMainUI *pMainUI = GetMainUI();
  647. if (NULL != pMainUI)
  648. {
  649. if (!pMainUI->OnQueryEndSession())
  650. {
  651. return(FALSE);
  652. }
  653. }
  654. m_pConfRoom->OnHangup(NULL, FALSE); // we've already confirmed
  655. return TRUE;
  656. }
  657. case WM_CLOSE:
  658. // HACKHACK: lParam shouldn't really be used in a WM_CLOSE
  659. OnClose(hWnd, lParam);
  660. break;
  661. case WM_DESTROY:
  662. {
  663. // RemoveModelessDlg(hWnd);
  664. if (NULL != m_pAccel)
  665. {
  666. RemoveTranslateAccelerator(m_pAccel);
  667. m_pAccel->Release();
  668. m_pAccel = NULL;
  669. }
  670. break;
  671. }
  672. case WM_POWERBROADCAST:
  673. {
  674. // Don't allow suspend while NetMeeting is running
  675. // so that we can receive calls.
  676. if (PBT_APMQUERYSUSPEND == wParam)
  677. {
  678. // Don't suspend on Win95 - we can't handle it
  679. if (g_osvi.dwMajorVersion == 4 && g_osvi.dwMinorVersion == 0
  680. && g_osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
  681. {
  682. // Put up UI if lParam says it's ok to do so
  683. if ( lParam & 0x1 )
  684. {
  685. ::PostConfMsgBox(IDS_WONT_SUSPEND);
  686. }
  687. return BROADCAST_QUERY_DENY;
  688. }
  689. }
  690. return CFrame::ProcessMessage(hWnd, message, wParam, lParam);
  691. }
  692. default:
  693. {
  694. if (message == c_uMsgXchgConf)
  695. {
  696. OnReleaseCamera();
  697. }
  698. else
  699. {
  700. return CFrame::ProcessMessage(hWnd, message, wParam, lParam);
  701. }
  702. break;
  703. }
  704. }
  705. return 0;
  706. }
  707. //
  708. // OnReleaseCamera()
  709. //
  710. // This is a hack for Exchange Real-Time server, so that NetMeeting will
  711. // release the video camera while the user is in an Xchg multicast video
  712. // conference, but can get it back when either
  713. // * the user goes to video options
  714. // * the conference ends
  715. //
  716. void CTopWindow::OnReleaseCamera(void)
  717. {
  718. CVideoWindow *pLocal = GetLocalVideo();
  719. if (NULL != pLocal)
  720. {
  721. // Release camera if in use
  722. WARNING_OUT(("CTopWindow::OnReleaseCamera -- releasing capture device"));
  723. pLocal->SetCurrCapDevID((DWORD)-1);
  724. }
  725. }
  726. void CTopWindow::OnClose(HWND hwnd, LPARAM lParam)
  727. {
  728. ASSERT(!m_fClosing);
  729. m_fClosing = TRUE;
  730. BOOL fNeedsHangup = FALSE;
  731. if (0 == CNmManagerObj::GetManagerCount(NM_INIT_OBJECT))
  732. {
  733. fNeedsHangup = FIsConferenceActive();
  734. if(fNeedsHangup && _Module.IsUIVisible())
  735. {
  736. UINT_PTR uMsg;
  737. if ((m_pConfRoom->GetMemberCount() <= 2) ||
  738. (FALSE == m_pConfRoom->FHasChildNodes()))
  739. {
  740. // Get confirmation
  741. // (DON'T mention that it will disconnect others)
  742. uMsg = IDS_CLOSEWINDOW_PERMISSION;
  743. }
  744. else
  745. {
  746. // Get confirmation
  747. // (DO mention that it will disconnect others)
  748. uMsg = IDS_CLOSE_DISCONNECT_PERMISSION;
  749. }
  750. UINT uMsgResult = ::ConfMsgBox( GetWindow(),
  751. (LPCTSTR) uMsg,
  752. MB_YESNO | MB_ICONQUESTION);
  753. if (IDNO == uMsgResult)
  754. {
  755. m_fClosing = FALSE;
  756. ShowUI();
  757. return;
  758. }
  759. }
  760. }
  761. BOOL fListen = (0 == lParam) && ConfPolicies::RunWhenWindowsStarts();
  762. if((0 != _Module.GetLockCount()) || fListen)
  763. {
  764. // Hang up before closing (don't need to confirm)
  765. if(fNeedsHangup)
  766. {
  767. m_pConfRoom->OnHangup(NULL, FALSE);
  768. }
  769. WARNING_OUT(("Hiding NetMeeting Window"));
  770. CNmManagerObj::OnShowUI(FALSE);
  771. ShowWindow(GetWindow(), SW_HIDE);
  772. m_fClosing = FALSE;
  773. return; // we're closed :-)
  774. }
  775. if (0 != g_uEndSessionMsg)
  776. {
  777. HWND hWndWB = FindWindow( "Wb32MainWindowClass", NULL );
  778. if (hWndWB)
  779. {
  780. DWORD_PTR dwResult = TRUE;
  781. ::SendMessageTimeout( hWndWB,
  782. g_uEndSessionMsg,
  783. 0,
  784. 0,
  785. SMTO_BLOCK | SMTO_ABORTIFHUNG,
  786. g_cuEndSessionMsgTimeout,
  787. &dwResult
  788. );
  789. if( g_cuEndSessionAbort == dwResult )
  790. {
  791. m_fClosing = FALSE;
  792. ShowUI();
  793. return;
  794. }
  795. }
  796. }
  797. // Check to see if Chat can close
  798. if(!m_pConfRoom->CanCloseChat(GetWindow()) ||
  799. !m_pConfRoom->CanCloseWhiteboard(GetWindow()) ||
  800. !m_pConfRoom->CanCloseFileTransfer(GetWindow()))
  801. {
  802. m_fClosing = FALSE;
  803. if (!_Module.IsSDKCallerRTC())
  804. {
  805. ShowUI();
  806. }
  807. return;
  808. }
  809. if(0 != _Module.GetLockCount())
  810. {
  811. m_fClosing = FALSE;
  812. return;
  813. }
  814. SignalShutdownStarting();
  815. // Shut the preview off, this speeds up closing the app
  816. // and avoids fault in connection point object
  817. // (see bug 3301)
  818. CMainUI *pMainUI = GetMainUI();
  819. if (NULL != pMainUI)
  820. {
  821. pMainUI->OnClose();
  822. }
  823. if (fNeedsHangup)
  824. {
  825. // Hang up before closing (don't need to confirm)
  826. m_pConfRoom->OnHangup(NULL, FALSE);
  827. }
  828. // Ensure that the help window goes away if it is up:
  829. ShutDownHelp();
  830. // Shut down the Find Someone window before destroying g_pConfRoom
  831. CFindSomeone::Destroy();
  832. m_pConfRoom->TerminateAppSharing();
  833. SaveSettings();
  834. m_pConfRoom->FreePartList();
  835. CloseChildWindows();
  836. }
  837. void CTopWindow::GetDesiredSize(SIZE *psize)
  838. {
  839. HWND hwnd = GetWindow();
  840. #if TRUE // {
  841. // Need to check the actual non-client area in case the menu has wrapped
  842. RECT rctWnd, rctCli;
  843. ::GetWindowRect(hwnd, &rctWnd);
  844. ::GetClientRect(hwnd, &rctCli);
  845. // Determine the size of the non-client portions of the window
  846. // NOTE: rctCli.left and rctCli.top are always zero
  847. int dx = rctWnd.right - rctWnd.left - rctCli.right;
  848. int dy = rctWnd.bottom - rctWnd.top - rctCli.bottom;
  849. #else // }{
  850. RECT rcTemp = { 0, 0, 0, 0 };
  851. AdjustWindowRectEx(&rcTemp, GetWindowLong(hwnd, GWL_STYLE), TRUE,
  852. GetWindowLong(hwnd, GWL_EXSTYLE));
  853. int dx = rcTemp.right - rcTemp.left;
  854. int dy = rcTemp.bottom - rcTemp.top;
  855. #endif // }
  856. if (NULL != m_pMainUI)
  857. {
  858. SIZE size;
  859. m_pMainUI->GetDesiredSize(&size);
  860. dx += size.cx;
  861. dy += size.cy;
  862. }
  863. if (NULL != m_pSeparator)
  864. {
  865. SIZE size;
  866. m_pSeparator->GetDesiredSize(&size);
  867. dy += size.cy;
  868. }
  869. if (NULL != m_pStatusBar)
  870. {
  871. dy += m_pStatusBar->GetHeight();
  872. }
  873. psize->cx = dx;
  874. psize->cy = dy;
  875. }
  876. /****************************************************************************
  877. *
  878. * CLASS: CConfRoom
  879. *
  880. * MEMBER: OnMeasureMenuItem(LPMEASUREITEMSTRUCT lpmis)
  881. *
  882. * PURPOSE: Handles WM_MEASUREITEM for owner drawn menus
  883. *
  884. ****************************************************************************/
  885. void CTopWindow::OnMeasureItem(HWND hwnd, MEASUREITEMSTRUCT * lpmis)
  886. {
  887. if (ODT_MENU != lpmis->CtlType)
  888. {
  889. return;
  890. }
  891. ASSERT(ODT_MENU == lpmis->CtlType);
  892. PMYOWNERDRAWSTRUCT pmods = (PMYOWNERDRAWSTRUCT) lpmis->itemData;
  893. if (NULL != pmods)
  894. {
  895. //TRACE_OUT(("WM_MEASUREITEM, hIcon=0x%x, "
  896. // "pszText=%s", pmods->hIcon, pmods->pszText));
  897. // get size of text:
  898. /* Retrieve a device context for the main window. */
  899. HDC hdc = GetDC(hwnd);
  900. HFONT hfontOld = SelectFont(hdc, m_hFontMenu);
  901. /*
  902. * Retrieve the width and height of the item's string,
  903. * and then copy the width and height into the
  904. * MEASUREITEMSTRUCT structure's itemWidth and
  905. * itemHeight members.
  906. */
  907. SIZE size;
  908. GetTextExtentPoint32( hdc,
  909. pmods->pszText,
  910. lstrlen(pmods->pszText),
  911. &size);
  912. /*
  913. * Remember to leave space in the menu item for the
  914. * check mark bitmap. Retrieve the width of the bitmap
  915. * and add it to the width of the menu item.
  916. */
  917. lpmis->itemHeight = size.cy;
  918. lpmis->itemWidth = size.cx + MENUICONSIZE + MENUICONGAP + (2 * MENUICONSPACE);
  919. if (pmods->fCanCheck)
  920. {
  921. lpmis->itemWidth += ::GetSystemMetrics(SM_CXMENUCHECK);
  922. }
  923. // Adjust height if necessary:
  924. NONCLIENTMETRICS ncm;
  925. ncm.cbSize = sizeof(ncm);
  926. if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, FALSE))
  927. {
  928. // BUGBUG: In order to look correct,
  929. // this is necessary - I'm not sure why - investigate
  930. ncm.iMenuHeight += 2;
  931. if (lpmis->itemHeight < (UINT) ncm.iMenuHeight)
  932. {
  933. lpmis->itemHeight = ncm.iMenuHeight;
  934. }
  935. }
  936. /*
  937. * Select the old font back into the device context,
  938. * and then release the device context.
  939. */
  940. SelectObject(hdc, hfontOld);
  941. ReleaseDC(hwnd, hdc);
  942. }
  943. else
  944. {
  945. WARNING_OUT(("NULL pmods passed in WM_MEASUREITEM"));
  946. }
  947. }
  948. /****************************************************************************
  949. *
  950. * CLASS: CConfRoom
  951. *
  952. * MEMBER: OnDrawItem(LPDRAWITEMSTRUCT lpdis)
  953. *
  954. * PURPOSE: Handles WM_DRAWITEM for owner drawn menus
  955. *
  956. ****************************************************************************/
  957. void CTopWindow::OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpdis)
  958. {
  959. if (ID_STATUS == lpdis->CtlID)
  960. {
  961. if (NULL != m_pStatusBar)
  962. {
  963. m_pStatusBar->OnDraw(const_cast<DRAWITEMSTRUCT*>(lpdis));
  964. }
  965. return;
  966. }
  967. if (ODT_MENU != lpdis->CtlType)
  968. {
  969. return;
  970. }
  971. PMYOWNERDRAWSTRUCT pmods = (PMYOWNERDRAWSTRUCT) lpdis->itemData;
  972. BOOL fSelected = 0 != (lpdis->itemState & ODS_SELECTED);
  973. COLORREF crText = SetTextColor(lpdis->hDC,
  974. ::GetSysColor(fSelected ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT));
  975. COLORREF crBkgnd = SetBkColor(lpdis->hDC,
  976. ::GetSysColor(fSelected ? COLOR_HIGHLIGHT : COLOR_MENU));
  977. /*
  978. * Remember to leave space in the menu item for the
  979. * check mark bitmap. Retrieve the width of the bitmap
  980. * and add it to the width of the menu item.
  981. */
  982. int nIconX = (pmods->fCanCheck ? ::GetSystemMetrics(SM_CXMENUCHECK) : 0)
  983. + lpdis->rcItem.left;
  984. int nTextY = lpdis->rcItem.top;
  985. // BUGBUG: remove hard-coded constants:
  986. int nTextX = nIconX + MENUTEXTOFFSET;
  987. HFONT hfontOld = SelectFont(lpdis->hDC, m_hFontMenu);
  988. // Adjust vertical centering:
  989. SIZE size;
  990. GetTextExtentPoint32( lpdis->hDC,
  991. pmods->pszText,
  992. lstrlen(pmods->pszText),
  993. &size);
  994. if (size.cy < (lpdis->rcItem.bottom - lpdis->rcItem.top))
  995. {
  996. nTextY += ((lpdis->rcItem.bottom - lpdis->rcItem.top) - size.cy) / 2;
  997. }
  998. RECT rctTextOut = lpdis->rcItem;
  999. if (fSelected)
  1000. {
  1001. rctTextOut.left += (nIconX + MENUSELTEXTOFFSET);
  1002. }
  1003. ExtTextOut(lpdis->hDC, nTextX, nTextY, ETO_OPAQUE,
  1004. &rctTextOut, pmods->pszText,
  1005. lstrlen(pmods->pszText), NULL);
  1006. if (pmods->fChecked)
  1007. {
  1008. ASSERT(pmods->fCanCheck);
  1009. HDC hdcMem = ::CreateCompatibleDC(NULL);
  1010. if (NULL != hdcMem)
  1011. {
  1012. HBITMAP hbmpCheck = ::LoadBitmap( NULL,
  1013. MAKEINTRESOURCE(OBM_CHECK));
  1014. if (NULL != hbmpCheck)
  1015. {
  1016. HBITMAP hBmpOld = (HBITMAP) ::SelectObject(hdcMem, hbmpCheck);
  1017. COLORREF crOldText = ::SetTextColor(lpdis->hDC, ::GetSysColor(COLOR_MENUTEXT));
  1018. // ::GetSysColor(fSelected ?
  1019. // COLOR_HIGHLIGHTTEXT :
  1020. // COLOR_MENUTEXT));
  1021. COLORREF crOldBkgnd = ::SetBkColor( lpdis->hDC, ::GetSysColor(COLOR_MENU));
  1022. // ::GetSysColor(fSelected ?
  1023. // COLOR_HIGHLIGHT :
  1024. // COLOR_MENU));
  1025. ::BitBlt( lpdis->hDC,
  1026. lpdis->rcItem.left,
  1027. nTextY,
  1028. ::GetSystemMetrics(SM_CXMENUCHECK),
  1029. ::GetSystemMetrics(SM_CYMENUCHECK),
  1030. hdcMem,
  1031. 0,
  1032. 0,
  1033. SRCCOPY);
  1034. ::SetTextColor(lpdis->hDC, crOldText);
  1035. ::SetBkColor(lpdis->hDC, crOldBkgnd);
  1036. ::SelectObject(hdcMem, hBmpOld);
  1037. ::DeleteObject(hbmpCheck);
  1038. }
  1039. ::DeleteDC(hdcMem);
  1040. }
  1041. }
  1042. HICON hIconMenu = pmods->hIcon;
  1043. if (fSelected)
  1044. {
  1045. if (NULL != pmods->hIconSel)
  1046. {
  1047. hIconMenu = pmods->hIconSel;
  1048. }
  1049. RECT rctIcon = lpdis->rcItem;
  1050. rctIcon.left = nIconX;
  1051. rctIcon.right = nIconX + MENUICONSIZE + (2 * MENUICONSPACE);
  1052. ::DrawEdge( lpdis->hDC,
  1053. &rctIcon,
  1054. BDR_RAISEDINNER,
  1055. BF_RECT | BF_MIDDLE);
  1056. }
  1057. int nIconY = lpdis->rcItem.top;
  1058. if (MENUICONSIZE < (lpdis->rcItem.bottom - lpdis->rcItem.top))
  1059. {
  1060. nIconY += ((lpdis->rcItem.bottom - lpdis->rcItem.top) - MENUICONSIZE) / 2;
  1061. }
  1062. if (NULL != hIconMenu)
  1063. {
  1064. ::DrawIconEx( lpdis->hDC,
  1065. nIconX + MENUICONSPACE,
  1066. nIconY,
  1067. hIconMenu,
  1068. MENUICONSIZE,
  1069. MENUICONSIZE,
  1070. 0,
  1071. NULL,
  1072. DI_NORMAL);
  1073. }
  1074. else
  1075. {
  1076. DrawIconSmall(lpdis->hDC, pmods->iImage,
  1077. nIconX + MENUICONSPACE, nIconY);
  1078. }
  1079. SelectFont(lpdis->hDC, hfontOld);
  1080. /*
  1081. * Return the text and background colors to their
  1082. * normal state (not selected).
  1083. */
  1084. // Restore the colors
  1085. SetTextColor(lpdis->hDC, crText);
  1086. SetBkColor(lpdis->hDC, crBkgnd);
  1087. }
  1088. /****************************************************************************
  1089. *
  1090. * CLASS: CConfRoom
  1091. *
  1092. * MEMBER: ForceWindowResize()
  1093. *
  1094. * PURPOSE: Handles redrawing the window after something changed
  1095. *
  1096. ****************************************************************************/
  1097. VOID CTopWindow::ForceWindowResize()
  1098. {
  1099. HWND hwnd = GetWindow();
  1100. DBGENTRY(CConfRoom::ForceWindowResize);
  1101. if (m_fMinimized || !FUiVisible())
  1102. return; // nothing to resize
  1103. // Turn off redraws:
  1104. ::SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
  1105. // resize:
  1106. ResizeChildWindows();
  1107. // Turn on redraws and then redraw everything:
  1108. ::SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
  1109. ::RedrawWindow( hwnd,
  1110. NULL,
  1111. NULL,
  1112. RDW_ALLCHILDREN | RDW_INVALIDATE |
  1113. RDW_ERASE | RDW_ERASENOW);
  1114. }
  1115. /****************************************************************************
  1116. *
  1117. * CLASS: CConfRoom
  1118. *
  1119. * MEMBER: OnCommand(WPARAM, LPARAM)
  1120. *
  1121. * PURPOSE: Handles command messages
  1122. *
  1123. ****************************************************************************/
  1124. void CTopWindow::OnCommand(HWND hwnd, int wCommand, HWND hwndCtl, UINT codeNotify)
  1125. {
  1126. switch(wCommand)
  1127. {
  1128. case ID_AUTOACCEPT:
  1129. ConfPolicies::SetAutoAcceptCallsEnabled(!ConfPolicies::IsAutoAcceptCallsEnabled());
  1130. break;
  1131. case ID_PRIVATE_UPDATE_UI:
  1132. {
  1133. UpdateUI(codeNotify);
  1134. break;
  1135. }
  1136. case ID_HELP_WEB_FREE:
  1137. case ID_HELP_WEB_FAQ:
  1138. case ID_HELP_WEB_FEEDBACK:
  1139. case ID_HELP_WEB_MSHOME:
  1140. case ID_HELP_WEB_SUPPORT:
  1141. case ID_HELP_WEB_NEWS:
  1142. {
  1143. CmdLaunchWebPage(wCommand);
  1144. break;
  1145. }
  1146. case IDM_FILE_DIRECTORY:
  1147. {
  1148. CFindSomeone::findSomeone(m_pConfRoom);
  1149. }
  1150. break;
  1151. case IDM_FILE_LOGON_ULS:
  1152. {
  1153. if( ConfPolicies::GetCallingMode() == ConfPolicies::CallingMode_GateKeeper )
  1154. { // this means that we are in Gatekeeper mode
  1155. if( IsGatekeeperLoggedOn() || IsGatekeeperLoggingOn() )
  1156. {
  1157. // The text of the menu item should have read "LogOff Gatekeeper"
  1158. // so we are going to take the command and log off
  1159. GkLogoff();
  1160. }
  1161. else
  1162. {
  1163. // The text of the menu item should have read "LogOn Gatekeeper"
  1164. // so we are going to take the command and log on
  1165. GkLogon();
  1166. }
  1167. }
  1168. else
  1169. {
  1170. g_pConfRoom->ToggleLdapLogon();
  1171. }
  1172. break;
  1173. }
  1174. case ID_HELP_HELPTOPICS:
  1175. {
  1176. ShowNmHelp(s_cszHtmlHelpFile);
  1177. break;
  1178. }
  1179. case ID_HELP_ABOUTOPRAH:
  1180. {
  1181. CmdShowAbout(hwnd);
  1182. break;
  1183. }
  1184. case ID_HELP_RELEASE_NOTES:
  1185. {
  1186. CmdShowReleaseNotes();
  1187. break;
  1188. }
  1189. case ID_STOP:
  1190. {
  1191. CancelAllOutgoingCalls();
  1192. break;
  1193. }
  1194. // General Toolbar Commands:
  1195. case ID_FILE_EXIT_ACTIVATERDS:
  1196. {
  1197. RegEntry re(REMOTECONTROL_KEY, HKEY_LOCAL_MACHINE);
  1198. re.SetValue(REMOTE_REG_ACTIVATESERVICE, 1);
  1199. // then fall through IDM_FILE_EXIT
  1200. }
  1201. case IDM_FILE_EXIT:
  1202. {
  1203. // ISSUE: Should this be a PostMessage?
  1204. ::SendMessage(GetWindow(), WM_CLOSE, 0, 0);
  1205. break;
  1206. }
  1207. case ID_FILE_CONF_HOST:
  1208. {
  1209. CmdHostConference(hwnd);
  1210. break;
  1211. }
  1212. case ID_FILE_DO_NOT_DISTURB:
  1213. {
  1214. CmdDoNotDisturb(hwnd);
  1215. UpdateUI(CRUI_STATUSBAR);
  1216. break;
  1217. }
  1218. case IDM_VIEW_STATUSBAR:
  1219. {
  1220. CmdViewStatusBar();
  1221. OnDesiredSizeChanged();
  1222. break;
  1223. }
  1224. case IDM_VIEW_COMPACT:
  1225. if (NULL != m_pMainUI)
  1226. {
  1227. m_fStateChanged = TRUE;
  1228. m_pMainUI->SetCompact(!m_pMainUI->IsCompact());
  1229. }
  1230. break;
  1231. case IDM_VIEW_DATAONLY:
  1232. if (NULL != m_pMainUI)
  1233. {
  1234. m_fStateChanged = TRUE;
  1235. m_pMainUI->SetDataOnly(!m_pMainUI->IsDataOnly());
  1236. }
  1237. break;
  1238. case IDM_VIEW_DIALPAD:
  1239. if (NULL != m_pMainUI)
  1240. {
  1241. m_fStateChanged = TRUE;
  1242. m_pMainUI->SetDialing(!m_pMainUI->IsDialing());
  1243. }
  1244. break;
  1245. case ID_TB_PICINPIC:
  1246. if (NULL != m_pMainUI)
  1247. {
  1248. m_fStateChanged = TRUE;
  1249. m_pMainUI->SetPicInPic(!m_pMainUI->IsPicInPic());
  1250. }
  1251. break;
  1252. case IDM_VIEW_ONTOP:
  1253. m_fStateChanged = TRUE;
  1254. SetOnTop(!IsOnTop());
  1255. break;
  1256. case ID_TOOLS_ENABLEAPPSHARING:
  1257. {
  1258. ::OnEnableAppSharing(GetWindow());
  1259. break;
  1260. }
  1261. case ID_TOOLS_RDSWIZARD:
  1262. {
  1263. RegEntry reCU( CONFERENCING_KEY, HKEY_CURRENT_USER);
  1264. BOOL fAlwaysRunning = (0 != reCU.GetNumber(
  1265. REGVAL_CONF_ALWAYS_RUNNING, ALWAYS_RUNNING_DEFAULT ));
  1266. if (fAlwaysRunning)
  1267. {
  1268. TCHAR szMsg[2*RES_CH_MAX];
  1269. if (IDYES != MessageBox(GetWindow(),
  1270. Res2THelper(IDS_RWSWARNING, szMsg, ARRAY_ELEMENTS(szMsg)), RES2T(IDS_MSGBOX_TITLE),
  1271. MB_YESNO|MB_ICONHAND))
  1272. {
  1273. break;
  1274. }
  1275. reCU.SetValue(REGVAL_CONF_ALWAYS_RUNNING, (int)FALSE);
  1276. RegEntry reRun(WINDOWS_RUN_KEY, HKEY_CURRENT_USER);
  1277. reRun.DeleteValue(REGVAL_RUN_TASKNAME);
  1278. }
  1279. RegEntry reLM( REMOTECONTROL_KEY, HKEY_LOCAL_MACHINE);
  1280. if (-1 != reLM.GetNumber(REMOTE_REG_RUNSERVICE,-1))
  1281. {
  1282. DialogBox(::GetInstanceHandle(), MAKEINTRESOURCE(IDD_RDS_SETTINGS), hwnd, RDSSettingDlgProc);
  1283. }
  1284. else
  1285. {
  1286. IntCreateRDSWizard(hwnd);
  1287. }
  1288. break;
  1289. }
  1290. case ID_TOOLS_OPTIONS:
  1291. {
  1292. ::LaunchConfCpl(hwnd, OPTIONS_DEFAULT_PAGE);
  1293. break;
  1294. }
  1295. case ID_TOOLS_SENDVIDEO:
  1296. {
  1297. CVideoWindow *pVideo = GetLocalVideo();
  1298. if (NULL != pVideo)
  1299. {
  1300. pVideo->Pause(!pVideo->IsPaused());
  1301. }
  1302. break;
  1303. }
  1304. case ID_TOOLS_RECEIVEVIDEO:
  1305. {
  1306. CVideoWindow *pVideo = GetRemoteVideo();
  1307. if (NULL != pVideo)
  1308. {
  1309. pVideo->Pause(!pVideo->IsPaused());
  1310. }
  1311. break;
  1312. }
  1313. case ID_TOOLS_AUDIO_WIZARD:
  1314. {
  1315. CmdAudioCalibWizard(hwnd);
  1316. break;
  1317. }
  1318. case IDM_FILE_HANGUP:
  1319. case ID_TB_FILETRANSFER:
  1320. case ID_TB_NEWWHITEBOARD:
  1321. case ID_TB_WHITEBOARD:
  1322. case ID_TB_CHAT:
  1323. case ID_TB_SHARING:
  1324. case ID_TB_NEW_CALL:
  1325. case IDM_CALL_MEETINGSETTINGS:
  1326. m_pConfRoom->OnCommand(hwnd, wCommand, NULL, 0);
  1327. break;
  1328. case IDM_VIDEO_ZOOM1:
  1329. case IDM_VIDEO_ZOOM2:
  1330. case IDM_VIDEO_ZOOM3:
  1331. case IDM_VIDEO_ZOOM4:
  1332. case IDM_VIDEO_UNDOCK:
  1333. case IDM_VIDEO_GETACAMERA:
  1334. case IDM_POPUP_EJECT:
  1335. case IDM_POPUP_PROPERTIES:
  1336. case IDM_POPUP_SPEEDDIAL:
  1337. case IDM_POPUP_ADDRESSBOOK:
  1338. case IDM_POPUP_GIVECONTROL:
  1339. case IDM_POPUP_CANCELGIVECONTROL:
  1340. case ID_FILE_CREATE_SPEED_DIAL:
  1341. {
  1342. if (NULL != m_pMainUI)
  1343. {
  1344. m_pMainUI->OnCommand(wCommand);
  1345. }
  1346. break;
  1347. }
  1348. default:
  1349. {
  1350. if ((wCommand >= ID_EXTENDED_TOOLS_ITEM) &&
  1351. (wCommand <= ID_EXTENDED_TOOLS_ITEM + MAX_EXTENDED_TOOLS_ITEMS))
  1352. {
  1353. // The user clicked on a extensible tools menu item:
  1354. OnExtToolsItem(wCommand);
  1355. return;
  1356. }
  1357. #ifdef DEBUG
  1358. else if ((wCommand >= IDM_DEBUG_FIRST) &&
  1359. (wCommand < IDM_DEBUG_LAST))
  1360. {
  1361. // The user clicked on a debug menu item:
  1362. ::OnDebugCommand(wCommand);
  1363. return;
  1364. }
  1365. #endif
  1366. else
  1367. {
  1368. // The message was not handled:
  1369. WARNING_OUT(("Command not handled [%08X]", wCommand));
  1370. return;
  1371. }
  1372. }
  1373. }
  1374. }
  1375. /****************************************************************************
  1376. *
  1377. * CLASS: CConfRoom
  1378. *
  1379. * FUNCTION: OnExtToolsItem(UINT uID)
  1380. *
  1381. * PURPOSE: Handles the action after a user selects an item from the
  1382. * extensible Tools menu.
  1383. *
  1384. ****************************************************************************/
  1385. BOOL CTopWindow::OnExtToolsItem(UINT uID)
  1386. {
  1387. HWND hwnd = GetWindow();
  1388. DebugEntry(CConfRoom::OnExtToolsItem);
  1389. BOOL bRet = FALSE;
  1390. HMENU hMenuMain = GetMenu(hwnd);
  1391. if (hMenuMain)
  1392. {
  1393. // Get the tools menu
  1394. HMENU hMenuTools = GetSubMenu(hMenuMain, MENUPOS_TOOLS);
  1395. if (hMenuTools)
  1396. {
  1397. MENUITEMINFO mmi;
  1398. mmi.cbSize = sizeof(mmi);
  1399. mmi.fMask = MIIM_DATA;
  1400. if (GetMenuItemInfo(hMenuTools,
  1401. uID,
  1402. FALSE,
  1403. &mmi))
  1404. {
  1405. TOOLSMENUSTRUCT* ptms = (TOOLSMENUSTRUCT*) mmi.dwItemData;
  1406. ASSERT(NULL != ptms);
  1407. TRACE_OUT(("Selected \"%s\" from Tools", ptms->szDisplayName));
  1408. TRACE_OUT(("\tExeName: \"%s\"", ptms->szExeName));
  1409. if ((HINSTANCE) 32 < ::ShellExecute(hwnd,
  1410. NULL,
  1411. ptms->szExeName,
  1412. NULL,
  1413. NULL,
  1414. SW_SHOWDEFAULT))
  1415. {
  1416. bRet = TRUE;
  1417. }
  1418. }
  1419. }
  1420. }
  1421. DebugExitBOOL(OnExtToolsItem, bRet);
  1422. return bRet;
  1423. }
  1424. /****************************************************************************
  1425. *
  1426. * CLASS: CConfRoom
  1427. *
  1428. * FUNCTION: ResizeChildWindows()
  1429. *
  1430. * PURPOSE: Calculates the correct size of the child windows and resizes
  1431. *
  1432. ****************************************************************************/
  1433. VOID CTopWindow::ResizeChildWindows(void)
  1434. {
  1435. if (m_fMinimized)
  1436. return;
  1437. RECT rcl;
  1438. GetClientRect(GetWindow(), &rcl);
  1439. if (NULL != m_pStatusBar)
  1440. {
  1441. rcl.bottom -= m_pStatusBar->GetHeight();
  1442. }
  1443. if (NULL != m_pSeparator)
  1444. {
  1445. SIZE size;
  1446. m_pSeparator->GetDesiredSize(&size);
  1447. ::SetWindowPos(m_pSeparator->GetWindow(), NULL,
  1448. rcl.left, rcl.top, rcl.right-rcl.left, size.cy,
  1449. SWP_NOACTIVATE | SWP_NOZORDER);
  1450. rcl.top += size.cy;
  1451. }
  1452. if (NULL != m_pMainUI)
  1453. {
  1454. // Fill the window with the main UI
  1455. ::SetWindowPos(m_pMainUI->GetWindow(), NULL,
  1456. rcl.left, rcl.top, rcl.right-rcl.left, rcl.bottom-rcl.top,
  1457. SWP_NOACTIVATE | SWP_NOZORDER);
  1458. }
  1459. }
  1460. /****************************************************************************
  1461. *
  1462. * CLASS: CConfRoom
  1463. *
  1464. * MEMBER: OnMenuSelect(UINT, UINT, HMENU)
  1465. *
  1466. * PURPOSE: Called when passing over a menu item (to display status text)
  1467. *
  1468. ****************************************************************************/
  1469. void CTopWindow::OnMenuSelect(HWND hwnd, HMENU hMenu, int uItem, UINT fuFlags)
  1470. {
  1471. UINT uHelpID;
  1472. TCHAR szHelpText[MAX_PATH];
  1473. if (NULL == m_pStatusBar)
  1474. return;
  1475. if ((0xFFFF == LOWORD(fuFlags)) && (NULL == hMenu))
  1476. {
  1477. m_pStatusBar->RemoveHelpText();
  1478. return;
  1479. }
  1480. if (!(MF_POPUP & fuFlags))
  1481. {
  1482. if (MF_SEPARATOR & fuFlags)
  1483. {
  1484. // show blank text in the status bar
  1485. uHelpID = 0;
  1486. }
  1487. else if (MF_SYSMENU & fuFlags)
  1488. {
  1489. // An item from the system menu (these ID's map to our
  1490. // string ID's directly)
  1491. uHelpID = uItem;
  1492. }
  1493. else if ((uItem >= ID_EXTENDED_TOOLS_ITEM) &&
  1494. (uItem <= ID_EXTENDED_TOOLS_ITEM + MAX_EXTENDED_TOOLS_ITEMS))
  1495. {
  1496. // BUGBUG georgep: No help for the extended tools items
  1497. uHelpID = 0;
  1498. }
  1499. #ifdef DEBUG
  1500. else if ((uItem >= IDM_DEBUG) &&
  1501. (uItem <= IDM_DEBUG_LAST))
  1502. {
  1503. // debug only - don't complain
  1504. uHelpID = 0;
  1505. }
  1506. #endif
  1507. else
  1508. {
  1509. uHelpID = MENU_ID_HELP_OFFSET + uItem;
  1510. }
  1511. }
  1512. else
  1513. {
  1514. // This is a popup menu
  1515. HMENU hMenuMain = ::GetMenu(GetWindow());
  1516. if (hMenu == hMenuMain)
  1517. {
  1518. #ifdef DEBUG
  1519. if (uItem == (MENUPOS_HELP+1))
  1520. {
  1521. // This is a popup from the debug menu
  1522. uHelpID = 0;
  1523. }
  1524. else
  1525. #endif
  1526. {
  1527. // This is a popup from the main window (i.e. Edit, View, etc.)
  1528. uHelpID = MAIN_MENU_POPUP_HELP_OFFSET + uItem;
  1529. }
  1530. }
  1531. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_TOOLS))
  1532. {
  1533. // This is a popup from the tools window (Video)
  1534. uHelpID = TOOLS_MENU_POPUP_HELP_OFFSET + uItem;
  1535. }
  1536. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_HELP))
  1537. {
  1538. // This is a popup from the tools window (i.e. "Microsoft on the Web")
  1539. uHelpID = HELP_MENU_POPUP_HELP_OFFSET + uItem;
  1540. }
  1541. // toolbar menu
  1542. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_VIEW))
  1543. {
  1544. uHelpID = VIEW_MENU_POPUP_HELP_OFFSET + uItem;
  1545. }
  1546. // system menu
  1547. else if (MF_SYSMENU & fuFlags)
  1548. {
  1549. uHelpID = IDS_SYSTEM_HELP;
  1550. }
  1551. else
  1552. {
  1553. // popup-menu that we haven't handled yet:
  1554. // BUGBUG: this shouldn't be needed if we handle all pop-up menus!
  1555. uHelpID = 0;
  1556. WARNING_OUT(("Missing help text for popup menu"));
  1557. }
  1558. }
  1559. if (0 == uHelpID)
  1560. {
  1561. // show blank text in the status bar
  1562. szHelpText[0] = _T('\0');
  1563. }
  1564. else
  1565. {
  1566. int cch = ::LoadString(::GetInstanceHandle(), uHelpID,
  1567. szHelpText, CCHMAX(szHelpText));
  1568. #ifdef DEBUG
  1569. if (0 == cch)
  1570. {
  1571. wsprintf(szHelpText, TEXT("Missing help text for id=%d"), uHelpID);
  1572. WARNING_OUT((szHelpText));
  1573. }
  1574. #endif
  1575. }
  1576. m_pStatusBar->SetHelpText(szHelpText);
  1577. }
  1578. /****************************************************************************
  1579. *
  1580. * CLASS: CConfRoom
  1581. *
  1582. * MEMBER: OnInitMenuPopup(HMENU)
  1583. *
  1584. * PURPOSE: Insures that menus are updated when they are selected
  1585. *
  1586. ****************************************************************************/
  1587. void CTopWindow::OnInitMenuPopup(HWND hwnd, HMENU hMenu, UINT item, BOOL fSystemMenu)
  1588. {
  1589. if (fSystemMenu)
  1590. {
  1591. FORWARD_WM_INITMENUPOPUP(hwnd, hMenu, item, fSystemMenu, CFrame::ProcessMessage);
  1592. return;
  1593. }
  1594. HMENU hMenuMain = ::GetMenu(GetWindow());
  1595. if (hMenuMain)
  1596. {
  1597. // Check to see if we are on a dynamic menu:
  1598. if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_CALL))
  1599. {
  1600. UpdateCallMenu(hMenu);
  1601. }
  1602. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_VIEW))
  1603. {
  1604. UpdateViewMenu(hMenu);
  1605. }
  1606. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_TOOLS))
  1607. {
  1608. UpdateToolsMenu(hMenu);
  1609. }
  1610. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_HELP))
  1611. {
  1612. UpdateHelpMenu(hMenu);
  1613. }
  1614. }
  1615. }
  1616. void CTopWindow::OnInitMenu(HWND hwnd, HMENU hMenu)
  1617. {
  1618. if (NULL != m_pMainUI)
  1619. {
  1620. m_pMainUI->OnInitMenu(hMenu);
  1621. }
  1622. }
  1623. /****************************************************************************
  1624. *
  1625. * CLASS: CConfRoom
  1626. *
  1627. * MEMBER: UpdateCallAnim()
  1628. *
  1629. * PURPOSE: Handles the starting and stopping of the call progress anim
  1630. *
  1631. ****************************************************************************/
  1632. VOID CTopWindow::UpdateCallAnim()
  1633. {
  1634. }
  1635. /****************************************************************************
  1636. *
  1637. * CLASS: CConfRoom
  1638. *
  1639. * MEMBER: UpdateStatusBar()
  1640. *
  1641. * PURPOSE: Updates the status bar object
  1642. *
  1643. ****************************************************************************/
  1644. VOID CTopWindow::UpdateStatusBar()
  1645. {
  1646. if (NULL != m_pStatusBar)
  1647. {
  1648. m_pStatusBar->Update();
  1649. }
  1650. }
  1651. /* C R E A T E C H I L D W I N D O W S */
  1652. /*-------------------------------------------------------------------------
  1653. %%Function: CreateChildWindows
  1654. Creates all of the child windows and views
  1655. -------------------------------------------------------------------------*/
  1656. VOID CTopWindow::CreateChildWindows(void)
  1657. {
  1658. DBGENTRY(CreateChildWindows);
  1659. HRESULT hr = S_OK;
  1660. RegEntry re(UI_KEY, HKEY_CURRENT_USER);
  1661. HWND hwnd = GetWindow();
  1662. ASSERT(NULL != hwnd);
  1663. // get the size and position of the parent window
  1664. RECT rcl;
  1665. ::GetClientRect(hwnd, &rcl);
  1666. // Create the status bar:
  1667. m_pStatusBar = new CConfStatusBar(m_pConfRoom);
  1668. if (NULL != m_pStatusBar)
  1669. {
  1670. if (m_pStatusBar->Create(hwnd))
  1671. {
  1672. if (re.GetNumber(REGVAL_SHOW_STATUSBAR, DEFAULT_SHOW_STATUSBAR))
  1673. {
  1674. m_pStatusBar->Show(TRUE);
  1675. }
  1676. }
  1677. }
  1678. /*** Create the main views ***/
  1679. m_pSeparator = new CSeparator();
  1680. if (NULL != m_pSeparator)
  1681. {
  1682. m_pSeparator->Create(hwnd);
  1683. }
  1684. // Create the toolbar
  1685. m_pMainUI = new CMainUI();
  1686. if (NULL != m_pMainUI)
  1687. {
  1688. if (!m_pMainUI->Create(hwnd, m_pConfRoom))
  1689. {
  1690. ERROR_OUT(("ConfRoom creation of toolbar window failed!"));
  1691. }
  1692. else
  1693. {
  1694. int state = re.GetNumber(REGVAL_MP_WINDOW_STATE, DEFAULT_MP_WINDOW_STATE);
  1695. switch (state & State_Mask)
  1696. {
  1697. case State_Normal:
  1698. break;
  1699. case State_Compact:
  1700. m_pMainUI->SetCompact(TRUE);
  1701. break;
  1702. case State_DataOnly:
  1703. m_pMainUI->SetDataOnly(TRUE);
  1704. break;
  1705. default:
  1706. if (!FIsAVCapable())
  1707. {
  1708. // initialize the toolbar buttons:
  1709. m_pMainUI->SetDataOnly(TRUE);
  1710. }
  1711. break;
  1712. }
  1713. if (0 != (state & SubState_PicInPic))
  1714. {
  1715. m_pMainUI->SetPicInPic(TRUE);
  1716. }
  1717. if (0 != (state & SubState_Dialpad))
  1718. {
  1719. m_pMainUI->SetDialing(TRUE);
  1720. }
  1721. if (0 != (state & SubState_OnTop))
  1722. {
  1723. SetOnTop(TRUE);
  1724. }
  1725. m_pMainUI->UpdateButtons();
  1726. }
  1727. }
  1728. }
  1729. /****************************************************************************
  1730. *
  1731. * CLASS: CConfRoom
  1732. *
  1733. * MEMBER: UpdateCallMenu(HMENU hMenuCall)
  1734. *
  1735. * PURPOSE: Updates the call menu
  1736. *
  1737. ****************************************************************************/
  1738. VOID CTopWindow::UpdateCallMenu(HMENU hMenuCall)
  1739. {
  1740. if (NULL != hMenuCall)
  1741. {
  1742. {
  1743. bool bEnabled = ConfPolicies::IsAutoAcceptCallsOptionEnabled();
  1744. bool bChecked = ConfPolicies::IsAutoAcceptCallsEnabled();
  1745. EnableMenuItem(hMenuCall, ID_AUTOACCEPT, MF_BYCOMMAND | (bEnabled ? MF_ENABLED : MF_GRAYED));
  1746. CheckMenuItem (hMenuCall, ID_AUTOACCEPT, MF_BYCOMMAND | (bChecked ? MF_CHECKED : MF_UNCHECKED));
  1747. }
  1748. TCHAR szMenu[ MAX_PATH * 2 ];
  1749. if( ConfPolicies::GetCallingMode() == ConfPolicies::CallingMode_GateKeeper )
  1750. {
  1751. // This means that we are in gatekeeper mode...
  1752. RegEntry reConf( CONFERENCING_KEY, HKEY_CURRENT_USER );
  1753. FLoadString1( IsGatekeeperLoggedOn()? IDS_LOGOFF_ULS: IDS_LOGON_ULS, szMenu, reConf.GetString( REGVAL_GK_SERVER ) );
  1754. ::ModifyMenu( hMenuCall, IDM_FILE_LOGON_ULS, MF_BYCOMMAND | MF_STRING, IDM_FILE_LOGON_ULS, szMenu );
  1755. }
  1756. else
  1757. {
  1758. const TCHAR * const defaultServer = CDirectoryManager::get_displayName( CDirectoryManager::get_defaultServer() );
  1759. bool bMenuItemShouldSayLogon = ((NULL == g_pLDAP) || !(g_pLDAP->IsLoggedOn() || g_pLDAP ->IsLoggingOn()));
  1760. FLoadString1( bMenuItemShouldSayLogon? IDS_LOGON_ULS: IDS_LOGOFF_ULS, szMenu, (void *) defaultServer );
  1761. ::ModifyMenu( hMenuCall, IDM_FILE_LOGON_ULS, MF_BYCOMMAND | MF_STRING, IDM_FILE_LOGON_ULS, szMenu );
  1762. ::EnableMenuItem( hMenuCall, IDM_FILE_LOGON_ULS, SysPol::AllowDirectoryServices()? MF_ENABLED: MF_GRAYED );
  1763. }
  1764. // Set the state of the hangup item:
  1765. ::EnableMenuItem( hMenuCall,
  1766. IDM_FILE_HANGUP,
  1767. FIsConferenceActive() ? MF_ENABLED : MF_GRAYED);
  1768. // Only enable the host conference item if we're not in a call:
  1769. ::EnableMenuItem( hMenuCall,
  1770. ID_FILE_CONF_HOST,
  1771. (FIsConferenceActive() ||
  1772. FIsCallInProgress()) ? MF_GRAYED : MF_ENABLED);
  1773. //
  1774. // Only enable the meeting settings item if we're in a call and there
  1775. // are settings.
  1776. //
  1777. ::EnableMenuItem(hMenuCall,
  1778. IDM_CALL_MEETINGSETTINGS,
  1779. MF_BYCOMMAND |
  1780. ((FIsConferenceActive() && (m_pConfRoom->GetMeetingSettings() != NM_PERMIT_ALL)) ?
  1781. MF_ENABLED : MF_GRAYED));
  1782. // Only enable the New Call menu item if permitted by settings
  1783. ::EnableMenuItem(hMenuCall,
  1784. ID_TB_NEW_CALL,
  1785. MF_BYCOMMAND|MenuState(m_pConfRoom->IsNewCallAllowed()));
  1786. // Check the "Do Not Disturb" menu item:
  1787. ::CheckMenuItem(hMenuCall,
  1788. ID_FILE_DO_NOT_DISTURB,
  1789. ::FDoNotDisturb() ? MF_CHECKED : MF_UNCHECKED);
  1790. RegEntry reLM(REMOTECONTROL_KEY, HKEY_LOCAL_MACHINE);
  1791. BOOL fActivated = reLM.GetNumber(REMOTE_REG_ACTIVATESERVICE, DEFAULT_REMOTE_ACTIVATESERVICE);
  1792. BOOL fEnabled = reLM.GetNumber(REMOTE_REG_RUNSERVICE,DEFAULT_REMOTE_RUNSERVICE);
  1793. if (fEnabled && !fActivated && !m_fExitAndActivateRDSMenuItem)
  1794. {
  1795. TCHAR szExitAndActivateRDSMenuItem[MAX_PATH];
  1796. MENUITEMINFO mmi;
  1797. int cchExitAndActivateRDSMenuItem = ::LoadString(GetInstanceHandle(),
  1798. ID_FILE_EXIT_ACTIVATERDS,
  1799. szExitAndActivateRDSMenuItem,
  1800. CCHMAX(szExitAndActivateRDSMenuItem));
  1801. if (0 == cchExitAndActivateRDSMenuItem)
  1802. {
  1803. ERROR_OUT(("LoadString(%d) failed", (int) ID_FILE_EXIT_ACTIVATERDS));
  1804. }
  1805. else
  1806. {
  1807. //ZeroMemory((PVOID) &mmi, sizeof(mmi));
  1808. mmi.cbSize = sizeof(mmi);
  1809. mmi.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
  1810. mmi.fState = MFS_ENABLED;
  1811. mmi.wID = ID_FILE_EXIT_ACTIVATERDS;
  1812. mmi.fType = MFT_STRING;
  1813. mmi.dwTypeData = szExitAndActivateRDSMenuItem;
  1814. mmi.cch = cchExitAndActivateRDSMenuItem;
  1815. if (InsertMenuItem(hMenuCall,-1,FALSE,&mmi))
  1816. {
  1817. m_fExitAndActivateRDSMenuItem = TRUE;
  1818. }
  1819. else
  1820. {
  1821. ERROR_OUT(("InsertMenuItem() failed, rc=%lu", (ULONG) GetLastError()));
  1822. }
  1823. }
  1824. }
  1825. else if (m_fExitAndActivateRDSMenuItem && (fActivated || !fEnabled))
  1826. {
  1827. if (DeleteMenu(hMenuCall,ID_FILE_EXIT_ACTIVATERDS,MF_BYCOMMAND))
  1828. {
  1829. m_fExitAndActivateRDSMenuItem = FALSE;
  1830. }
  1831. else
  1832. {
  1833. ERROR_OUT(("DeleteMenu() failed, rc=%lu", (ULONG) GetLastError()));
  1834. }
  1835. }
  1836. }
  1837. }
  1838. /****************************************************************************
  1839. *
  1840. * CLASS: CConfRoom
  1841. *
  1842. * MEMBER: UpdateHelpMenu(HMENU hMenuHelp)
  1843. *
  1844. * PURPOSE: Updates the help menu
  1845. *
  1846. ****************************************************************************/
  1847. VOID CTopWindow::UpdateHelpMenu(HMENU hMenuHelp)
  1848. {
  1849. if (NULL != hMenuHelp)
  1850. {
  1851. // Enable/disable web items
  1852. UINT uEnable = ::CanShellExecHttp() ? MF_ENABLED : MF_GRAYED;
  1853. ::EnableMenuItem(hMenuHelp, IDM_FILE_LAUNCH_WEB_PAGE, uEnable);
  1854. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_FREE, uEnable);
  1855. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_NEWS, uEnable);
  1856. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_FAQ, uEnable);
  1857. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_FEEDBACK, uEnable);
  1858. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_MSHOME, uEnable);
  1859. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_SUPPORT, uEnable);
  1860. }
  1861. }
  1862. /****************************************************************************
  1863. *
  1864. * CLASS: CConfRoom
  1865. *
  1866. * MEMBER: UpdateViewMenu(HMENU hMenuView)
  1867. *
  1868. * PURPOSE: Updates the view menu by placing a bullet next to the
  1869. * current view and a check mark next to the toolbar and
  1870. * status bar items
  1871. *
  1872. ****************************************************************************/
  1873. VOID CTopWindow::UpdateViewMenu(HMENU hMenuView)
  1874. {
  1875. if (NULL == hMenuView)
  1876. return;
  1877. CheckMenu_ViewStatusBar(hMenuView);
  1878. CMainUI *pMainUI = GetMainUI();
  1879. BOOL bChecked;
  1880. BOOL bEnable;
  1881. bChecked = (NULL != pMainUI && pMainUI->IsCompact());
  1882. CheckMenuItem(hMenuView, IDM_VIEW_COMPACT,
  1883. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1884. bEnable = FIsAVCapable();
  1885. EnableMenuItem(hMenuView, IDM_VIEW_COMPACT,
  1886. MF_BYCOMMAND|(bEnable ? MF_ENABLED : MF_GRAYED|MF_DISABLED));
  1887. bChecked = (NULL != pMainUI && pMainUI->IsDataOnly());
  1888. CheckMenuItem(hMenuView, IDM_VIEW_DATAONLY,
  1889. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1890. bEnable = FIsAVCapable();
  1891. EnableMenuItem(hMenuView, IDM_VIEW_DATAONLY,
  1892. MF_BYCOMMAND|(bEnable ? MF_ENABLED : MF_GRAYED|MF_DISABLED));
  1893. bChecked = (NULL != pMainUI && pMainUI->IsDialing());
  1894. CheckMenuItem(hMenuView, IDM_VIEW_DIALPAD,
  1895. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1896. bEnable = (NULL != pMainUI && pMainUI->IsDialingAllowed());
  1897. bEnable = bEnable && FIsAVCapable();
  1898. EnableMenuItem(hMenuView, IDM_VIEW_DIALPAD,
  1899. MF_BYCOMMAND|(bEnable ? MF_ENABLED : MF_GRAYED|MF_DISABLED));
  1900. bChecked = (NULL != pMainUI && pMainUI->IsPicInPic());
  1901. CheckMenuItem(hMenuView, ID_TB_PICINPIC,
  1902. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1903. bEnable = (NULL != pMainUI && pMainUI->IsPicInPicAllowed());
  1904. EnableMenuItem(hMenuView, ID_TB_PICINPIC,
  1905. MF_BYCOMMAND|(bEnable ? MF_ENABLED : MF_GRAYED|MF_DISABLED));
  1906. bChecked = IsOnTop();
  1907. CheckMenuItem(hMenuView, IDM_VIEW_ONTOP,
  1908. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1909. }
  1910. /****************************************************************************
  1911. *
  1912. * CLASS: CConfRoom
  1913. *
  1914. * MEMBER: UpdateToolsMenu(HMENU hMenuTools)
  1915. *
  1916. * PURPOSE: Updates the tools menu
  1917. *
  1918. ****************************************************************************/
  1919. VOID CTopWindow::UpdateToolsMenu(HMENU hMenuTools)
  1920. {
  1921. if (NULL != hMenuTools)
  1922. {
  1923. bool fRDSDisabled = ConfPolicies::IsRDSDisabled();
  1924. EnableMenuItem(hMenuTools, ID_TOOLS_AUDIO_WIZARD,
  1925. FEnableAudioWizard() ? MF_ENABLED : MF_GRAYED);
  1926. EnableMenuItem(hMenuTools, ID_TB_SHARING,
  1927. MF_BYCOMMAND|MenuState(m_pConfRoom->IsSharingAllowed()));
  1928. //
  1929. // No app sharing, no RDS.
  1930. //
  1931. if (!m_pConfRoom->FIsSharingAvailable())
  1932. {
  1933. fRDSDisabled = TRUE;
  1934. }
  1935. // If this is NT, we need to handle adding or removing the menu item
  1936. // to enable the display driver for application sharing. We add the
  1937. // menu item (immediately above the "Options" item) if the display
  1938. // driver is not enabled and the item hasn't been added already. We
  1939. // remove the menu item if it's there and the display driver is
  1940. // enabled, which should only happen if the user enabled it and then
  1941. // choose to ignore the reboot prompt.
  1942. if (::IsWindowsNT())
  1943. {
  1944. if (!g_fNTDisplayDriverEnabled && !m_fEnableAppSharingMenuItem)
  1945. {
  1946. // Add the menu item
  1947. TCHAR szEnableAppSharingMenuItem[MAX_PATH];
  1948. MENUITEMINFO mmi;
  1949. int cchEnableAppSharingMenuItem =
  1950. ::LoadString(
  1951. GetInstanceHandle(),
  1952. ID_TOOLS_ENABLEAPPSHARING,
  1953. szEnableAppSharingMenuItem,
  1954. CCHMAX(szEnableAppSharingMenuItem));
  1955. if (0 == cchEnableAppSharingMenuItem)
  1956. {
  1957. ERROR_OUT(("LoadString(%d) failed", (int) ID_TOOLS_ENABLEAPPSHARING));
  1958. }
  1959. else
  1960. {
  1961. //ZeroMemory((PVOID) &mmi, sizeof(mmi));
  1962. mmi.cbSize = sizeof(mmi);
  1963. mmi.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
  1964. mmi.fState = MFS_ENABLED;
  1965. mmi.wID = ID_TOOLS_ENABLEAPPSHARING;
  1966. mmi.fType = MFT_STRING;
  1967. mmi.dwTypeData = szEnableAppSharingMenuItem;
  1968. mmi.cch = cchEnableAppSharingMenuItem;
  1969. if (InsertMenuItem(
  1970. hMenuTools,
  1971. ID_TOOLS_OPTIONS,
  1972. FALSE,
  1973. &mmi))
  1974. {
  1975. m_fEnableAppSharingMenuItem = TRUE;
  1976. }
  1977. else
  1978. {
  1979. ERROR_OUT(("InsertMenuItem() failed, rc=%lu", (ULONG) GetLastError()));
  1980. }
  1981. }
  1982. }
  1983. else if (m_fEnableAppSharingMenuItem && g_fNTDisplayDriverEnabled)
  1984. {
  1985. // Remove the menu item
  1986. if (DeleteMenu(
  1987. hMenuTools,
  1988. ID_TOOLS_ENABLEAPPSHARING,
  1989. MF_BYCOMMAND))
  1990. {
  1991. m_fEnableAppSharingMenuItem = FALSE;
  1992. }
  1993. else
  1994. {
  1995. ERROR_OUT(("DeleteMenu() failed, rc=%lu", (ULONG) GetLastError()));
  1996. }
  1997. }
  1998. if (m_fEnableAppSharingMenuItem)
  1999. fRDSDisabled = TRUE;
  2000. }
  2001. else
  2002. {
  2003. // Windows 9.x;
  2004. if (ConfPolicies::IsRDSDisabledOnWin9x())
  2005. {
  2006. fRDSDisabled = TRUE;
  2007. }
  2008. }
  2009. EnableMenuItem(hMenuTools, ID_TOOLS_RDSWIZARD, MF_BYCOMMAND |
  2010. (fRDSDisabled ? MF_GRAYED : MF_ENABLED));
  2011. //
  2012. // LAURABU BOGUS:
  2013. // Make installable tools a popup from Tools submenu, don't put these
  2014. // flat!
  2015. //
  2016. CleanTools(hMenuTools, m_ExtToolsList);
  2017. if (m_pConfRoom->GetMeetingPermissions() & NM_PERMIT_STARTOTHERTOOLS)
  2018. {
  2019. FillInTools(hMenuTools, 0, TOOLS_MENU_KEY, m_ExtToolsList);
  2020. }
  2021. BOOL fEnableSend = FALSE;
  2022. BOOL fSending = FALSE;
  2023. CVideoWindow *pLocal = GetLocalVideo();
  2024. if (NULL != pLocal)
  2025. {
  2026. fEnableSend = pLocal->IsXferAllowed() &&
  2027. ((m_pConfRoom->GetMeetingPermissions() & NM_PERMIT_SENDVIDEO) != 0);
  2028. fSending = fEnableSend &&
  2029. !pLocal->IsPaused();
  2030. }
  2031. BOOL fEnableReceive = FALSE;
  2032. BOOL fReceiving = FALSE;
  2033. CVideoWindow *pRemote = GetRemoteVideo();
  2034. if (NULL != pRemote)
  2035. {
  2036. fEnableReceive = pRemote->IsConnected();
  2037. fReceiving = fEnableReceive &&
  2038. !pRemote->IsPaused();
  2039. }
  2040. EnableMenuItem( hMenuTools,
  2041. MENUPOS_TOOLS_VIDEO,
  2042. (MF_BYPOSITION |
  2043. ((fEnableSend || fEnableReceive) ? MF_ENABLED : MF_GRAYED)));
  2044. EnableMenuItem( hMenuTools,
  2045. ID_TOOLS_SENDVIDEO,
  2046. fEnableSend ? MF_ENABLED : MF_GRAYED);
  2047. CheckMenuItem( hMenuTools,
  2048. ID_TOOLS_SENDVIDEO,
  2049. fSending ? MF_CHECKED : MF_UNCHECKED);
  2050. EnableMenuItem( hMenuTools,
  2051. ID_TOOLS_RECEIVEVIDEO,
  2052. fEnableReceive ? MF_ENABLED : MF_GRAYED);
  2053. CheckMenuItem( hMenuTools,
  2054. ID_TOOLS_RECEIVEVIDEO,
  2055. fReceiving ? MF_CHECKED : MF_UNCHECKED);
  2056. EnableMenuItem(hMenuTools, ID_TOOLS_OPTIONS,
  2057. MF_BYCOMMAND|MenuState(CanLaunchConfCpl()));
  2058. //
  2059. // OTHER TOOLS
  2060. //
  2061. EnableMenuItem(hMenuTools, ID_TB_NEWWHITEBOARD,
  2062. MF_BYCOMMAND|MenuState(m_pConfRoom->IsNewWhiteboardAllowed()));
  2063. EnableMenuItem(hMenuTools, ID_TB_WHITEBOARD,
  2064. MF_BYCOMMAND|MenuState(m_pConfRoom->IsOldWhiteboardAllowed()));
  2065. EnableMenuItem(hMenuTools, ID_TB_CHAT,
  2066. MF_BYCOMMAND|MenuState(m_pConfRoom->IsChatAllowed()));
  2067. EnableMenuItem(hMenuTools, ID_TB_FILETRANSFER,
  2068. MF_BYCOMMAND|MenuState(m_pConfRoom->IsFileTransferAllowed()));
  2069. }
  2070. }
  2071. /****************************************************************************
  2072. *
  2073. * CLASS: CConfRoom
  2074. *
  2075. * MEMBER: SelAndRealizePalette()
  2076. *
  2077. * PURPOSE: Selects and realizes the NetMeeting palette
  2078. *
  2079. ****************************************************************************/
  2080. BOOL CTopWindow::SelAndRealizePalette()
  2081. {
  2082. BOOL bRet = FALSE;
  2083. HPALETTE hPal = m_pConfRoom->GetPalette();
  2084. if (NULL == hPal)
  2085. {
  2086. return(bRet);
  2087. }
  2088. HWND hwnd = GetWindow();
  2089. HDC hdc = ::GetDC(hwnd);
  2090. if (NULL != hdc)
  2091. {
  2092. ::SelectPalette(hdc, hPal, FALSE);
  2093. bRet = (GDI_ERROR != ::RealizePalette(hdc));
  2094. ::ReleaseDC(hwnd, hdc);
  2095. }
  2096. return bRet;
  2097. }
  2098. /****************************************************************************
  2099. *
  2100. * CLASS: CConfRoom
  2101. *
  2102. * MEMBER: InitMenuFont()
  2103. *
  2104. * PURPOSE: Initializes/Updates the menu font member
  2105. *
  2106. ****************************************************************************/
  2107. VOID CTopWindow::InitMenuFont()
  2108. {
  2109. DebugEntry(CConfRoom::InitMenuFont);
  2110. if (NULL != m_hFontMenu)
  2111. {
  2112. ::DeleteObject(m_hFontMenu);
  2113. }
  2114. NONCLIENTMETRICS ncm;
  2115. ncm.cbSize = sizeof(ncm);
  2116. if (::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, FALSE))
  2117. {
  2118. m_hFontMenu = ::CreateFontIndirect(&(ncm.lfMenuFont));
  2119. ASSERT(m_hFontMenu);
  2120. }
  2121. DebugExitVOID(CConfRoom::InitMenuFont);
  2122. }
  2123. CVideoWindow* CTopWindow::GetLocalVideo()
  2124. {
  2125. CMainUI *pMainUI = GetMainUI();
  2126. return (pMainUI ? pMainUI->GetLocalVideo() : NULL);
  2127. }
  2128. CVideoWindow* CTopWindow::GetRemoteVideo()
  2129. {
  2130. CMainUI *pMainUI = GetMainUI();
  2131. return (pMainUI ? pMainUI->GetRemoteVideo() : NULL);
  2132. }
  2133. BOOL CTopWindow::IsOnTop()
  2134. {
  2135. return((GetWindowLong(GetWindow(), GWL_EXSTYLE)&WS_EX_TOPMOST) == WS_EX_TOPMOST);
  2136. }
  2137. void CTopWindow::SetOnTop(BOOL bOnTop)
  2138. {
  2139. bOnTop = (bOnTop != FALSE);
  2140. if (IsOnTop() == bOnTop)
  2141. {
  2142. // Nothing to do
  2143. return;
  2144. }
  2145. SetWindowPos(GetWindow(), bOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
  2146. 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
  2147. }
  2148. HPALETTE CTopWindow::GetPalette()
  2149. {
  2150. return(m_pConfRoom->GetPalette());
  2151. }