Leaked source code of windows server 2003
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.

2526 lines
62 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. USES_RES2T
  1270. if (IDYES != MessageBox(GetWindow(),
  1271. Res2THelper(IDS_RWSWARNING, szMsg, ARRAY_ELEMENTS(szMsg)), RES2T(IDS_MSGBOX_TITLE),
  1272. MB_YESNO|MB_ICONHAND))
  1273. {
  1274. break;
  1275. }
  1276. reCU.SetValue(REGVAL_CONF_ALWAYS_RUNNING, (unsigned long)FALSE);
  1277. RegEntry reRun(WINDOWS_RUN_KEY, HKEY_CURRENT_USER);
  1278. reRun.DeleteValue(REGVAL_RUN_TASKNAME);
  1279. }
  1280. RegEntry reLM( REMOTECONTROL_KEY, HKEY_LOCAL_MACHINE);
  1281. if (-1 != reLM.GetNumber(REMOTE_REG_RUNSERVICE,-1))
  1282. {
  1283. DialogBox(::GetInstanceHandle(), MAKEINTRESOURCE(IDD_RDS_SETTINGS), hwnd, RDSSettingDlgProc);
  1284. }
  1285. else
  1286. {
  1287. IntCreateRDSWizard(hwnd);
  1288. }
  1289. break;
  1290. }
  1291. case ID_TOOLS_OPTIONS:
  1292. {
  1293. ::LaunchConfCpl(hwnd, OPTIONS_DEFAULT_PAGE);
  1294. break;
  1295. }
  1296. case ID_TOOLS_SENDVIDEO:
  1297. {
  1298. CVideoWindow *pVideo = GetLocalVideo();
  1299. if (NULL != pVideo)
  1300. {
  1301. pVideo->Pause(!pVideo->IsPaused());
  1302. }
  1303. break;
  1304. }
  1305. case ID_TOOLS_RECEIVEVIDEO:
  1306. {
  1307. CVideoWindow *pVideo = GetRemoteVideo();
  1308. if (NULL != pVideo)
  1309. {
  1310. pVideo->Pause(!pVideo->IsPaused());
  1311. }
  1312. break;
  1313. }
  1314. case ID_TOOLS_AUDIO_WIZARD:
  1315. {
  1316. CmdAudioCalibWizard(hwnd);
  1317. break;
  1318. }
  1319. case IDM_FILE_HANGUP:
  1320. case ID_TB_FILETRANSFER:
  1321. case ID_TB_NEWWHITEBOARD:
  1322. case ID_TB_WHITEBOARD:
  1323. case ID_TB_CHAT:
  1324. case ID_TB_SHARING:
  1325. case ID_TB_NEW_CALL:
  1326. case IDM_CALL_MEETINGSETTINGS:
  1327. m_pConfRoom->OnCommand(hwnd, wCommand, NULL, 0);
  1328. break;
  1329. case IDM_VIDEO_ZOOM1:
  1330. case IDM_VIDEO_ZOOM2:
  1331. case IDM_VIDEO_ZOOM3:
  1332. case IDM_VIDEO_ZOOM4:
  1333. case IDM_VIDEO_UNDOCK:
  1334. case IDM_VIDEO_GETACAMERA:
  1335. case IDM_POPUP_EJECT:
  1336. case IDM_POPUP_PROPERTIES:
  1337. case IDM_POPUP_SPEEDDIAL:
  1338. case IDM_POPUP_ADDRESSBOOK:
  1339. case IDM_POPUP_GIVECONTROL:
  1340. case IDM_POPUP_CANCELGIVECONTROL:
  1341. case ID_FILE_CREATE_SPEED_DIAL:
  1342. {
  1343. if (NULL != m_pMainUI)
  1344. {
  1345. m_pMainUI->OnCommand(wCommand);
  1346. }
  1347. break;
  1348. }
  1349. default:
  1350. {
  1351. if ((wCommand >= ID_EXTENDED_TOOLS_ITEM) &&
  1352. (wCommand <= ID_EXTENDED_TOOLS_ITEM + MAX_EXTENDED_TOOLS_ITEMS))
  1353. {
  1354. // The user clicked on a extensible tools menu item:
  1355. OnExtToolsItem(wCommand);
  1356. return;
  1357. }
  1358. #ifdef DEBUG
  1359. else if ((wCommand >= IDM_DEBUG_FIRST) &&
  1360. (wCommand < IDM_DEBUG_LAST))
  1361. {
  1362. // The user clicked on a debug menu item:
  1363. ::OnDebugCommand(wCommand);
  1364. return;
  1365. }
  1366. #endif
  1367. else
  1368. {
  1369. // The message was not handled:
  1370. WARNING_OUT(("Command not handled [%08X]", wCommand));
  1371. return;
  1372. }
  1373. }
  1374. }
  1375. }
  1376. /****************************************************************************
  1377. *
  1378. * CLASS: CConfRoom
  1379. *
  1380. * FUNCTION: OnExtToolsItem(UINT uID)
  1381. *
  1382. * PURPOSE: Handles the action after a user selects an item from the
  1383. * extensible Tools menu.
  1384. *
  1385. ****************************************************************************/
  1386. BOOL CTopWindow::OnExtToolsItem(UINT uID)
  1387. {
  1388. HWND hwnd = GetWindow();
  1389. DebugEntry(CConfRoom::OnExtToolsItem);
  1390. BOOL bRet = FALSE;
  1391. HMENU hMenuMain = GetMenu(hwnd);
  1392. if (hMenuMain)
  1393. {
  1394. // Get the tools menu
  1395. HMENU hMenuTools = GetSubMenu(hMenuMain, MENUPOS_TOOLS);
  1396. if (hMenuTools)
  1397. {
  1398. MENUITEMINFO mmi;
  1399. mmi.cbSize = sizeof(mmi);
  1400. mmi.fMask = MIIM_DATA;
  1401. if (GetMenuItemInfo(hMenuTools,
  1402. uID,
  1403. FALSE,
  1404. &mmi))
  1405. {
  1406. TOOLSMENUSTRUCT* ptms = (TOOLSMENUSTRUCT*) mmi.dwItemData;
  1407. ASSERT(NULL != ptms);
  1408. TRACE_OUT(("Selected \"%s\" from Tools", ptms->szDisplayName));
  1409. TRACE_OUT(("\tExeName: \"%s\"", ptms->szExeName));
  1410. if ((HINSTANCE) 32 < ::ShellExecute(hwnd,
  1411. NULL,
  1412. ptms->szExeName,
  1413. NULL,
  1414. NULL,
  1415. SW_SHOWDEFAULT))
  1416. {
  1417. bRet = TRUE;
  1418. }
  1419. }
  1420. }
  1421. }
  1422. DebugExitBOOL(OnExtToolsItem, bRet);
  1423. return bRet;
  1424. }
  1425. /****************************************************************************
  1426. *
  1427. * CLASS: CConfRoom
  1428. *
  1429. * FUNCTION: ResizeChildWindows()
  1430. *
  1431. * PURPOSE: Calculates the correct size of the child windows and resizes
  1432. *
  1433. ****************************************************************************/
  1434. VOID CTopWindow::ResizeChildWindows(void)
  1435. {
  1436. if (m_fMinimized)
  1437. return;
  1438. RECT rcl;
  1439. GetClientRect(GetWindow(), &rcl);
  1440. if (NULL != m_pStatusBar)
  1441. {
  1442. rcl.bottom -= m_pStatusBar->GetHeight();
  1443. }
  1444. if (NULL != m_pSeparator)
  1445. {
  1446. SIZE size;
  1447. m_pSeparator->GetDesiredSize(&size);
  1448. ::SetWindowPos(m_pSeparator->GetWindow(), NULL,
  1449. rcl.left, rcl.top, rcl.right-rcl.left, size.cy,
  1450. SWP_NOACTIVATE | SWP_NOZORDER);
  1451. rcl.top += size.cy;
  1452. }
  1453. if (NULL != m_pMainUI)
  1454. {
  1455. // Fill the window with the main UI
  1456. ::SetWindowPos(m_pMainUI->GetWindow(), NULL,
  1457. rcl.left, rcl.top, rcl.right-rcl.left, rcl.bottom-rcl.top,
  1458. SWP_NOACTIVATE | SWP_NOZORDER);
  1459. }
  1460. }
  1461. /****************************************************************************
  1462. *
  1463. * CLASS: CConfRoom
  1464. *
  1465. * MEMBER: OnMenuSelect(UINT, UINT, HMENU)
  1466. *
  1467. * PURPOSE: Called when passing over a menu item (to display status text)
  1468. *
  1469. ****************************************************************************/
  1470. void CTopWindow::OnMenuSelect(HWND hwnd, HMENU hMenu, int uItem, UINT fuFlags)
  1471. {
  1472. UINT uHelpID;
  1473. TCHAR szHelpText[MAX_PATH];
  1474. if (NULL == m_pStatusBar)
  1475. return;
  1476. if ((0xFFFF == LOWORD(fuFlags)) && (NULL == hMenu))
  1477. {
  1478. m_pStatusBar->RemoveHelpText();
  1479. return;
  1480. }
  1481. if (!(MF_POPUP & fuFlags))
  1482. {
  1483. if (MF_SEPARATOR & fuFlags)
  1484. {
  1485. // show blank text in the status bar
  1486. uHelpID = 0;
  1487. }
  1488. else if (MF_SYSMENU & fuFlags)
  1489. {
  1490. // An item from the system menu (these ID's map to our
  1491. // string ID's directly)
  1492. uHelpID = uItem;
  1493. }
  1494. else if ((uItem >= ID_EXTENDED_TOOLS_ITEM) &&
  1495. (uItem <= ID_EXTENDED_TOOLS_ITEM + MAX_EXTENDED_TOOLS_ITEMS))
  1496. {
  1497. // BUGBUG georgep: No help for the extended tools items
  1498. uHelpID = 0;
  1499. }
  1500. #ifdef DEBUG
  1501. else if ((uItem >= IDM_DEBUG) &&
  1502. (uItem <= IDM_DEBUG_LAST))
  1503. {
  1504. // debug only - don't complain
  1505. uHelpID = 0;
  1506. }
  1507. #endif
  1508. else
  1509. {
  1510. uHelpID = MENU_ID_HELP_OFFSET + uItem;
  1511. }
  1512. }
  1513. else
  1514. {
  1515. // This is a popup menu
  1516. HMENU hMenuMain = ::GetMenu(GetWindow());
  1517. if (hMenu == hMenuMain)
  1518. {
  1519. #ifdef DEBUG
  1520. if (uItem == (MENUPOS_HELP+1))
  1521. {
  1522. // This is a popup from the debug menu
  1523. uHelpID = 0;
  1524. }
  1525. else
  1526. #endif
  1527. {
  1528. // This is a popup from the main window (i.e. Edit, View, etc.)
  1529. uHelpID = MAIN_MENU_POPUP_HELP_OFFSET + uItem;
  1530. }
  1531. }
  1532. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_TOOLS))
  1533. {
  1534. // This is a popup from the tools window (Video)
  1535. uHelpID = TOOLS_MENU_POPUP_HELP_OFFSET + uItem;
  1536. }
  1537. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_HELP))
  1538. {
  1539. // This is a popup from the tools window (i.e. "Microsoft on the Web")
  1540. uHelpID = HELP_MENU_POPUP_HELP_OFFSET + uItem;
  1541. }
  1542. // toolbar menu
  1543. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_VIEW))
  1544. {
  1545. uHelpID = VIEW_MENU_POPUP_HELP_OFFSET + uItem;
  1546. }
  1547. // system menu
  1548. else if (MF_SYSMENU & fuFlags)
  1549. {
  1550. uHelpID = IDS_SYSTEM_HELP;
  1551. }
  1552. else
  1553. {
  1554. // popup-menu that we haven't handled yet:
  1555. // BUGBUG: this shouldn't be needed if we handle all pop-up menus!
  1556. uHelpID = 0;
  1557. WARNING_OUT(("Missing help text for popup menu"));
  1558. }
  1559. }
  1560. if (0 == uHelpID)
  1561. {
  1562. // show blank text in the status bar
  1563. szHelpText[0] = _T('\0');
  1564. }
  1565. else
  1566. {
  1567. int cch = ::LoadString(::GetInstanceHandle(), uHelpID,
  1568. szHelpText, CCHMAX(szHelpText));
  1569. #ifdef DEBUG
  1570. if (0 == cch)
  1571. {
  1572. wsprintf(szHelpText, TEXT("Missing help text for id=%d"), uHelpID);
  1573. WARNING_OUT((szHelpText));
  1574. }
  1575. #endif
  1576. }
  1577. m_pStatusBar->SetHelpText(szHelpText);
  1578. }
  1579. /****************************************************************************
  1580. *
  1581. * CLASS: CConfRoom
  1582. *
  1583. * MEMBER: OnInitMenuPopup(HMENU)
  1584. *
  1585. * PURPOSE: Insures that menus are updated when they are selected
  1586. *
  1587. ****************************************************************************/
  1588. void CTopWindow::OnInitMenuPopup(HWND hwnd, HMENU hMenu, UINT item, BOOL fSystemMenu)
  1589. {
  1590. if (fSystemMenu)
  1591. {
  1592. FORWARD_WM_INITMENUPOPUP(hwnd, hMenu, item, fSystemMenu, CFrame::ProcessMessage);
  1593. return;
  1594. }
  1595. HMENU hMenuMain = ::GetMenu(GetWindow());
  1596. if (hMenuMain)
  1597. {
  1598. // Check to see if we are on a dynamic menu:
  1599. if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_CALL))
  1600. {
  1601. UpdateCallMenu(hMenu);
  1602. }
  1603. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_VIEW))
  1604. {
  1605. UpdateViewMenu(hMenu);
  1606. }
  1607. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_TOOLS))
  1608. {
  1609. UpdateToolsMenu(hMenu);
  1610. }
  1611. else if (hMenu == ::GetSubMenu(hMenuMain, MENUPOS_HELP))
  1612. {
  1613. UpdateHelpMenu(hMenu);
  1614. }
  1615. }
  1616. }
  1617. void CTopWindow::OnInitMenu(HWND hwnd, HMENU hMenu)
  1618. {
  1619. if (NULL != m_pMainUI)
  1620. {
  1621. m_pMainUI->OnInitMenu(hMenu);
  1622. }
  1623. }
  1624. /****************************************************************************
  1625. *
  1626. * CLASS: CConfRoom
  1627. *
  1628. * MEMBER: UpdateCallAnim()
  1629. *
  1630. * PURPOSE: Handles the starting and stopping of the call progress anim
  1631. *
  1632. ****************************************************************************/
  1633. VOID CTopWindow::UpdateCallAnim()
  1634. {
  1635. }
  1636. /****************************************************************************
  1637. *
  1638. * CLASS: CConfRoom
  1639. *
  1640. * MEMBER: UpdateStatusBar()
  1641. *
  1642. * PURPOSE: Updates the status bar object
  1643. *
  1644. ****************************************************************************/
  1645. VOID CTopWindow::UpdateStatusBar()
  1646. {
  1647. if (NULL != m_pStatusBar)
  1648. {
  1649. m_pStatusBar->Update();
  1650. }
  1651. }
  1652. /* C R E A T E C H I L D W I N D O W S */
  1653. /*-------------------------------------------------------------------------
  1654. %%Function: CreateChildWindows
  1655. Creates all of the child windows and views
  1656. -------------------------------------------------------------------------*/
  1657. VOID CTopWindow::CreateChildWindows(void)
  1658. {
  1659. DBGENTRY(CreateChildWindows);
  1660. HRESULT hr = S_OK;
  1661. RegEntry re(UI_KEY, HKEY_CURRENT_USER);
  1662. HWND hwnd = GetWindow();
  1663. ASSERT(NULL != hwnd);
  1664. // get the size and position of the parent window
  1665. RECT rcl;
  1666. ::GetClientRect(hwnd, &rcl);
  1667. // Create the status bar:
  1668. m_pStatusBar = new CConfStatusBar(m_pConfRoom);
  1669. if (NULL != m_pStatusBar)
  1670. {
  1671. if (m_pStatusBar->Create(hwnd))
  1672. {
  1673. if (re.GetNumber(REGVAL_SHOW_STATUSBAR, DEFAULT_SHOW_STATUSBAR))
  1674. {
  1675. m_pStatusBar->Show(TRUE);
  1676. }
  1677. }
  1678. }
  1679. /*** Create the main views ***/
  1680. m_pSeparator = new CSeparator();
  1681. if (NULL != m_pSeparator)
  1682. {
  1683. m_pSeparator->Create(hwnd);
  1684. }
  1685. // Create the toolbar
  1686. m_pMainUI = new CMainUI();
  1687. if (NULL != m_pMainUI)
  1688. {
  1689. if (!m_pMainUI->Create(hwnd, m_pConfRoom))
  1690. {
  1691. ERROR_OUT(("ConfRoom creation of toolbar window failed!"));
  1692. }
  1693. else
  1694. {
  1695. int state = re.GetNumber(REGVAL_MP_WINDOW_STATE, DEFAULT_MP_WINDOW_STATE);
  1696. switch (state & State_Mask)
  1697. {
  1698. case State_Normal:
  1699. break;
  1700. case State_Compact:
  1701. m_pMainUI->SetCompact(TRUE);
  1702. break;
  1703. case State_DataOnly:
  1704. m_pMainUI->SetDataOnly(TRUE);
  1705. break;
  1706. default:
  1707. if (!FIsAVCapable())
  1708. {
  1709. // initialize the toolbar buttons:
  1710. m_pMainUI->SetDataOnly(TRUE);
  1711. }
  1712. break;
  1713. }
  1714. if (0 != (state & SubState_PicInPic))
  1715. {
  1716. m_pMainUI->SetPicInPic(TRUE);
  1717. }
  1718. if (0 != (state & SubState_Dialpad))
  1719. {
  1720. m_pMainUI->SetDialing(TRUE);
  1721. }
  1722. if (0 != (state & SubState_OnTop))
  1723. {
  1724. SetOnTop(TRUE);
  1725. }
  1726. m_pMainUI->UpdateButtons();
  1727. }
  1728. }
  1729. }
  1730. /****************************************************************************
  1731. *
  1732. * CLASS: CConfRoom
  1733. *
  1734. * MEMBER: UpdateCallMenu(HMENU hMenuCall)
  1735. *
  1736. * PURPOSE: Updates the call menu
  1737. *
  1738. ****************************************************************************/
  1739. VOID CTopWindow::UpdateCallMenu(HMENU hMenuCall)
  1740. {
  1741. if (NULL != hMenuCall)
  1742. {
  1743. {
  1744. bool bEnabled = ConfPolicies::IsAutoAcceptCallsOptionEnabled();
  1745. bool bChecked = ConfPolicies::IsAutoAcceptCallsEnabled();
  1746. EnableMenuItem(hMenuCall, ID_AUTOACCEPT, MF_BYCOMMAND | (bEnabled ? MF_ENABLED : MF_GRAYED));
  1747. CheckMenuItem (hMenuCall, ID_AUTOACCEPT, MF_BYCOMMAND | (bChecked ? MF_CHECKED : MF_UNCHECKED));
  1748. }
  1749. TCHAR szMenu[ MAX_PATH * 2 ];
  1750. if( ConfPolicies::GetCallingMode() == ConfPolicies::CallingMode_GateKeeper )
  1751. {
  1752. // This means that we are in gatekeeper mode...
  1753. RegEntry reConf( CONFERENCING_KEY, HKEY_CURRENT_USER );
  1754. FLoadString1( IsGatekeeperLoggedOn()? IDS_LOGOFF_ULS: IDS_LOGON_ULS, szMenu, reConf.GetString( REGVAL_GK_SERVER ) );
  1755. ::ModifyMenu( hMenuCall, IDM_FILE_LOGON_ULS, MF_BYCOMMAND | MF_STRING, IDM_FILE_LOGON_ULS, szMenu );
  1756. }
  1757. else
  1758. {
  1759. const TCHAR * const defaultServer = CDirectoryManager::get_displayName( CDirectoryManager::get_defaultServer() );
  1760. bool bMenuItemShouldSayLogon = ((NULL == g_pLDAP) || !(g_pLDAP->IsLoggedOn() || g_pLDAP ->IsLoggingOn()));
  1761. FLoadString1( bMenuItemShouldSayLogon? IDS_LOGON_ULS: IDS_LOGOFF_ULS, szMenu, (void *) defaultServer );
  1762. ::ModifyMenu( hMenuCall, IDM_FILE_LOGON_ULS, MF_BYCOMMAND | MF_STRING, IDM_FILE_LOGON_ULS, szMenu );
  1763. ::EnableMenuItem( hMenuCall, IDM_FILE_LOGON_ULS, SysPol::AllowDirectoryServices()? MF_ENABLED: MF_GRAYED );
  1764. }
  1765. // Set the state of the hangup item:
  1766. ::EnableMenuItem( hMenuCall,
  1767. IDM_FILE_HANGUP,
  1768. FIsConferenceActive() ? MF_ENABLED : MF_GRAYED);
  1769. // Only enable the host conference item if we're not in a call:
  1770. ::EnableMenuItem( hMenuCall,
  1771. ID_FILE_CONF_HOST,
  1772. (FIsConferenceActive() ||
  1773. FIsCallInProgress()) ? MF_GRAYED : MF_ENABLED);
  1774. //
  1775. // Only enable the meeting settings item if we're in a call and there
  1776. // are settings.
  1777. //
  1778. ::EnableMenuItem(hMenuCall,
  1779. IDM_CALL_MEETINGSETTINGS,
  1780. MF_BYCOMMAND |
  1781. ((FIsConferenceActive() && (m_pConfRoom->GetMeetingSettings() != NM_PERMIT_ALL)) ?
  1782. MF_ENABLED : MF_GRAYED));
  1783. // Only enable the New Call menu item if permitted by settings
  1784. ::EnableMenuItem(hMenuCall,
  1785. ID_TB_NEW_CALL,
  1786. MF_BYCOMMAND|MenuState(m_pConfRoom->IsNewCallAllowed()));
  1787. // Check the "Do Not Disturb" menu item:
  1788. ::CheckMenuItem(hMenuCall,
  1789. ID_FILE_DO_NOT_DISTURB,
  1790. ::FDoNotDisturb() ? MF_CHECKED : MF_UNCHECKED);
  1791. RegEntry reLM(REMOTECONTROL_KEY, HKEY_LOCAL_MACHINE);
  1792. BOOL fActivated = reLM.GetNumber(REMOTE_REG_ACTIVATESERVICE, DEFAULT_REMOTE_ACTIVATESERVICE);
  1793. BOOL fEnabled = reLM.GetNumber(REMOTE_REG_RUNSERVICE,DEFAULT_REMOTE_RUNSERVICE);
  1794. if (fEnabled && !fActivated && !m_fExitAndActivateRDSMenuItem)
  1795. {
  1796. TCHAR szExitAndActivateRDSMenuItem[MAX_PATH];
  1797. MENUITEMINFO mmi;
  1798. int cchExitAndActivateRDSMenuItem = ::LoadString(GetInstanceHandle(),
  1799. ID_FILE_EXIT_ACTIVATERDS,
  1800. szExitAndActivateRDSMenuItem,
  1801. CCHMAX(szExitAndActivateRDSMenuItem));
  1802. if (0 == cchExitAndActivateRDSMenuItem)
  1803. {
  1804. ERROR_OUT(("LoadString(%d) failed", (int) ID_FILE_EXIT_ACTIVATERDS));
  1805. }
  1806. else
  1807. {
  1808. //ZeroMemory((PVOID) &mmi, sizeof(mmi));
  1809. mmi.cbSize = sizeof(mmi);
  1810. mmi.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
  1811. mmi.fState = MFS_ENABLED;
  1812. mmi.wID = ID_FILE_EXIT_ACTIVATERDS;
  1813. mmi.fType = MFT_STRING;
  1814. mmi.dwTypeData = szExitAndActivateRDSMenuItem;
  1815. mmi.cch = cchExitAndActivateRDSMenuItem;
  1816. if (InsertMenuItem(hMenuCall,-1,FALSE,&mmi))
  1817. {
  1818. m_fExitAndActivateRDSMenuItem = TRUE;
  1819. }
  1820. else
  1821. {
  1822. ERROR_OUT(("InsertMenuItem() failed, rc=%lu", (ULONG) GetLastError()));
  1823. }
  1824. }
  1825. }
  1826. else if (m_fExitAndActivateRDSMenuItem && (fActivated || !fEnabled))
  1827. {
  1828. if (DeleteMenu(hMenuCall,ID_FILE_EXIT_ACTIVATERDS,MF_BYCOMMAND))
  1829. {
  1830. m_fExitAndActivateRDSMenuItem = FALSE;
  1831. }
  1832. else
  1833. {
  1834. ERROR_OUT(("DeleteMenu() failed, rc=%lu", (ULONG) GetLastError()));
  1835. }
  1836. }
  1837. }
  1838. }
  1839. /****************************************************************************
  1840. *
  1841. * CLASS: CConfRoom
  1842. *
  1843. * MEMBER: UpdateHelpMenu(HMENU hMenuHelp)
  1844. *
  1845. * PURPOSE: Updates the help menu
  1846. *
  1847. ****************************************************************************/
  1848. VOID CTopWindow::UpdateHelpMenu(HMENU hMenuHelp)
  1849. {
  1850. if (NULL != hMenuHelp)
  1851. {
  1852. // Enable/disable web items
  1853. UINT uEnable = ::CanShellExecHttp() ? MF_ENABLED : MF_GRAYED;
  1854. ::EnableMenuItem(hMenuHelp, IDM_FILE_LAUNCH_WEB_PAGE, uEnable);
  1855. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_FREE, uEnable);
  1856. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_NEWS, uEnable);
  1857. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_FAQ, uEnable);
  1858. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_FEEDBACK, uEnable);
  1859. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_MSHOME, uEnable);
  1860. ::EnableMenuItem(hMenuHelp, ID_HELP_WEB_SUPPORT, uEnable);
  1861. }
  1862. }
  1863. /****************************************************************************
  1864. *
  1865. * CLASS: CConfRoom
  1866. *
  1867. * MEMBER: UpdateViewMenu(HMENU hMenuView)
  1868. *
  1869. * PURPOSE: Updates the view menu by placing a bullet next to the
  1870. * current view and a check mark next to the toolbar and
  1871. * status bar items
  1872. *
  1873. ****************************************************************************/
  1874. VOID CTopWindow::UpdateViewMenu(HMENU hMenuView)
  1875. {
  1876. if (NULL == hMenuView)
  1877. return;
  1878. CheckMenu_ViewStatusBar(hMenuView);
  1879. CMainUI *pMainUI = GetMainUI();
  1880. BOOL bChecked;
  1881. BOOL bEnable;
  1882. bChecked = (NULL != pMainUI && pMainUI->IsCompact());
  1883. CheckMenuItem(hMenuView, IDM_VIEW_COMPACT,
  1884. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1885. bEnable = FIsAVCapable();
  1886. EnableMenuItem(hMenuView, IDM_VIEW_COMPACT,
  1887. MF_BYCOMMAND|(bEnable ? MF_ENABLED : MF_GRAYED|MF_DISABLED));
  1888. bChecked = (NULL != pMainUI && pMainUI->IsDataOnly());
  1889. CheckMenuItem(hMenuView, IDM_VIEW_DATAONLY,
  1890. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1891. bEnable = FIsAVCapable();
  1892. EnableMenuItem(hMenuView, IDM_VIEW_DATAONLY,
  1893. MF_BYCOMMAND|(bEnable ? MF_ENABLED : MF_GRAYED|MF_DISABLED));
  1894. bChecked = (NULL != pMainUI && pMainUI->IsDialing());
  1895. CheckMenuItem(hMenuView, IDM_VIEW_DIALPAD,
  1896. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1897. bEnable = (NULL != pMainUI && pMainUI->IsDialingAllowed());
  1898. bEnable = bEnable && FIsAVCapable();
  1899. EnableMenuItem(hMenuView, IDM_VIEW_DIALPAD,
  1900. MF_BYCOMMAND|(bEnable ? MF_ENABLED : MF_GRAYED|MF_DISABLED));
  1901. bChecked = (NULL != pMainUI && pMainUI->IsPicInPic());
  1902. CheckMenuItem(hMenuView, ID_TB_PICINPIC,
  1903. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1904. bEnable = (NULL != pMainUI && pMainUI->IsPicInPicAllowed());
  1905. EnableMenuItem(hMenuView, ID_TB_PICINPIC,
  1906. MF_BYCOMMAND|(bEnable ? MF_ENABLED : MF_GRAYED|MF_DISABLED));
  1907. bChecked = IsOnTop();
  1908. CheckMenuItem(hMenuView, IDM_VIEW_ONTOP,
  1909. MF_BYCOMMAND|(bChecked ? MF_CHECKED : MF_UNCHECKED));
  1910. }
  1911. /****************************************************************************
  1912. *
  1913. * CLASS: CConfRoom
  1914. *
  1915. * MEMBER: UpdateToolsMenu(HMENU hMenuTools)
  1916. *
  1917. * PURPOSE: Updates the tools menu
  1918. *
  1919. ****************************************************************************/
  1920. VOID CTopWindow::UpdateToolsMenu(HMENU hMenuTools)
  1921. {
  1922. if (NULL != hMenuTools)
  1923. {
  1924. bool fRDSDisabled = ConfPolicies::IsRDSDisabled();
  1925. EnableMenuItem(hMenuTools, ID_TOOLS_AUDIO_WIZARD,
  1926. FEnableAudioWizard() ? MF_ENABLED : MF_GRAYED);
  1927. EnableMenuItem(hMenuTools, ID_TB_SHARING,
  1928. MF_BYCOMMAND|MenuState(m_pConfRoom->IsSharingAllowed()));
  1929. //
  1930. // No app sharing, no RDS.
  1931. //
  1932. if (!m_pConfRoom->FIsSharingAvailable())
  1933. {
  1934. fRDSDisabled = TRUE;
  1935. }
  1936. // If this is NT, we need to handle adding or removing the menu item
  1937. // to enable the display driver for application sharing. We add the
  1938. // menu item (immediately above the "Options" item) if the display
  1939. // driver is not enabled and the item hasn't been added already. We
  1940. // remove the menu item if it's there and the display driver is
  1941. // enabled, which should only happen if the user enabled it and then
  1942. // choose to ignore the reboot prompt.
  1943. if (::IsWindowsNT())
  1944. {
  1945. if (!g_fNTDisplayDriverEnabled && !m_fEnableAppSharingMenuItem)
  1946. {
  1947. // Add the menu item
  1948. TCHAR szEnableAppSharingMenuItem[MAX_PATH];
  1949. MENUITEMINFO mmi;
  1950. int cchEnableAppSharingMenuItem =
  1951. ::LoadString(
  1952. GetInstanceHandle(),
  1953. ID_TOOLS_ENABLEAPPSHARING,
  1954. szEnableAppSharingMenuItem,
  1955. CCHMAX(szEnableAppSharingMenuItem));
  1956. if (0 == cchEnableAppSharingMenuItem)
  1957. {
  1958. ERROR_OUT(("LoadString(%d) failed", (int) ID_TOOLS_ENABLEAPPSHARING));
  1959. }
  1960. else
  1961. {
  1962. //ZeroMemory((PVOID) &mmi, sizeof(mmi));
  1963. mmi.cbSize = sizeof(mmi);
  1964. mmi.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
  1965. mmi.fState = MFS_ENABLED;
  1966. mmi.wID = ID_TOOLS_ENABLEAPPSHARING;
  1967. mmi.fType = MFT_STRING;
  1968. mmi.dwTypeData = szEnableAppSharingMenuItem;
  1969. mmi.cch = cchEnableAppSharingMenuItem;
  1970. if (InsertMenuItem(
  1971. hMenuTools,
  1972. ID_TOOLS_OPTIONS,
  1973. FALSE,
  1974. &mmi))
  1975. {
  1976. m_fEnableAppSharingMenuItem = TRUE;
  1977. }
  1978. else
  1979. {
  1980. ERROR_OUT(("InsertMenuItem() failed, rc=%lu", (ULONG) GetLastError()));
  1981. }
  1982. }
  1983. }
  1984. else if (m_fEnableAppSharingMenuItem && g_fNTDisplayDriverEnabled)
  1985. {
  1986. // Remove the menu item
  1987. if (DeleteMenu(
  1988. hMenuTools,
  1989. ID_TOOLS_ENABLEAPPSHARING,
  1990. MF_BYCOMMAND))
  1991. {
  1992. m_fEnableAppSharingMenuItem = FALSE;
  1993. }
  1994. else
  1995. {
  1996. ERROR_OUT(("DeleteMenu() failed, rc=%lu", (ULONG) GetLastError()));
  1997. }
  1998. }
  1999. if (m_fEnableAppSharingMenuItem)
  2000. fRDSDisabled = TRUE;
  2001. }
  2002. else
  2003. {
  2004. // Windows 9.x;
  2005. if (ConfPolicies::IsRDSDisabledOnWin9x())
  2006. {
  2007. fRDSDisabled = TRUE;
  2008. }
  2009. }
  2010. EnableMenuItem(hMenuTools, ID_TOOLS_RDSWIZARD, MF_BYCOMMAND |
  2011. (fRDSDisabled ? MF_GRAYED : MF_ENABLED));
  2012. //
  2013. // LAURABU BOGUS:
  2014. // Make installable tools a popup from Tools submenu, don't put these
  2015. // flat!
  2016. //
  2017. CleanTools(hMenuTools, m_ExtToolsList);
  2018. if (m_pConfRoom->GetMeetingPermissions() & NM_PERMIT_STARTOTHERTOOLS)
  2019. {
  2020. FillInTools(hMenuTools, 0, TOOLS_MENU_KEY, m_ExtToolsList);
  2021. }
  2022. BOOL fEnableSend = FALSE;
  2023. BOOL fSending = FALSE;
  2024. CVideoWindow *pLocal = GetLocalVideo();
  2025. if (NULL != pLocal)
  2026. {
  2027. fEnableSend = pLocal->IsXferAllowed() &&
  2028. ((m_pConfRoom->GetMeetingPermissions() & NM_PERMIT_SENDVIDEO) != 0);
  2029. fSending = fEnableSend &&
  2030. !pLocal->IsPaused();
  2031. }
  2032. BOOL fEnableReceive = FALSE;
  2033. BOOL fReceiving = FALSE;
  2034. CVideoWindow *pRemote = GetRemoteVideo();
  2035. if (NULL != pRemote)
  2036. {
  2037. fEnableReceive = pRemote->IsConnected();
  2038. fReceiving = fEnableReceive &&
  2039. !pRemote->IsPaused();
  2040. }
  2041. EnableMenuItem( hMenuTools,
  2042. MENUPOS_TOOLS_VIDEO,
  2043. (MF_BYPOSITION |
  2044. ((fEnableSend || fEnableReceive) ? MF_ENABLED : MF_GRAYED)));
  2045. EnableMenuItem( hMenuTools,
  2046. ID_TOOLS_SENDVIDEO,
  2047. fEnableSend ? MF_ENABLED : MF_GRAYED);
  2048. CheckMenuItem( hMenuTools,
  2049. ID_TOOLS_SENDVIDEO,
  2050. fSending ? MF_CHECKED : MF_UNCHECKED);
  2051. EnableMenuItem( hMenuTools,
  2052. ID_TOOLS_RECEIVEVIDEO,
  2053. fEnableReceive ? MF_ENABLED : MF_GRAYED);
  2054. CheckMenuItem( hMenuTools,
  2055. ID_TOOLS_RECEIVEVIDEO,
  2056. fReceiving ? MF_CHECKED : MF_UNCHECKED);
  2057. EnableMenuItem(hMenuTools, ID_TOOLS_OPTIONS,
  2058. MF_BYCOMMAND|MenuState(CanLaunchConfCpl()));
  2059. //
  2060. // OTHER TOOLS
  2061. //
  2062. EnableMenuItem(hMenuTools, ID_TB_NEWWHITEBOARD,
  2063. MF_BYCOMMAND|MenuState(m_pConfRoom->IsNewWhiteboardAllowed()));
  2064. EnableMenuItem(hMenuTools, ID_TB_WHITEBOARD,
  2065. MF_BYCOMMAND|MenuState(m_pConfRoom->IsOldWhiteboardAllowed()));
  2066. EnableMenuItem(hMenuTools, ID_TB_CHAT,
  2067. MF_BYCOMMAND|MenuState(m_pConfRoom->IsChatAllowed()));
  2068. EnableMenuItem(hMenuTools, ID_TB_FILETRANSFER,
  2069. MF_BYCOMMAND|MenuState(m_pConfRoom->IsFileTransferAllowed()));
  2070. }
  2071. }
  2072. /****************************************************************************
  2073. *
  2074. * CLASS: CConfRoom
  2075. *
  2076. * MEMBER: SelAndRealizePalette()
  2077. *
  2078. * PURPOSE: Selects and realizes the NetMeeting palette
  2079. *
  2080. ****************************************************************************/
  2081. BOOL CTopWindow::SelAndRealizePalette()
  2082. {
  2083. BOOL bRet = FALSE;
  2084. HPALETTE hPal = m_pConfRoom->GetPalette();
  2085. if (NULL == hPal)
  2086. {
  2087. return(bRet);
  2088. }
  2089. HWND hwnd = GetWindow();
  2090. HDC hdc = ::GetDC(hwnd);
  2091. if (NULL != hdc)
  2092. {
  2093. ::SelectPalette(hdc, hPal, FALSE);
  2094. bRet = (GDI_ERROR != ::RealizePalette(hdc));
  2095. ::ReleaseDC(hwnd, hdc);
  2096. }
  2097. return bRet;
  2098. }
  2099. /****************************************************************************
  2100. *
  2101. * CLASS: CConfRoom
  2102. *
  2103. * MEMBER: InitMenuFont()
  2104. *
  2105. * PURPOSE: Initializes/Updates the menu font member
  2106. *
  2107. ****************************************************************************/
  2108. VOID CTopWindow::InitMenuFont()
  2109. {
  2110. DebugEntry(CConfRoom::InitMenuFont);
  2111. if (NULL != m_hFontMenu)
  2112. {
  2113. ::DeleteObject(m_hFontMenu);
  2114. }
  2115. NONCLIENTMETRICS ncm;
  2116. ncm.cbSize = sizeof(ncm);
  2117. if (::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, FALSE))
  2118. {
  2119. m_hFontMenu = ::CreateFontIndirect(&(ncm.lfMenuFont));
  2120. ASSERT(m_hFontMenu);
  2121. }
  2122. DebugExitVOID(CConfRoom::InitMenuFont);
  2123. }
  2124. CVideoWindow* CTopWindow::GetLocalVideo()
  2125. {
  2126. CMainUI *pMainUI = GetMainUI();
  2127. return (pMainUI ? pMainUI->GetLocalVideo() : NULL);
  2128. }
  2129. CVideoWindow* CTopWindow::GetRemoteVideo()
  2130. {
  2131. CMainUI *pMainUI = GetMainUI();
  2132. return (pMainUI ? pMainUI->GetRemoteVideo() : NULL);
  2133. }
  2134. BOOL CTopWindow::IsOnTop()
  2135. {
  2136. return((GetWindowLong(GetWindow(), GWL_EXSTYLE)&WS_EX_TOPMOST) == WS_EX_TOPMOST);
  2137. }
  2138. void CTopWindow::SetOnTop(BOOL bOnTop)
  2139. {
  2140. bOnTop = (bOnTop != FALSE);
  2141. if (IsOnTop() == bOnTop)
  2142. {
  2143. // Nothing to do
  2144. return;
  2145. }
  2146. SetWindowPos(GetWindow(), bOnTop ? HWND_TOPMOST : HWND_NOTOPMOST,
  2147. 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
  2148. }
  2149. HPALETTE CTopWindow::GetPalette()
  2150. {
  2151. return(m_pConfRoom->GetPalette());
  2152. }