我没分了,请无偿帮我解决自定义纸张的问题,Help(0分)

  • 主题发起人 主题发起人 Loway
  • 开始时间 开始时间
L

Loway

Unregistered / Unconfirmed
GUEST, unregistred user!
以下自定义纸张的代码在Win98、ME中正常,在2000中没有任何反应,何故?如何解决?
请指教
void __fastcall SetPaper( int PW, int PL, bool PO )
{
char Device[256];
char Driver[256];
char Port[32];
THandle hDMode;
PDevMode pDMode;

Printer()->GetPrinter( Device, Driver, Port, hDMode );

if( hDMode != 0)
{
pDMode = ( PDevMode )GlobalLock( (void*)hDMode );
if( pDMode != NULL )
{
pDMode->dmPaperSize = 0;
pDMode->dmPaperLength = PL;
pDMode->dmPaperWidth = PW;
pDMode->dmOrientation = PO ? DMORIENT_PORTRAIT : DMORIENT_LANDSCAPE;
pDMode->dmFields = pDMode->dmFields | DM_PAPERSIZE;
pDMode->dmFields = pDMode->dmFields | DM_PAPERLENGTH;
pDMode->dmFields = pDMode->dmFields | DM_PAPERWIDTH;
pDMode->dmFields = pDMode->dmFields | DM_ORIENTATION;
}
GlobalUnlock( (void*)hDMode );
}
}
 
好像2000中不支持自定义纸张
 
给你个delphi代码,我的程序中使用的,for 2000
procedure TFormMain.SetPrinterProp;
var oldhandle: THandle;
olddevmode: ^TDeviceMode;
ADev, ADri, APort: PChar;
tempform: TFormMDI;
begin

tempform := TFormMDI( ActiveMDIChild);

GetMem( ADev, 1024);
GetMem( ADri, 1024);
GetMem( APort, 1024);
Printer.GetPrinter( ADev, ADri, APort, oldhandle);
olddevmode := GlobalLock( oldhandle);

olddevmode^.dmFields := olddevmode^.dmFields or DM_PAPERSIZE;
olddevmode^.dmFields := olddevmode^.dmFields or DM_PAPERLENGTH;
olddevmode^.dmFields := olddevmode^.dmFields or DM_PAPERWIDTH;
olddevmode^.dmPaperWidth := trunc( tempform.PrintPage.Width * 10);
olddevmode^.dmPaperLength := trunc( tempform.PrintPage.Height * 10);
olddevmode^.dmPaperSize:=DMPAPER_USER;

GlobalUnLock( oldhandle);
Printer.SetPrinter( ADev, ADri, APort, oldhandle);
//DEVMODE

FreeMem( ADev);
FreeMem( ADri);
FreeMem( APort);
end;

 
后退
顶部