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.

100 lines
2.1 KiB

  1. /****************************************************************************\
  2. *
  3. * MSLUPROP.CPP
  4. *
  5. * Created: William Taylor (wtaylor) 12/14/00
  6. *
  7. * MS Ratings Property Sheet Class
  8. *
  9. \****************************************************************************/
  10. /*INCLUDES--------------------------------------------------------------------*/
  11. #include "msrating.h"
  12. #include "msluprop.h"
  13. #include "debug.h"
  14. #include "apithk.h"
  15. #include <mluisupp.h>
  16. /*Property Sheet Class--------------------------------------------------------*/
  17. PropSheet::PropSheet()
  18. {
  19. memset(&psHeader, 0,sizeof(psHeader));
  20. psHeader.dwSize = sizeof(psHeader);
  21. }
  22. PropSheet::~PropSheet()
  23. {
  24. if ( psHeader.pszCaption )
  25. {
  26. delete (LPSTR)psHeader.pszCaption;
  27. psHeader.pszCaption = NULL;
  28. }
  29. if ( psHeader.phpage )
  30. {
  31. delete psHeader.phpage;
  32. psHeader.phpage = NULL;
  33. }
  34. }
  35. BOOL PropSheet::Init(HWND hwnd, int nPages, char *szCaption, BOOL fApplyNow)
  36. {
  37. HINSTANCE hinst = _Module.GetResourceInstance();
  38. char *p;
  39. psHeader.hwndParent = hwnd;
  40. psHeader.hInstance = hinst;
  41. p = new char [strlenf(szCaption)+1];
  42. if (p == NULL)
  43. return FALSE;
  44. strcpyf(p, szCaption);
  45. psHeader.pszCaption = p;
  46. psHeader.phpage = new HPROPSHEETPAGE [nPages];
  47. if (psHeader.phpage == NULL)
  48. {
  49. delete p;
  50. p = NULL;
  51. psHeader.pszCaption = NULL;
  52. return FALSE;
  53. }
  54. if ( ! fApplyNow )
  55. {
  56. psHeader.dwFlags |= PSH_NOAPPLYNOW;
  57. }
  58. return (psHeader.pszCaption != NULL);
  59. }
  60. // We can safely cast down to (int) because we don't use modeless
  61. // property sheets.
  62. int PropSheet::Run()
  63. {
  64. return (int)::PropertySheet(&psHeader);
  65. }
  66. void PropSheet::MakePropPage( HPROPSHEETPAGE hPage )
  67. {
  68. ASSERT( hPage );
  69. if ( ! hPage )
  70. {
  71. TraceMsg( TF_ERROR, "PropSheet::MakePropPage() - hPage is NULL!" );
  72. return;
  73. }
  74. // Add newly created page handle to list of pages in Header.
  75. if ( psHeader.phpage )
  76. {
  77. psHeader.phpage[psHeader.nPages] = hPage;
  78. if ( hPage )
  79. {
  80. psHeader.nPages++;
  81. }
  82. }
  83. return;
  84. }