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.

77 lines
1.7 KiB

  1. // Page1.cpp : Implementation of CTaskAppApp and DLL registration.
  2. #include "pch.h"
  3. #include "TaskApp.h"
  4. #include "LiteControl.h"
  5. #include "Page1.h"
  6. #include "Page2.h"
  7. EXTERN_C const CLSID CLSID_CPage1 = __uuidof(CPage1);
  8. /////////////////////////////////////////////////////////////////////////////
  9. //
  10. STDMETHODIMP CPage1::SetFrame(ITaskFrame* pFrame)
  11. {
  12. ATOMICRELEASE(m_pTaskFrame);
  13. m_pTaskFrame = pFrame;
  14. if (m_pTaskFrame)
  15. m_pTaskFrame->AddRef();
  16. return S_OK;
  17. }
  18. // 1 primary, 3 secondary
  19. static const UINT s_rgObjectCount[] = { 1, 3 };
  20. STDMETHODIMP CPage1::GetObjectCount(UINT nArea, UINT *pVal)
  21. {
  22. if (!pVal)
  23. return E_POINTER;
  24. *pVal = 0;
  25. if (nArea < ARRAYSIZE(s_rgObjectCount))
  26. *pVal = s_rgObjectCount[nArea];
  27. return S_OK;
  28. }
  29. STDMETHODIMP CPage1::CreateObject(UINT nArea, UINT nIndex, REFIID riid, void **ppv)
  30. {
  31. HRESULT hr;
  32. CComObject<CLiteControl>* pControl = NULL;
  33. hr = CComObject<CLiteControl>::CreateInstance(&pControl);
  34. if (SUCCEEDED(hr))
  35. {
  36. static const LPCWSTR pszFormat[] =
  37. {
  38. L"Page 1 primary control #%d",
  39. L"Secondary #%d",
  40. L"Unknown %d"
  41. };
  42. WCHAR szText[MAX_PATH];
  43. pControl->AddRef();
  44. pControl->SetFrame(m_pTaskFrame);
  45. pControl->SetDestinationPage(CLSID_CPage2);
  46. nArea = min(nArea, ARRAYSIZE(pszFormat)-1);
  47. wsprintfW(szText, pszFormat[nArea], nIndex+1);
  48. pControl->SetText(szText);
  49. pControl->SetMaxExtent(MAXLONG, nArea ? 0 : MAXLONG);
  50. hr = pControl->QueryInterface(riid, ppv);
  51. pControl->Release();
  52. }
  53. return hr;
  54. }
  55. STDMETHODIMP CPage1::Reinitialize(ULONG /*reserved*/)
  56. {
  57. return E_FAIL;
  58. }