comp.lang.ada
 help / color / mirror / Atom feed
From: David Botton <David@Botton.com>
Subject: Re: Prints with the Win32Ada Binding
Date: 1999/04/25
Date: 1999-04-25T21:04:54+00:00	[thread overview]
Message-ID: <37238373.A2E5F778@Botton.com> (raw)
In-Reply-To: CtFT2.5336$fz.1841649@WReNphoon2

There is a bug in the binding.

Windows is very particular about the lStructSize parameter since it uses
it to version the calls. The value returned from (PRINTDLGW'Size + 1) /
System.Storage_Unit is 68 and Windows expects 66 (as a sizeof(PRINTDLGW)
in VC indicates). When I have a chance I'll hunt down where the bug is
in the binding and report it. In the interim hard code 66 and hope for
the best :)

David Botton

-- SAMPLE TEST CODE THAT WORKS

with Ada.Text_IO; use Ada.Text_IO;
with System;

with Interfaces.C; use Interfaces.C;

with Win32.Commdlg;

with Get_Last_Error;

procedure PrintDlg is
   use type Win32.BOOL;

   bIsSuccess        : Win32.BOOL;
   Print_Struct      : aliased Win32.Commdlg.PRINTDLG;

begin
   put_line( Integer'IMAGE((Win32.Commdlg.PRINTDLG'Size +
1)/System.Storage_Unit));
   -- a sizeof(PRINTDLGA) in VC indicates 66 no 68 which is what shows
up
   -- PRINTDLGA and PRINTDLGW are both sized as 66 bytes in the C Win32
API.

   Print_Struct.lStructSize := 66; --(Win32.Commdlg.PRINTDLG'Size +
1)/System.Storage_Unit;
   Print_Struct.hwndOwner   := System.Null_Address;
   Print_Struct.hDevMode    := System.Null_Address;
   Print_Struct.hDevNames   := System.Null_Address;
   Print_Struct.nFromPage   := 1;
   Print_Struct.nToPage     := 1;
   Print_Struct.nMinPage    := 1;
   Print_Struct.nMaxPage    := 1;
   Print_Struct.nCopies     := 1;
   Print_Struct.Flags       := Win32.Commdlg.PD_ALLPAGES or
                              Win32.Commdlg.PD_COLLATE  or
                              Win32.Commdlg.PD_RETURNDC;

   bIsSuccess :=
Win32.commdlg.PrintDlg_Func(Print_Struct'Unchecked_Access);

   if bIsSuccess = Win32.False then
      Put_Line("NO GO!");
   else
       Put_Line("Success!");
   end if;

end PrintDlg;


Shawn Barber wrote:
> 
>    I have my call to PrintDlg_Func setup very close to your example David. I
> still could get the Print
> Dialog to display so I looked at the last error and I'm getting a "Class
> does not exist" error message.
> So I am again out of ideas.




  reply	other threads:[~1999-04-25  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-21  0:00 Prints with the Win32Ada Binding Shawn Barber
1999-04-21  0:00 ` Martin C. Carlisle
1999-04-21  0:00 ` David Botton
1999-04-22  0:00 ` Shawn Barber
1999-04-25  0:00   ` David Botton [this message]
1999-04-23  0:00 ` Shawn Barber
1999-04-23  0:00   ` Martin C. Carlisle
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox