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.

224 lines
6.3 KiB

  1. #include "precomp.h"
  2. #include "resource.h"
  3. #include "EditServer.h"
  4. #include "nmakwiz.h"
  5. CEditServer* CEditServer::ms_pThis = NULL;
  6. CEditServer::CEditServer( HWND hwndParent, LPTSTR szServer, size_t cbLen )
  7. : m_hwnd( NULL ), m_hwndParent( hwndParent ), m_cbLen( cbLen )
  8. {
  9. ms_pThis = this;
  10. m_szServerBuffer = new TCHAR[ m_cbLen ];
  11. lstrcpy( m_szServerBuffer, szServer );
  12. }
  13. CEditServer::~CEditServer()
  14. {
  15. ms_pThis = NULL;
  16. delete [] m_szServerBuffer;
  17. }
  18. int CEditServer::ShowDialog()
  19. {
  20. return DialogBox( g_hInstance, // handle to application instance
  21. MAKEINTRESOURCE( IDD_DIALOG_EDIT_SERVERNAME ), // identifies dialog box template
  22. m_hwndParent, // handle to owner window
  23. _Proc, // pointer to dialog box procedure
  24. );
  25. }
  26. INT_PTR CALLBACK CEditServer::_Proc( HWND hwndDlg, // handle to dialog box
  27. UINT uMsg, // message
  28. WPARAM wParam, // first message parameter
  29. LPARAM lParam // second message parameter
  30. )
  31. {
  32. switch( uMsg )
  33. {
  34. case WM_INITDIALOG:
  35. {
  36. HWND hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT_SERVER_NAME );
  37. Edit_SetText( hwndEdit, ms_pThis->m_szServerBuffer );
  38. Edit_LimitText( hwndEdit, ms_pThis->m_cbLen - 1 );
  39. return TRUE;
  40. break;
  41. }
  42. case WM_COMMAND:
  43. {
  44. switch (GET_WM_COMMAND_ID(wParam, lParam))
  45. {
  46. case IDOK:
  47. {
  48. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  49. {
  50. case BN_CLICKED:
  51. {
  52. HWND hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT_SERVER_NAME );
  53. if( Edit_GetTextLength( hwndEdit ) )
  54. {
  55. if( !Edit_GetText( hwndEdit, ms_pThis->m_szServerBuffer, ms_pThis->m_cbLen ) )
  56. {
  57. ErrorMessage( TEXT("Edit_GetText"), GetLastError() );
  58. }
  59. EndDialog( hwndDlg, IDOK );
  60. }
  61. else
  62. {
  63. NmrkMessageBox(
  64. MAKEINTRESOURCE(IDS_REMOVE_SERVER),
  65. MAKEINTRESOURCE(IDS_EMPTY_SERVER),
  66. MB_ICONEXCLAMATION | MB_OK,
  67. hwndDlg);
  68. }
  69. return TRUE;
  70. break;
  71. }
  72. }
  73. break;
  74. }
  75. case IDCANCEL:
  76. {
  77. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  78. {
  79. case BN_CLICKED:
  80. {
  81. EndDialog( hwndDlg, IDCANCEL );
  82. return TRUE;
  83. break;
  84. }
  85. }
  86. break;
  87. }
  88. }
  89. break;
  90. }
  91. }
  92. return 0;
  93. }
  94. CEditWebView* CEditWebView::ms_pThis = NULL;
  95. CEditWebView::CEditWebView( HWND hwndParent, LPCTSTR szServer, LPCTSTR szName, LPCTSTR szURL, size_t cbLen )
  96. : m_hwndParent( hwndParent ), m_cbLen( cbLen ), m_bEditServer(TRUE)
  97. {
  98. ms_pThis = this;
  99. m_szServerBuffer = new TCHAR[ m_cbLen ];
  100. lstrcpy( m_szServerBuffer, szServer );
  101. m_szNameBuffer = new TCHAR[ m_cbLen ];
  102. lstrcpy( m_szNameBuffer, szName );
  103. m_szURLBuffer = new TCHAR[ m_cbLen ];
  104. lstrcpy( m_szURLBuffer, szURL );
  105. }
  106. CEditWebView::~CEditWebView()
  107. {
  108. ms_pThis = NULL;
  109. delete [] m_szServerBuffer;
  110. delete [] m_szNameBuffer;
  111. delete [] m_szURLBuffer;
  112. }
  113. int CEditWebView::ShowDialog()
  114. {
  115. return DialogBox( g_hInstance, // handle to application instance
  116. MAKEINTRESOURCE( IDD_DIALOG_EDIT_WEBVIEW ), // identifies dialog box template
  117. m_hwndParent, // handle to owner window
  118. _Proc, // pointer to dialog box procedure
  119. );
  120. }
  121. INT_PTR CALLBACK CEditWebView::_Proc( HWND hwndDlg, // handle to dialog box
  122. UINT uMsg, // message
  123. WPARAM wParam, // first message parameter
  124. LPARAM lParam // second message parameter
  125. )
  126. {
  127. switch( uMsg )
  128. {
  129. case WM_INITDIALOG:
  130. {
  131. HWND hwndEdit;
  132. hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT_SERVER_NAME );
  133. Edit_SetText( hwndEdit, ms_pThis->m_szServerBuffer );
  134. Edit_LimitText( hwndEdit, ms_pThis->m_cbLen - 1 );
  135. FORWARD_WM_NEXTDLGCTL(hwndDlg, hwndEdit, TRUE, SendMessage);
  136. if (!ms_pThis->GetEditServer())
  137. {
  138. Edit_SetReadOnly(hwndEdit, TRUE);
  139. FORWARD_WM_NEXTDLGCTL(hwndDlg, FALSE, FALSE, SendMessage);
  140. }
  141. hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT_URL_NAME );
  142. Edit_SetText( hwndEdit, ms_pThis->m_szURLBuffer );
  143. Edit_LimitText( hwndEdit, ms_pThis->m_cbLen - 1 );
  144. hwndEdit = GetDlgItem( hwndDlg, IDC_EDIT_DISPLAY_NAME );
  145. Edit_SetText( hwndEdit, ms_pThis->m_szNameBuffer );
  146. Edit_LimitText( hwndEdit, ms_pThis->m_cbLen - 1 );
  147. // I already set the focus
  148. return FALSE;
  149. break;
  150. }
  151. case WM_COMMAND:
  152. {
  153. switch (GET_WM_COMMAND_ID(wParam, lParam))
  154. {
  155. case IDOK:
  156. {
  157. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  158. {
  159. case BN_CLICKED:
  160. {
  161. if( GetDlgItemText( hwndDlg, IDC_EDIT_SERVER_NAME, ms_pThis->m_szServerBuffer, ms_pThis->m_cbLen )
  162. && GetDlgItemText( hwndDlg, IDC_EDIT_URL_NAME, ms_pThis->m_szURLBuffer, ms_pThis->m_cbLen )
  163. && GetDlgItemText( hwndDlg, IDC_EDIT_DISPLAY_NAME, ms_pThis->m_szNameBuffer, ms_pThis->m_cbLen ))
  164. {
  165. EndDialog( hwndDlg, IDOK );
  166. }
  167. else
  168. {
  169. NmrkMessageBox(
  170. MAKEINTRESOURCE(IDS_ERROR_NEEDALLFIELDS),
  171. MAKEINTRESOURCE(IDS_EDIT_WEBVIEW),
  172. MB_ICONEXCLAMATION | MB_OK,
  173. hwndDlg);
  174. }
  175. return TRUE;
  176. break;
  177. }
  178. }
  179. break;
  180. }
  181. case IDCANCEL:
  182. {
  183. switch (GET_WM_COMMAND_CMD(wParam, lParam))
  184. {
  185. case BN_CLICKED:
  186. {
  187. EndDialog( hwndDlg, IDCANCEL );
  188. return TRUE;
  189. break;
  190. }
  191. }
  192. break;
  193. }
  194. }
  195. break;
  196. }
  197. }
  198. return 0;
  199. }