Re: Linked win32lib structures

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Tue, 7 Jan 2003 08:25:51 +1100, Derek Parnell
<ddparnell at bigpond.com> wrote:

>>I've just about figured out how to read linked structures:
>>
>>devmode=3Dfetch(psd,PAGESETUPDLG_pDevMode)
>>fetch( devmode, DEVMODE_dmOrientation ),
>>
>
>Yes, this is correct.
Yeah, I figured/assumed that must be the right way, cos it works.
Thanks for confirming I'm on the right track
>The "pDevMode" fetch will get the address of the
>DEVMODE structure. What happens is that the PAGESETUPDLG structure =
contains
>a handle. A handle is the address of an address that points to the =
DEVMODE.
>So if you fetch the "hDevMode" field, you get the address of the DEVMODE
>structure's address.
>
>>but initialising them has lost me. After:
>>
>>psd =3D acquire_mem( 0, SIZEOF_PAGESETUPDLG )
>>devmode =3D acquire_mem ( 0, SIZEOF_DEVMODE )
>>store( devmode, DEVMODE_dmOrientation, 2 ) -- set to landscape
>>store( devmode, DEVMODE_dmPaperSize, 11 ) -- set to A5
>>
>>I had hoped something vaguely like this would do:
>>store( psd, PAGESETUPDLG_pDevMode, devmode)
>
>This should work too. The 'store' as written above, first grabs an =
address
>to a 4-byte area and saves the 'devmode' value there, then stores that
>address into the PAGESETUPDLG structure.
>
>
>>Everything I've tried, windows just quietly and firmly returns 0.
>
>When you say "windows...returns" what function are you calling to get =
that
>return value?

	ok =3D w32Func( xPageSetupDlg, { psd } )

If I comment out that store( psd, PAGESETUPDLG_pDevMode, devmode),
the usual dialog pops up; when I put it back in, it just returns
false. No dialog, no usual wait, immediate return of 0.

I recon I'm putting a handle in a pointer or a pointer in a handle;
and topping it with not really knowing what I'm taking about blink
I also tried (with same results) this:
>>store( psd, PAGESETUPDLG_hDevMode, devmode)

I suppose I should post my wrap of devmode(it is my very first attempt
at this afterall); maybe I just assume it is right because it returns
the right results, however there may be an obvious flaw in there:

typedef struct _devicemode {    /* dvmd */  =20
   TCHAR  dmDeviceName[32];
    WORD   dmSpecVersion;
    WORD   dmDriverVersion;=20
    WORD   dmSize;
    WORD   dmDriverExtra;=20
    DWORD  dmFields;
    short  dmOrientation;
    short  dmPaperSize;
    short  dmPaperLength;
    short  dmPaperWidth;
    short  dmScale;
    short  dmCopies;
    short  dmDefaultSource;
    short  dmPrintQuality;
    short  dmColor;
    short  dmDuplex;
    short  dmYResolution;
    short  dmTTOption;
    short  dmCollate;
    TCHAR  dmFormName[32];
    WORD   dmUnusedPadding;
    USHORT dmBitsPerPel;
    DWORD  dmPelsWidth;
    DWORD  dmPelsHeight;
    DWORD  dmDisplayFlags;
    DWORD  dmDisplayFrequency;
} DEVMODE;

	DEVMODE_dmDeviceName 		=3D allot( {32,Byte} ),
	DEVMODE_dmSpecVersion		=3D allot( Word ),
	DEVMODE_dmDriverVersion		=3D allot( Word ),
	DEVMODE_dmSize				=3D allot( Word ),   =20
	DEVMODE_dmDriverExtra			=3D allot( Word ),
	DEVMODE_dmFields				=3D allot( Long ),=09
	DEVMODE_dmOrientation			=3D allot( Word ),=09
	DEVMODE_dmPaperSize			=3D allot( Word ),
	DEVMODE_dmPaperLength		=3D allot( Word ),=09
	DEVMODE_dmPaperWidth			=3D allot( Word ),   =20
	DEVMODE_dmScale				=3D allot( Word ),
	DEVMODE_dmCopies				=3D allot( Word ),   =20
	DEVMODE_dmDefaultSource		=3D allot( Word ),
	DEVMODE_dmPrintQuality			=3D allot( Word ),	=20
	DEVMODE_dmColor				=3D allot( Word ),   =20
	DEVMODE_dmDuplex				=3D allot( Word ),
	DEVMODE_dmYResolution			=3D allot( Word ),=09
	DEVMODE_dmTTOption			=3D allot( Word ),	=20
	DEVMODE_dmCollate				=3D allot( Word ),
	DEVMODE_dmFormName			=3D allot( {32,Byte} ),
	DEVMODE_dmUnusedPadding		=3D allot( Word ),
	DEVMODE_dmBitsPerPel			=3D allot( Word ),   =20
	DEVMODE_dmPelsWidth			=3D allot( Long ),	 =20
	DEVMODE_dmPelsHeight			=3D allot( Long ),
	DEVMODE_dmDisplayFlags		=3D allot( Long ),	 =20
	DEVMODE_dmDisplayFrequency	=3D allot( Long ),
	SIZEOF_DEVMODE				=3D allotted_size(),

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu