🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7869

Re: Printer properties

#7869
From: Bob Gonder
Date: Fri, 17 Dec 2004 18:31
79 lines
3460 bytes
Deepak Mishra wrote:

>The PRINTDLG structure size passed to PrintDlg is wrong.
>The correct one is 66 not 68 returned by sizeof(PRINTDLG) operator.
>
>Writing 66 instead of using sizeof might be a working solution, but I don't think that's a good idea. 
>
>Not able to find the reason.

At the top of COMMDLG.H is the following line
#pragma option push -b -a8 -pc -A- /*P_O_Push*/
which should set the packing to 8 bytes.
But, several lines later, is
#include <pshpack1.h>         /* Assume byte packing throughout */
which should result in byte packing.

Take a look at the many   #if defined    in pshpack1, and make sure
your application doesn't accidentally set incorrect #defines

The following program compiles and executes correctly.
PrintDlg.c:

#include <windows.h>
#include <commdlg.h>

#pragma	argsused
int _stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine, int nCmdShow)
{
	PRINTDLG pd;
	DOCINFO	lpdi;
	HDC	printerDC;

	pd.lStructSize = sizeof(PRINTDLG); 
	pd.hDevMode = (HANDLE) NULL; 
	pd.hDevNames = (HANDLE) NULL; 
	pd.Flags = PD_RETURNDC|PD_USEDEVMODECOPIESANDCOLLATE;
	pd.hwndOwner = 0; 
	pd.hDC = (HDC) NULL; 
	pd.nFromPage = 1; 
	pd.nToPage = 1; 
	pd.nMinPage = 0; 
	pd.nMaxPage = 0; 
	pd.nCopies = 1; 
	pd.hInstance = (HANDLE) NULL; 
	pd.lCustData = 0L; 
	pd.lpfnPrintHook = (LPPRINTHOOKPROC) NULL; 
	pd.lpfnSetupHook = (LPSETUPHOOKPROC) NULL; 
	pd.lpPrintTemplateName = (LPSTR) NULL; 
	pd.lpSetupTemplateName = (LPSTR)  NULL; 
	pd.hPrintTemplate = (HANDLE) NULL; 
	pd.hSetupTemplate = (HANDLE) NULL;

	if( IDOK == PrintDlg(&pd) )
	{	MessageBox( 0, "ID_OK", "Print Dialog",
MB_OK|MB_ICONINFORMATION|MB_TOPMOST );
	}else{
		MessageBox( 0, "Not ID_OK", "Print Dialog",
MB_OK|MB_ICONINFORMATION|MB_TOPMOST );
	};
	if( 0==(printerDC=pd.hDC) )
	{
		MessageBox( 0, "DC Not Ok", "Print Dialog",
MB_OK|MB_ICONINFORMATION|MB_TOPMOST );
	}else{
		MessageBox( 0, "DC Ok", "Print Dialog",
MB_OK|MB_ICONINFORMATION|MB_TOPMOST );
		DeleteDC(printerDC);
	};
	return 0;
}

Compiled with (might be more than needed, but it's what I use)
bcc32 -6 -a1 -C -d -g50 -K -O2 -Oi -Os -Ov -Q -VI- -tW  -vi -x-
-I$(INCLUDEPATH) -L$(LIBPATH) -P -M -v /c

Linked with
ilink32 /aa/v/x/c/C/Gn/P-/Twe/L$(LIBPATH) c0w32.obj+$(FILE).obj,
$(FILE), , import32.lib+cw32.lib
Technical Details
Message-ID: <vq46s0dvqr961dd3pe6vgq6fqsvq4p1sv5@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41bfe84c$1@newsgroups.borland.com> <6ro0s0pgsjn6kr7lnhkb68gtfkr2g0glm2@4ax.com> <41c162f7@newsgroups.borland.com> <r2c3s0ta1bn5u16c3cmv5fi5nf3bfn09cr@4ax.com> <41c28262$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6620db7697e43cb9
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Printer properties
Date: Fri, 17 Dec 2004 10:31:08 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <vq46s0dvqr961dd3pe6vgq6fqsvq4p1sv5@4ax.com>
References: <41bfe84c$1@newsgroups.borland.com> <6ro0s0pgsjn6kr7lnhkb68gtfkr2g0glm2@4ax.com> <41c162f7@newsgroups.borland.com> <r2c3s0ta1bn5u16c3cmv5fi5nf3bfn09cr@4ax.com> <41c28262$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.77.147.66
X-Trace: newsgroups.borland.com 1103308266 67.77.147.66 (17 Dec 2004 10:31:06 -0800)
Lines: 82
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail