双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

C++代码转为C#

东莞寻香苑 东莞寻香苑 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
At offset 24 (0x18) after the end of the DEVMODE structure, there is a byte that directly controls this setting.
So, you need only punch the right value into the right place, at the right time. You'll want to make the change to the application-global DEVMODE right before printing. I decided to put it in the easily-accessible OnPreparePrinting function of my View class.

BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
PRINTDLG rPD;
BOOL fRet= AfxGetApp()->GetPrinterDeviceDefaults( &rPD );

LPDEVMODE pDM= (LPDEVMODE)::GlobalLock( rPD.hDevMode );

PBYTE pbDriverData= (PBYTE)(((BYTE *)pDM)+(pDM->dmSize));// right after the end

pbDriverData[24]= 2; // set to 4-up (1=2-up, 3=6-up, etc.)

::GlobalUnlock( rPD.hDevMode );

// default handling (as added by the ClassWizard)
return( DoPreparePrinting(pInfo) );
}

主要是这句:
PBYTE pbDriverData= (PBYTE)(((BYTE *)pDM)+(pDM->dmSize));
...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
东莞寻香苑
C# 111,129 成员 642,540 内容