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.

102 lines
2.2 KiB

  1. // FullScCtl.cpp : Implementation of CFullScCtl
  2. #include "stdafx.h"
  3. #include "Fullsc.h"
  4. #include "FullScCtl.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CFullScCtl
  7. STDMETHODIMP CFullScCtl::get_FullScreen(VARIANT_BOOL *pVal)
  8. {
  9. HRESULT hr;
  10. LPOLECLIENTSITE pClientSite = NULL;
  11. IWebBrowser2 *pBrowser=NULL;
  12. hr = GetClientSite(&pClientSite);
  13. if (FAILED(hr))
  14. return hr;
  15. hr = pClientSite->QueryInterface(IID_IWebBrowser2, reinterpret_cast<void**>(&pBrowser));
  16. pClientSite->Release();
  17. if (FAILED(hr))
  18. return hr;
  19. hr = pBrowser->get_FullScreen(pVal);
  20. pBrowser->Release();
  21. if (FAILED(hr))
  22. return hr;
  23. return S_OK;
  24. }
  25. STDMETHODIMP CFullScCtl::put_FullScreen(VARIANT_BOOL newVal)
  26. {
  27. HRESULT hr;
  28. LPOLECLIENTSITE pClientSite = NULL;
  29. IWebBrowser2 *pBrowser=NULL;
  30. hr = GetClientSite(&pClientSite);
  31. if (FAILED(hr))
  32. return hr;
  33. #if 0 //This doesn't work. Use undocumented way as in the #else part.
  34. hr = pClientSite->QueryInterface(IID_IWebBrowser2, (LPVOID*)&pBrowser);
  35. pClientSite->Release();
  36. if(FAILED(hr))
  37. return(hr);
  38. #else
  39. IServiceProvider* psp=NULL;
  40. hr = pClientSite->QueryInterface(IID_IServiceProvider, (LPVOID*)&psp);
  41. pClientSite->Release();
  42. if(FAILED(hr))
  43. return(hr);
  44. hr = psp->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, (LPVOID*)&pBrowser);
  45. psp->Release();
  46. if (FAILED(hr))
  47. return hr;
  48. #endif
  49. hr = pBrowser->put_FullScreen(newVal);
  50. /*
  51. if (newVal == VARIANT_FALSE)
  52. {
  53. HideTitleBar(pBrowser);
  54. }
  55. */
  56. pBrowser->Release();
  57. if (FAILED(hr))
  58. return hr;
  59. return S_OK;
  60. }
  61. HRESULT
  62. CFullScCtl::HideTitleBar(IWebBrowser2 *pBrowser)
  63. {
  64. HWND hWnd = NULL;
  65. HRESULT hr;
  66. hr = pBrowser->get_HWND(reinterpret_cast<PLONG>(&hWnd)); //? Does get_HWND addref the hwnd?
  67. if (FAILED(hr))
  68. return hr;
  69. LONG lWndStyle = ::GetWindowLong(hWnd, GWL_STYLE);
  70. if (0 == lWndStyle)
  71. return hr;
  72. lWndStyle &= (~WS_TILEDWINDOW);
  73. ::SetWindowLong(hWnd, GWL_STYLE, lWndStyle);
  74. ::InvalidateRect(hWnd, NULL, TRUE);
  75. ::UpdateWindow(hWnd);
  76. return S_OK;
  77. }