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.

359 lines
7.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1992 **/
  4. /**********************************************************************/
  5. /*
  6. voledit.cxx
  7. Contains the dialog for editing volumes in the file manager
  8. VOLUME_EDIT_DIALOG
  9. FILE HISTORY:
  10. NarenG 11/11/92 Modified sharemgt.cxx for AFPMGR
  11. */
  12. #define INCL_WINDOWS_GDI
  13. #define INCL_WINDOWS
  14. #define INCL_DOSERRORS
  15. #define INCL_NETERRORS
  16. #define INCL_NETSERVER
  17. #define INCL_NETSHARE
  18. #define INCL_NETCONS
  19. #define INCL_NETLIB
  20. #include <lmui.hxx>
  21. #define INCL_BLT_WINDOW
  22. #define INCL_BLT_DIALOG
  23. #define INCL_BLT_CONTROL
  24. #define INCL_BLT_MISC
  25. #define INCL_BLT_CLIENT
  26. #define INCL_BLT_MSGPOPUP
  27. #define INCL_BLT_SPIN_GROUP
  28. #define INCL_BLT_GROUP
  29. #include <blt.hxx>
  30. extern "C"
  31. {
  32. #include <afpmgr.h>
  33. #include <macfile.h>
  34. }
  35. #include <lmoloc.hxx>
  36. #include <string.hxx>
  37. #include <uitrace.hxx>
  38. #include <volprop.hxx>
  39. #include "voledit.hxx"
  40. /*******************************************************************
  41. NAME: VOLUME_EDIT_DIALOG::VOLUME_EDIT_DIALOG
  42. SYNOPSIS: Constructor
  43. ENTRY: hwndParent - hwnd of the parent window
  44. hServer - handle to the target server
  45. pszServerName - name of the selected computer
  46. EXIT:
  47. RETURNS:
  48. NOTES:
  49. HISTORY:
  50. NarenG 11/18/92 Modified for AFPMGR
  51. ********************************************************************/
  52. VOLUME_EDIT_DIALOG::VOLUME_EDIT_DIALOG( HWND hwndOwner,
  53. AFP_SERVER_HANDLE hServer,
  54. const TCHAR *pszServerName,
  55. const TCHAR *pszPath,
  56. BOOL fIsFile )
  57. : VIEW_VOLUMES_DIALOG_BASE( MAKEINTRESOURCE(IDD_VOLUME_EDIT_DLG),
  58. hwndOwner,
  59. hServer,
  60. pszServerName,
  61. FALSE,
  62. IDEV_SLT_VOLUME_TITLE,
  63. IDEV_LB_VOLUMES),
  64. _pbVolumeInfo( this, IDEV_PB_VOL_INFO ),
  65. _hServer( hServer ),
  66. _pbClose( this, IDOK ),
  67. _sltVolumeTitle( this, IDEV_SLT_VOLUME_TITLE )
  68. {
  69. AUTO_CURSOR Cursor;
  70. //
  71. // Make sure everything constructed OK
  72. //
  73. if ( QueryError() != NERR_Success )
  74. return;
  75. //
  76. // Set the text of the list box title
  77. //
  78. DWORD err;
  79. NLS_STR nlsServer;
  80. LOCATION Loc( pszServerName );
  81. RESOURCE_STR nlsTitle( IDS_VOLUMES_LB_TITLE_TEXT );
  82. if ( ((err = nlsTitle.QueryError()) != NERR_Success ) ||
  83. ((err = _sltVolumeTitle.QueryError()) != NERR_Success ) ||
  84. ((err = nlsServer.QueryError()) != NERR_Success ) ||
  85. ((err = Loc.QueryDisplayName( &nlsServer )) != NERR_Success ) ||
  86. ((err = nlsTitle.InsertParams( nlsServer )) != NERR_Success ))
  87. {
  88. ReportError( err );
  89. return;
  90. }
  91. _sltVolumeTitle.SetText( nlsTitle );
  92. err = Refresh();
  93. if ( err != NO_ERROR )
  94. {
  95. ReportError( err );
  96. return;
  97. }
  98. //
  99. // If there are not items then tell the user that there are no
  100. // items to delete
  101. //
  102. if ( QueryLBVolumes()->QueryCount() == 0 )
  103. {
  104. ::MsgPopup( this, IDS_NO_VOLUMES, MPSEV_INFO );
  105. ReportError( ERROR_ALREADY_REPORTED );
  106. return;
  107. }
  108. //
  109. // If the current selection is a directory set the initial
  110. // selection to the item that matches this directory path.
  111. //
  112. if ( !fIsFile )
  113. {
  114. if ( (err = SelectVolumeItem( pszPath ) ) != NERR_Success )
  115. {
  116. ReportError( err );
  117. return;
  118. }
  119. }
  120. ResetControls();
  121. }
  122. /*******************************************************************
  123. NAME: VOLUME_EDIT_DIALOG::ResetControls
  124. SYNOPSIS: Enable/Disable/MakeDefault the push buttons according
  125. to whether there are items in the listbox
  126. ENTRY:
  127. EXIT:
  128. RETURNS:
  129. NOTES:
  130. HISTORY:
  131. NarenG 11/18/92 Modified for AFPMGR
  132. ********************************************************************/
  133. VOID VOLUME_EDIT_DIALOG::ResetControls( VOID )
  134. {
  135. INT nCount = QueryLBVolumes()->QuerySelCount();
  136. //
  137. // If there was no initial selection, then simply select the first item
  138. //
  139. if ( nCount == 0 )
  140. {
  141. QueryLBVolumes()->SelectItem( 0 );
  142. }
  143. QueryLBVolumes()->ClaimFocus();
  144. }
  145. /*******************************************************************
  146. NAME: VOLUME_EDIT_DIALOG::OnCommand
  147. SYNOPSIS: Handle all push buttons commands
  148. ENTRY: event - the CONTROL_EVENT that occurred
  149. EXIT:
  150. RETURNS:
  151. NOTES:
  152. HISTORY:
  153. NarenG 11/18/92 Modified for AFPMGR
  154. ********************************************************************/
  155. BOOL VOLUME_EDIT_DIALOG::OnCommand( const CONTROL_EVENT &event )
  156. {
  157. switch ( event.QueryCid() )
  158. {
  159. case IDEV_PB_VOL_INFO:
  160. return( OnVolumeInfo() );
  161. default:
  162. return VIEW_VOLUMES_DIALOG_BASE::OnCommand( event );
  163. }
  164. }
  165. /*******************************************************************
  166. NAME: VOLUME_EDIT_DIALOG::OnVolumeInfo
  167. SYNOPSIS: Called when the "Properties" button is pressed.
  168. Will pop up a dialog showing the properties of the
  169. selected volume.
  170. ENTRY:
  171. EXIT:
  172. RETURNS:
  173. NOTES:
  174. HISTORY:
  175. NarenG 11/18/92 Modified for AFPMGR
  176. ********************************************************************/
  177. BOOL VOLUME_EDIT_DIALOG::OnVolumeInfo( VOID )
  178. {
  179. AUTO_CURSOR Cursor;
  180. INT nCount = QueryLBVolumes()->QuerySelCount();
  181. if ( nCount == 0 )
  182. {
  183. return FALSE;
  184. }
  185. DWORD err = NO_ERROR;
  186. VIEW_VOLUMES_LISTBOX *plbVolume = QueryLBVolumes();
  187. VIEW_VOLUMES_LBI *pvlbi = plbVolume->QueryItem();
  188. VOLUME_PROPERTIES_DIALOG *pDlg = new VOLUME_PROPERTIES_DIALOG(
  189. QueryHwnd(),
  190. _hServer,
  191. pvlbi->QueryVolumeName(),
  192. NULL,
  193. FALSE );
  194. if ( ( pDlg == NULL )
  195. || ((err = pDlg->QueryError()) != NERR_Success )
  196. || ((err = pDlg->Process()) != NERR_Success )
  197. )
  198. {
  199. err = err ? err : ERROR_NOT_ENOUGH_MEMORY;
  200. }
  201. delete pDlg;
  202. pDlg = NULL;
  203. if ( err != NO_ERROR )
  204. {
  205. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  206. if ( ( err = Refresh() ) != NO_ERROR )
  207. {
  208. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  209. return FALSE;
  210. }
  211. if ( QueryLBVolumes()->QueryCount() > 0 )
  212. {
  213. QueryLBVolumes()->SelectItem( 0 );
  214. QueryLBVolumes()->ClaimFocus();
  215. }
  216. else
  217. {
  218. _pbVolumeInfo.Enable( FALSE );
  219. _pbClose.ClaimFocus();
  220. }
  221. }
  222. return TRUE;
  223. }
  224. /*******************************************************************
  225. NAME: VOLUME_EDIT_DIALOG::OnVolumeLbDblClk
  226. SYNOPSIS: This is called when the user double clicks on a volume
  227. in the listbox. Will pop up a dialog showing the
  228. properties of the selected volume.
  229. ENTRY:
  230. EXIT:
  231. RETURNS:
  232. NOTES:
  233. HISTORY:
  234. NarenG 11/18/92 Modified for AFPMGR
  235. ********************************************************************/
  236. BOOL VOLUME_EDIT_DIALOG::OnVolumeLbDblClk( VOID )
  237. {
  238. return OnVolumeInfo();
  239. }
  240. /*******************************************************************
  241. NAME: VOLUME_EDIT_DIALOG::QueryHelpContext
  242. SYNOPSIS: Query the help context of the dialog
  243. ENTRY:
  244. EXIT:
  245. RETURNS: Return the help context of the dialog
  246. NOTES:
  247. HISTORY:
  248. NarenG 11/18/92 Modified for AFPMGR
  249. ********************************************************************/
  250. ULONG VOLUME_EDIT_DIALOG::QueryHelpContext( VOID )
  251. {
  252. return HC_VOLUME_EDIT_DIALOG;
  253. }