获取默认打印机纸张的设置
2006-08-15 17:32
323 查看
CPrintDialog dlg(FALSE);
if (!dlg.GetDefaults())
AfxMessageBox(_T("You have no default printer!"));
else
...{
// attach to the DC we were given
CDC dc;
dc.Attach(dlg.m_pd.hDC);
// ask for the measurements
int nHorz = dc.GetDeviceCaps(LOGPIXELSX);
int nVert = dc.GetDeviceCaps(LOGPIXELSY);
// almost always the same in both directions, but sometimes not!
/**//*CString str;
if (nHorz == nVert)
str.Format(_T("Your printer supports %d pixels per inch"), nHorz);
else
str.Format(_T("Your printer supports %d pixels per inch ")
_T("horizontal resolution, and %d pixels per inch vertical ")
_T("resolution"), nHorz, nVert);
*/
// tell the user
this->m_PageWidth = (float) dc.GetDeviceCaps(PHYSICALWIDTH)/nHorz;
this->m_PageHeight = (float) dc.GetDeviceCaps(PHYSICALHEIGHT)/nVert;
/**//*
AfxMessageBox(str);
str.Format(_T("实际可打印的区域 width:%f height:%f"),this->m_PageWidth,this->m_PageHeight);
AfxMessageBox(str);
*/
this->m_MarginLeft = (float) dc.GetDeviceCaps(PHYSICALOFFSETX)/nHorz;
this->m_MarginTop = (float) dc.GetDeviceCaps(PHYSICALOFFSETY)/nVert;
/**//*str.Format(_T("可打印区的水平/垂直偏移 width:%f height:%f"),this->m_MarginLeft,this->m_MarginTop);
AfxMessageBox(str);
*/
this->m_PageActWidth = (float) dc.GetDeviceCaps(HORZRES)/nHorz;
this->m_PageActHeight = (float) dc.GetDeviceCaps(VERTRES)/nVert;
/**//*str.Format(_T("纸张大小 width:%f height:%f"),this->m_PageActWidth,this->m_PageActHeight);
AfxMessageBox(str);
*/
this->m_MarginRight = this->m_PageWidth - this->m_MarginLeft - this->m_PageActWidth;
this->m_MarginBottom = this->m_PageHeight- this->m_MarginTop - this->m_PageActHeight;
/**//*
str.Format(_T("纸张右边距,下边距 width:%f height:%f"),this->m_MarginRight,this->m_MarginBottom);
AfxMessageBox(str);
*/
相关文章推荐
- VB6 获取和设置默认打印机
- 打印技术之获取及设置系统默认打印机
- 【打印技术01】获取及设置系统默认打印机
- C#获取本地打印机列表,并将指定打印机设置为默认打印机
- 获取设置本地当前默认打印机
- 利用ActiveX实现web页面设置本地默认打印机、纸张大小
- C#获取本地打印机列表,并将指定打印机设置为默认打印机
- 获取所有打印机,设置默认打印机,获取默认打印机
- C#获取和设置系统的默认打印机,使用API
- 【VC++技术杂谈002】打印技术之获取及设置系统默认打印机
- C#获取本地打印机列表,并将指定打印机设置为默认打印机
- 设置非默认打印机纸张的问题
- C#获取本地打印机列表,并将指定打印机设置为默认打印机
- VB6 获取和设置默认打印机
- C#获取本地打印机列表,并将指定打印机设置为默认打印机
- 获取和设置默认打印机
- VB6 获取和设置默认打印机
- 浏览器如何设置默认打印机的纸张类型
- Win7系统设置自动切换默认打印机的方法
- C#调用windows api控制打印机 状态获取 打印 自定义纸张 完整版