Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

CPrinterList Class Reference

#include <profile.h>

Inheritance diagram for CPrinterList:

CDeviceList List of all members.

Public Member Functions

 CPrinterList ()
 ~CPrinterList ()
virtual unsigned Count ()
virtual CStringDeviceName (unsigned u)
virtual CStringDisplayName (unsigned u)
virtual void Enumerate ()
virtual BOOL IsValidDeviceName (LPCTSTR lpstr)

Private Attributes

CStringArray m_csaDeviceNames
CStringArray m_csaDisplayNames

Constructor & Destructor Documentation

CPrinterList::CPrinterList  )  [inline]
 

Definition at line 80 of file icmui/profile.h.

00080 {}

CPrinterList::~CPrinterList  )  [inline]
 

Definition at line 81 of file icmui/profile.h.

00081 {}


Member Function Documentation

virtual unsigned CPrinterList::Count  )  [inline, virtual]
 

Reimplemented from CDeviceList.

Definition at line 83 of file icmui/profile.h.

References CStringArray::Count(), and m_csaDeviceNames.

Referenced by CAllDeviceList::Enumerate(), and IsValidDeviceName().

00083 { return m_csaDeviceNames.Count(); }

virtual CString& CPrinterList::DeviceName unsigned  u  )  [inline, virtual]
 

Reimplemented from CDeviceList.

Definition at line 84 of file icmui/profile.h.

References DeviceName(), and m_csaDeviceNames.

Referenced by DeviceName(), and CAllDeviceList::Enumerate().

00084 { return m_csaDeviceNames[u]; }

virtual CString& CPrinterList::DisplayName unsigned  u  )  [inline, virtual]
 

Reimplemented from CDeviceList.

Definition at line 85 of file icmui/profile.h.

References DisplayName(), and m_csaDisplayNames.

Referenced by DisplayName(), and CAllDeviceList::Enumerate().

00085 { return m_csaDisplayNames[u]; }

void CPrinterList::Enumerate  )  [virtual]
 

Reimplemented from CDeviceList.

Definition at line 40 of file profile.cpp.

References CStringArray::Add(), BYTE, DWORD, m_csaDeviceNames, m_csaDisplayNames, NULL, and PBYTE.

Referenced by CAllDeviceList::Enumerate(), and IsValidDeviceName().

00040 { 00041 00042 #if !defined(_WIN95_) // CPrinterList::Enumetate() 00043 00044 // Enumerate all local printers 00045 00046 DWORD dwcNeeded, dwcReturned; 00047 EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 4, NULL, 0, &dwcNeeded, 00048 &dwcReturned); 00049 00050 union { 00051 PBYTE pBuff; 00052 PPRINTER_INFO_4 ppi4; 00053 }; 00054 00055 pBuff = new BYTE[dwcNeeded]; 00056 00057 while (pBuff && !EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 4, pBuff, 00058 dwcNeeded, &dwcNeeded, &dwcReturned) && 00059 GetLastError() == ERROR_MORE_DATA) { 00060 delete pBuff; 00061 pBuff = new BYTE[dwcNeeded]; 00062 } 00063 00064 if (pBuff) { 00065 00066 for (unsigned u = 0; u < dwcReturned; u++) 00067 if (CGlobals::ThisIsAColorPrinter(ppi4[u].pPrinterName)) { 00068 m_csaDeviceNames.Add(ppi4[u].pPrinterName); 00069 m_csaDisplayNames.Add(ppi4[u].pPrinterName); 00070 } 00071 00072 delete pBuff; 00073 } 00074 00075 // Now, enumerate all the connected printers 00076 00077 EnumPrinters(PRINTER_ENUM_CONNECTIONS, NULL, 4, NULL, 0, &dwcNeeded, 00078 &dwcReturned); 00079 00080 pBuff = new BYTE[dwcNeeded]; 00081 00082 while (pBuff && !EnumPrinters(PRINTER_ENUM_CONNECTIONS, NULL, 4, pBuff, 00083 dwcNeeded, &dwcNeeded, &dwcReturned) && 00084 GetLastError() == ERROR_MORE_DATA) { 00085 delete pBuff; 00086 pBuff = new BYTE[dwcNeeded]; 00087 } 00088 00089 if (!pBuff) 00090 return; 00091 00092 for (unsigned u = 0; u < dwcReturned; u++) 00093 if (CGlobals::ThisIsAColorPrinter(ppi4[u].pPrinterName)) { 00094 m_csaDeviceNames.Add(ppi4[u].pPrinterName); 00095 m_csaDisplayNames.Add(ppi4[u].pPrinterName); 00096 } 00097 00098 delete pBuff; 00099 00100 #else 00101 00102 // Enumerate all local printers 00103 00104 DWORD dwcNeeded, dwcReturned; 00105 EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5, NULL, 0, &dwcNeeded, 00106 &dwcReturned); 00107 00108 union { 00109 PBYTE pBuff; 00110 PPRINTER_INFO_5 ppi5; 00111 }; 00112 00113 pBuff = new BYTE[dwcNeeded]; 00114 00115 while (pBuff && !EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5, pBuff, 00116 dwcNeeded, &dwcNeeded, &dwcReturned) && 00117 GetLastError() == ERROR_MORE_DATA) { 00118 delete pBuff; 00119 pBuff = new BYTE[dwcNeeded]; 00120 } 00121 00122 if (pBuff) { 00123 00124 for (unsigned u = 0; u < dwcReturned; u++) { 00125 if (CGlobals::ThisIsAColorPrinter(ppi5[u].pPrinterName)) { 00126 m_csaDeviceNames.Add(ppi5[u].pPrinterName); 00127 m_csaDisplayNames.Add(ppi5[u].pPrinterName); 00128 } 00129 } 00130 00131 delete pBuff; 00132 } 00133 #endif 00134 }

BOOL CPrinterList::IsValidDeviceName LPCTSTR  lpstr  )  [virtual]
 

Reimplemented from CDeviceList.

Definition at line 138 of file profile.cpp.

References BOOL, Count(), Enumerate(), FALSE, IsValidDeviceName(), and m_csaDeviceNames.

Referenced by IsValidDeviceName().

00138 { 00139 00140 if (!lpstrRef) return FALSE; 00141 00142 if (!Count()) 00143 Enumerate(); 00144 00145 for (unsigned u = 0; u < Count(); u++) 00146 if (!lstrcmpi(m_csaDeviceNames[u], lpstrRef)) 00147 break; 00148 00149 return u < Count(); 00150 }


Member Data Documentation

CStringArray CPrinterList::m_csaDeviceNames [private]
 

Definition at line 76 of file icmui/profile.h.

Referenced by Count(), DeviceName(), Enumerate(), and IsValidDeviceName().

CStringArray CPrinterList::m_csaDisplayNames [private]
 

Definition at line 77 of file icmui/profile.h.

Referenced by DisplayName(), and Enumerate().


The documentation for this class was generated from the following files:
Generated on Sat May 15 19:46:27 2004 for test by doxygen 1.3.7