void CWordPadApp::NotifyPrinterChanged(BOOL bUpdatePrinterSelection) { if (bUpdatePrinterSelection) UpdatePrinterSelection(FALSE); POSITION pos = m_listPrinterNotify.GetHeadPosition(); while (pos != NULL) { HWND hWnd = m_listPrinterNotify.GetNext(pos); ::SendMessage(hWnd, m_nPrinterChangedMsg, 0, 0); } }
BOOL CWinApp::GetPrinterDeviceDefaults( PRINTDLG *pPrintDlg ) /***********************************************************/ { UpdatePrinterSelection( FALSE ); if( m_hDevMode == NULL || m_hDevNames == NULL ) { return( FALSE ); } pPrintDlg->hDevMode = m_hDevMode; pPrintDlg->hDevNames = m_hDevNames; return( TRUE ); }
BOOL CWinApp::GetPrinterDeviceDefaults(PRINTDLG* pPrintDlg) { UpdatePrinterSelection(m_hDevNames == NULL); //force default if no current if (m_hDevNames == NULL) return FALSE; // no printer defaults pPrintDlg->hDevNames = m_hDevNames; pPrintDlg->hDevMode = m_hDevMode; ::GlobalUnlock(m_hDevNames); ::GlobalUnlock(m_hDevMode); return TRUE; }
int CWinApp::DoPrintDialog(CPrintDialog* pPD) { UpdatePrinterSelection(FALSE); pPD->m_pd.hDevMode = m_hDevMode; pPD->m_pd.hDevNames = m_hDevNames; int nResponse = pPD->DoModal(); // if OK or Cancel is selected we need to update cached devMode/Names while (nResponse != IDOK && nResponse != IDCANCEL) { switch (::CommDlgExtendedError()) { // CommDlg cannot give these errors after NULLing these handles case PDERR_PRINTERNOTFOUND: case PDERR_DNDMMISMATCH: case PDERR_DEFAULTDIFFERENT: if (pPD->m_pd.hDevNames != NULL) { ASSERT(m_hDevNames == pPD->m_pd.hDevNames); AfxGlobalFree(pPD->m_pd.hDevNames); pPD->m_pd.hDevNames = NULL; m_hDevNames = NULL; } if (pPD->m_pd.hDevMode) { ASSERT(m_hDevMode == pPD->m_pd.hDevMode); AfxGlobalFree(pPD->m_pd.hDevMode); pPD->m_pd.hDevMode = NULL; m_hDevMode = NULL; } break; default: return nResponse; // do not update cached devMode/Names } nResponse = pPD->DoModal(); } // refresh current CWinApp cache of printer device information m_hDevMode = pPD->m_pd.hDevMode; m_hDevNames = pPD->m_pd.hDevNames; return nResponse; }