/////////////////////////////////////////////////////////////////////////////// // // Method: CreateRightsReport // Description: Generates the report file. // Parameters: None. // Returns: S_OK - The file was written without incident. // E_FAIL - The object needs wasn't fully initialized before calling. // /////////////////////////////////////////////////////////////////////////////// HRESULT CRightsReporter::CreateRightsReport() { HRESULT hr = S_OK; // Check for initialization conditions. if ((m_pLicenseQuery == NULL) || (m_KIDStrings == NULL) || (m_pFile == NULL)) { hr = E_FAIL; } // Write the header to the output file. if (SUCCEEDED(hr)) { hr = WriteReportHeader(); } // Loop through the KIDs, getting and reporting rights for each. for (int i = 0; i < m_NumKIDs; i++) { // Write a header for the KID. fwprintf(m_pFile, L"****************************************"); fwprintf(m_pFile, L"**********\n"); fwprintf(m_pFile, L"* KID : %s\n", m_KIDStrings[i]); fwprintf(m_pFile, L"****************************************"); fwprintf(m_pFile, L"**********\n"); // Get the "is allowed" rights. hr = GetRightsForKID(m_KIDStrings[i]); if (FAILED(hr)) { break; } // Get the "license state" rights. hr = GetDetailedRightsForKID(m_KIDStrings[i]); if (FAILED(hr)) { break; } // Spacing. fwprintf(m_pFile, L"\n"); } if ((FAILED(hr)) && (m_pFile != NULL)) { fwprintf(m_pFile, L"An error occurred while getting rights.\n"); } return hr; }
/***************************************************************** * * method :void CEasyReport::Start(void) * * parameters : none * * returns : * * description: Start the report generation. Create all the fonts, etc * Try and get the printer device context, If no printer is set up as * the default printer on the system, create a screen device context. * ****************************************************************/ void CEasyReport::Start() { ASSERT( m_PrinterDC == NULL ); DoCleanup(); // set up a print date .. CTime aNow = CTime::GetCurrentTime(); m_ReportDate.Format("Date: %2d/%2d/%4d", aNow.GetMonth(), aNow.GetDay(), aNow.GetYear()); // NOTE: The following is most certainly not correct if there is // no default printer defined ! If you do not have ANY printer, then // you might install a Fax printer (eg Microsoft Fax or Bitware etc) CPrintDialog aPD(false); if(aPD.GetDefaults()) { m_PrinterDC = aPD.m_pd.hDC; } else { m_PrinterDC = ::GetDC(NULL); // get the screen device context } //::SetMapMode(m_PrinterDC, MM_ANISOTROPIC); //::SetWindowExtEx( m_PrinterDC, 254,254,NULL); //::SetViewportExtEx(m_PrinterDC, GetDeviceCaps(m_PrinterDC,LOGPIXELSX),GetDeviceCaps(m_PrinterDC,LOGPIXELSY),NULL); SetMapMode( m_PrinterDC, MM_LOMETRIC); SetupTextStyles( m_PrinterDC ); m_DataTop = m_TopMargin; m_PageCount = 0; m_CurPage = 0; CRect aRect; // Write the report header... if( m_ReportHdrHt > 0 ) { aRect.SetRect(m_LeftMargin, m_TopMargin, m_PageWidth - m_RightMargin,m_TopMargin + m_ReportHdrHt ); aRect.bottom = aRect.top + m_ReportHdrHt; WriteReportHeader(aRect); m_DataTop += m_ReportHdrHt; } if( m_PageHdrHt > 0) { aRect.SetRect(m_LeftMargin, m_DataTop, m_PageWidth - m_RightMargin, m_DataTop + m_PageHdrHt); WritePageHeader(aRect); m_DataTop += m_PageHdrHt; } }