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.

218 lines
4.3 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved
  3. Module Name:
  4. Note.cpp
  5. Abstract:
  6. Main module file - defines the overall COM server.
  7. Author:
  8. Rohde Wakefield [rohde] 04-Mar-1997
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CRecallNote dialog
  14. CRecallNote::CRecallNote( IFsaRecallNotifyServer * pRecall, CWnd * pParent )
  15. : CDialog( CRecallNote::IDD, pParent )
  16. {
  17. //{{AFX_DATA_INIT(CRecallNote)
  18. //}}AFX_DATA_INIT
  19. TRACEFNHR( "CRecallNote::CRecallNote" );
  20. RecApp->LockApp( );
  21. try {
  22. //
  23. // Store the interface pointer back to the recall object
  24. //
  25. m_pRecall = pRecall;
  26. RecAffirmHr( pRecall->GetIdentifier( &m_RecallId ) );
  27. //
  28. // Get the file size and its name
  29. //
  30. RecAffirmHr( pRecall->GetSize( &m_Size ) );
  31. RecComString pathName, drive;
  32. RecAffirmHr( pRecall->GetPath( &pathName, 0 ) );
  33. #if 0
  34. CComPtr<IFsaResource> pResource;
  35. RecAffirmHr( pRecall->GetResource( &pResource ) );
  36. RecAffirmHr( pResource->GetPath( &drive, 0 ) );
  37. m_Name.Format( TEXT( "%.1ls:%ls" ), drive, pathName );
  38. #else
  39. m_Name = pathName;
  40. #endif
  41. //
  42. // Create the dialog
  43. //
  44. Create( CRecallNote::IDD, pParent );
  45. } RecCatch( hrRet );
  46. m_hrCreate = hrRet;
  47. m_bCancelled = FALSE;
  48. }
  49. CRecallNote::~CRecallNote( )
  50. {
  51. TRACEFN( "CRecallNote::~CRecallNote" );
  52. //
  53. // Remove the lock count on the app
  54. //
  55. RecApp->UnlockApp( );
  56. CDialog::~CDialog( );
  57. }
  58. void CRecallNote::DoDataExchange(CDataExchange* pDX)
  59. {
  60. TRACEFN( "CRecallNote::DoDataExchange" );
  61. CDialog::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CRecallNote)
  63. DDX_Control(pDX, IDC_FILENAME, m_FileName);
  64. DDX_Control(pDX, IDC_ANIMATION, m_Animation);
  65. //}}AFX_DATA_MAP
  66. }
  67. BEGIN_MESSAGE_MAP(CRecallNote, CDialog)
  68. //{{AFX_MSG_MAP(CRecallNote)
  69. ON_WM_CLOSE()
  70. ON_WM_TIMER()
  71. //}}AFX_MSG_MAP
  72. END_MESSAGE_MAP()
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CRecallNote message handlers
  75. BOOL CRecallNote::OnInitDialog()
  76. {
  77. TRACEFNBOOL( "CRecallNote::OnInitDialog" );
  78. CDialog::OnInitDialog();
  79. boolRet = TRUE;
  80. CString fileName;
  81. // Set a timer to delay displaying myself in case the
  82. // recall is quick and the dialog is unnecessary
  83. SetTimer( 2, RSRECALL_TIME_DELAY_DISPLAY * 1000, 0 );
  84. //
  85. // Initialize all the text
  86. //
  87. int pos = m_Name.ReverseFind( TEXT( '\\' ) );
  88. if( pos >= 0 ) {
  89. fileName = m_Name.Mid( pos + 1 );
  90. } else {
  91. fileName = m_Name;
  92. }
  93. m_FileName.SetWindowText( fileName );
  94. //
  95. // Set up the icon for the dialog (big and small)
  96. //
  97. m_hIcon = RecApp->LoadIcon( IDR_MAINFRAME );
  98. SetIcon( m_hIcon, TRUE );
  99. SetIcon( m_hIcon, FALSE );
  100. //
  101. // Start up the animation
  102. //
  103. m_Animation.Open( IDR_RECALL_ANIM );
  104. m_Animation.Play( 0, -1, -1 );
  105. return( boolRet );
  106. }
  107. void CRecallNote::OnClose()
  108. {
  109. TRACEFNHR( "CRecallNote::OnClose" );
  110. hrRet = RecApp->RemoveRecall( m_pRecall );
  111. //
  112. // If we failed to find and remove the recall from our list,
  113. // destroy the window anyway.
  114. //
  115. if( hrRet != S_OK ) {
  116. DestroyWindow( );
  117. }
  118. }
  119. void CRecallNote::PostNcDestroy()
  120. {
  121. TRACEFNHR( "CRecallNote::PostNcDestroy" );
  122. //
  123. // Delete the object (CDialogs don't automatically do this)
  124. //
  125. CDialog::PostNcDestroy();
  126. delete( this );
  127. }
  128. void CRecallNote::OnTimer(UINT nIDEvent)
  129. {
  130. TRACEFNHR( "CRecallNote::OnTimer" );
  131. // Kill the timer so we don't get called again
  132. KillTimer( nIDEvent );
  133. // Display the window
  134. EnableWindow( );
  135. ShowWindow( SW_SHOW );
  136. SetForegroundWindow( );
  137. CDialog::OnTimer( nIDEvent );
  138. }
  139. void CRecallNote::OnCancel()
  140. {
  141. TRACEFNHR( "CRecallNote::OnCancel" );
  142. // Use a local pointer because m_pRecall may not be valid after the call to RemoveRecall
  143. CComPtr<IFsaRecallNotifyServer> pRecall = m_pRecall;
  144. // Remove recall from queue.
  145. // This ensure that the popup is closed and the recall is removed even if there are
  146. // connection problems with FSA
  147. RecApp->RemoveRecall( pRecall );
  148. // The object might be already destroyed here but it shouldn't matter
  149. // because we use only local data
  150. pRecall->Cancel( );
  151. }