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.

150 lines
3.7 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 2000
  4. *
  5. * TITLE: GETURLDLG.H
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 4/5/2000
  12. *
  13. * DESCRIPTION: Get an URL
  14. *
  15. *******************************************************************************/
  16. #ifndef __GETURL_H_INCLUDED
  17. #define __GETURL_H_INCLUDED
  18. #include <windows.h>
  19. #include <simcrack.h>
  20. #include <simstr.h>
  21. #include "mru.h"
  22. class CGetCommunityUrlDialog
  23. {
  24. public:
  25. class CData
  26. {
  27. private:
  28. CSimpleString m_strUrl;
  29. CSimpleString m_strMruRegistryKey;
  30. CSimpleString m_strMruRegistryValue;
  31. private:
  32. CData( const CData & );
  33. CData &operator=( const CData & );
  34. public:
  35. CData(void)
  36. {
  37. }
  38. ~CData(void)
  39. {
  40. }
  41. void MruRegistryKey( LPCTSTR pszMruRegistryKey )
  42. {
  43. m_strMruRegistryKey = pszMruRegistryKey;
  44. }
  45. void MruRegistryValue( LPCTSTR pszMruRegistryValue )
  46. {
  47. m_strMruRegistryValue = pszMruRegistryValue;
  48. }
  49. void Url( LPCTSTR pszUrl )
  50. {
  51. m_strUrl = pszUrl;
  52. }
  53. CSimpleString MruRegistryValue(void) const
  54. {
  55. return m_strMruRegistryValue;
  56. }
  57. CSimpleString MruRegistryKey(void) const
  58. {
  59. return m_strMruRegistryKey;
  60. }
  61. CSimpleString Url(void) const
  62. {
  63. return m_strUrl;
  64. }
  65. };
  66. private:
  67. HWND m_hWnd;
  68. CData *m_pData;
  69. CMruStringList m_UrlListMru;
  70. private:
  71. CGetCommunityUrlDialog(void);
  72. CGetCommunityUrlDialog( const CGetCommunityUrlDialog & );
  73. CGetCommunityUrlDialog &operator=( const CGetCommunityUrlDialog & );
  74. private:
  75. explicit CGetCommunityUrlDialog( HWND hWnd )
  76. : m_hWnd(hWnd),
  77. m_pData(NULL)
  78. {
  79. }
  80. ~CGetCommunityUrlDialog(void)
  81. {
  82. m_hWnd = NULL;
  83. m_pData = NULL;
  84. }
  85. protected:
  86. LRESULT OnInitDialog( WPARAM, LPARAM lParam )
  87. {
  88. m_pData = reinterpret_cast<CData*>(lParam);
  89. if (!m_pData)
  90. {
  91. EndDialog( m_hWnd, IDCANCEL );
  92. }
  93. if (m_pData->MruRegistryKey().Length() && m_pData->MruRegistryValue().Length())
  94. {
  95. m_UrlListMru.Read( HKEY_CURRENT_USER, m_pData->MruRegistryKey(), m_pData->MruRegistryValue() );
  96. }
  97. m_UrlListMru.PopulateComboBox( GetDlgItem( m_hWnd, IDC_URL_LIST ) );
  98. SendDlgItemMessage( m_hWnd, IDC_URL_LIST, CB_SETCURSEL, 0, 0 );
  99. return 0;
  100. }
  101. void OnOK( WPARAM, LPARAM )
  102. {
  103. CSimpleString strUrl;
  104. strUrl.GetWindowText( GetDlgItem( m_hWnd, IDC_URL_LIST ) );
  105. if (strUrl.Length())
  106. {
  107. m_UrlListMru.Add(strUrl);
  108. m_pData->Url(strUrl);
  109. m_UrlListMru.Write( HKEY_CURRENT_USER, m_pData->MruRegistryKey(), m_pData->MruRegistryValue() );
  110. EndDialog( m_hWnd, IDOK );
  111. }
  112. }
  113. void OnCancel( WPARAM, LPARAM )
  114. {
  115. EndDialog( m_hWnd, IDCANCEL );
  116. }
  117. LRESULT OnCommand( WPARAM wParam, LPARAM lParam )
  118. {
  119. SC_BEGIN_COMMAND_HANDLERS()
  120. {
  121. SC_HANDLE_COMMAND(IDCANCEL,OnCancel);
  122. SC_HANDLE_COMMAND(IDOK,OnOK);
  123. }
  124. SC_END_COMMAND_HANDLERS();
  125. }
  126. public:
  127. static INT_PTR CALLBACK DialogProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  128. {
  129. SC_BEGIN_DIALOG_MESSAGE_HANDLERS(CGetCommunityUrlDialog)
  130. {
  131. SC_HANDLE_DIALOG_MESSAGE( WM_INITDIALOG, OnInitDialog );
  132. SC_HANDLE_DIALOG_MESSAGE( WM_COMMAND, OnCommand );
  133. }
  134. SC_END_DIALOG_MESSAGE_HANDLERS();
  135. }
  136. };
  137. #endif // __GETURL_H_INCLUDED