comp.lang.ada
 help / color / mirror / Atom feed
* win32ada coverage
@ 2009-04-03 21:08 xiehang
  2009-04-03 22:51 ` anon
  0 siblings, 1 reply; 7+ messages in thread
From: xiehang @ 2009-04-03 21:08 UTC (permalink / raw)


I'm new to Ada, and trying to migrate a C/Win32 API program to GNAT
+win32ada, but seems win32ada lacks of some functions like:

SetWindowRgn
LoadImage

My question is, does win32ada binding has all win32 APIs? And if it
does not, is there any Win32 binding provide thin layer like it?
Further more, how tough is it to create new or update win32ada binding
to include those missing functions?

Thanks,

-Hang



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: win32ada coverage
  2009-04-03 21:08 win32ada coverage xiehang
@ 2009-04-03 22:51 ` anon
  2009-04-04  0:52   ` xiehang
  2009-04-04  6:38   ` Jerry van Dijk
  0 siblings, 2 replies; 7+ messages in thread
From: anon @ 2009-04-03 22:51 UTC (permalink / raw)


Win32Ada provides only a subset of common routines. Version 3.0 was created 
back in 1999, so any additional routines that was added in XP or Vista must 
be added to the package or Imported into your program.

Now, expanding win32Ada to include these new routines can be as easy as 
using an "pragma Import" statement but other routines may require a set of 
wrapper routines before calling the imported Win32 API.  You should be able 
to use the existing win32Ada as a guide to aid you in adding those extra API 
you need.

One suggestion, is due to the number of Win32 API you should only to add 
those routines that you need for your project.



In <785addc4-95e3-48d6-ba9f-e698d26922b5@s12g2000prc.googlegroups.com>, xiehang@gmail.com writes:
>I'm new to Ada, and trying to migrate a C/Win32 API program to GNAT
>+win32ada, but seems win32ada lacks of some functions like:
>
>SetWindowRgn
>LoadImage
>
>My question is, does win32ada binding has all win32 APIs? And if it
>does not, is there any Win32 binding provide thin layer like it?
>Further more, how tough is it to create new or update win32ada binding
>to include those missing functions?
>
>Thanks,
>
>-Hang




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: win32ada coverage
  2009-04-03 22:51 ` anon
@ 2009-04-04  0:52   ` xiehang
  2009-04-04  6:38   ` Jerry van Dijk
  1 sibling, 0 replies; 7+ messages in thread
From: xiehang @ 2009-04-04  0:52 UTC (permalink / raw)


Thanks Anon, I'm creating my own package to include those APIs for my
project.

-Hang

> Win32Ada provides only a subset of common routines. Version 3.0 was created
> back in 1999, so any additional routines that was added in XP or Vista must
> be added to the package or Imported into your program.
>
> Now, expanding win32Ada to include these new routines can be as easy as
> using an "pragma Import" statement but other routines may require a set of
> wrapper routines before calling the imported Win32 API.  You should be able
> to use the existing win32Ada as a guide to aid you in adding those extra API
> you need.
>
> One suggestion, is due to the number of Win32 API you should only to add
> those routines that you need for your project.
>
> In <785addc4-95e3-48d6-ba9f-e698d2692...@s12g2000prc.googlegroups.com>, xieh...@gmail.com writes:
> >I'm new to Ada, and trying to migrate a C/Win32 API program to GNAT
> >+win32ada, but seems win32ada lacks of some functions like:
>
> >SetWindowRgn
> >LoadImage
>
> >My question is, does win32ada binding has all win32 APIs? And if it
> >does not, is there any Win32 binding provide thin layer like it?
> >Further more, how tough is it to create new or update win32ada binding
> >to include those missing functions?
>
> >Thanks,
>
> >-Hang
>
>




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: win32ada coverage
  2009-04-03 22:51 ` anon
  2009-04-04  0:52   ` xiehang
@ 2009-04-04  6:38   ` Jerry van Dijk
  2009-04-05  4:30     ` xiehang
  1 sibling, 1 reply; 7+ messages in thread
From: Jerry van Dijk @ 2009-04-04  6:38 UTC (permalink / raw)


anon@anon.org (anon) writes:

> Win32Ada provides only a subset of common routines. Version 3.0 was created 
> back in 1999, so any additional routines that was added in XP or Vista must 
> be added to the package or Imported into your program.

Although SetWindowRgn is indeed missing from from Win32Ada (it was added with
Windows 2000), LoadImage is an alias for either LoadImageA or LoadImageW,
depending on whether you are in unicode mode or not.

-- 
--  Jerry van Dijk
--  Leiden, Holland
--
--  The early bird may get the worm, but the second mouse gets the cheese!!



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: win32ada coverage
  2009-04-04  6:38   ` Jerry van Dijk
@ 2009-04-05  4:30     ` xiehang
  2009-04-05  5:58       ` anon
  2009-04-05 10:44       ` Jerry van Dijk
  0 siblings, 2 replies; 7+ messages in thread
From: xiehang @ 2009-04-05  4:30 UTC (permalink / raw)


Yea I know the W/A trick, but the win32ada I have does not have
LoadImageA nor LoadImageW.

Does your version of win32ada have them?

-Hang

Jerry van Dijk <je...@jerryware.nl> wrote:
> a...@anon.org (anon) writes:
> > Win32Ada provides only a subset of common routines. Version 3.0 was created
> > back in 1999, so any additional routines that was added in XP or Vista must
> > be added to the package or Imported into your program.
>
> Although SetWindowRgn is indeed missing from from Win32Ada (it was added with
> Windows 2000), LoadImage is an alias for either LoadImageA or LoadImageW,
> depending on whether you are in unicode mode or not.
>
> --
> --  Jerry van Dijk
> --  Leiden, Holland
> --
> --  The early bird may get the worm, but the second mouse gets the cheese!!



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: win32ada coverage
  2009-04-05  4:30     ` xiehang
@ 2009-04-05  5:58       ` anon
  2009-04-05 10:44       ` Jerry van Dijk
  1 sibling, 0 replies; 7+ messages in thread
From: anon @ 2009-04-05  5:58 UTC (permalink / raw)


An easy answer is to create a wrapper file "load_image.c". This is needed 
because LoadImage(A/W) are in some API versions a macro which can not 
be directly access by Ada.  Then  use the "pragma Import" statement.

Note: Correction may be needed based on your packages and header files.

--
-- Insert into you Win32 package
--

  --  request Ada to automatically include the C object file that 
  --  contains the wrapper for this routine.

  pragma Linker_Options ( "load_image.o" ) ; 
                                  
  function LoadImage ( HINSTANCE hinst ;
                       LPCTSTR lpszName ;
                       UINT uType ;
                       int cxDesired ;
                       int cyDesired ;
                       UINT fuLoad ) return HANDLE ;

    pragma Import ( C, LoadImage, "LoadImage" ) ;

    ...




/*
 * load_image.c  -- LoadImage wrapper 
 */
#include <windows.h>

  HANDLE LoadImage ( HINSTANCE hinst,
                     LPCTSTR lpszName,
                     UINT uType,
                     int cxDesired,
                     int cyDesired,
                     UINT fuLoad );
    {
#ifdef UNICODE
      return LoadImageW ( hinst, lpszName, uType,
                          cxDesired, cyDesired, fuLoad ) ;
#else
      return LoadImageA ( hinst, lpszName, uType,
                          cxDesired, cyDesired, fuLoad ) ;
#endif // !UNICODE 
    }












In <0c1ee36a-67a7-4bf1-9a38-46ea9eae7cf2@s12g2000prc.googlegroups.com>, xiehang@gmail.com writes:
>Yea I know the W/A trick, but the win32ada I have does not have
>LoadImageA nor LoadImageW.
>
>Does your version of win32ada have them?
>
>-Hang
>
>Jerry van Dijk <je...@jerryware.nl> wrote:
>> a...@anon.org (anon) writes:
>> > Win32Ada provides only a subset of common routines. Version 3.0 was cre=
>ated
>> > back in 1999, so any additional routines that was added in XP or Vista =
>must
>> > be added to the package or Imported into your program.
>>
>> Although SetWindowRgn is indeed missing from from Win32Ada (it was added =
>with
>> Windows 2000), LoadImage is an alias for either LoadImageA or LoadImageW,
>> depending on whether you are in unicode mode or not.
>>
>> --
>> -- =A0Jerry van Dijk
>> -- =A0Leiden, Holland
>> --
>> -- =A0The early bird may get the worm, but the second mouse gets the chee=
>se!!




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: win32ada coverage
  2009-04-05  4:30     ` xiehang
  2009-04-05  5:58       ` anon
@ 2009-04-05 10:44       ` Jerry van Dijk
  1 sibling, 0 replies; 7+ messages in thread
From: Jerry van Dijk @ 2009-04-05 10:44 UTC (permalink / raw)


xiehang@gmail.com writes:

> Yea I know the W/A trick, but the win32ada I have does not have
> LoadImageA nor LoadImageW.
>
> Does your version of win32ada have them?

I assumed so since I used them before, but checking GNAT 2008 they are indeed
missing. Assumptions are always bad! :-)

Anyway, since the functions are in the import library, it is easy to define an
extra package for our own API definitions, see below. Untested, us at your own
risk, blah, blah. Note that you might have to add some constant definitions.

--                              -*- Mode: Ada -*-
--  Filename        : win32-addon.ads
--  Description     : Module to add missing API stuff to win32ada
--  Author          : Jerry van Dijk
--  Created On      : Sun Apr 05 12:02:59 2009
--  Last Modified By: .
--  Last Modified On: .
--  Update Count    : 0
--  Status          : Unknown, Use with caution!
-------------------------------------------------------------------------------

with Win32;
With Win32.Winnt;
with Win32.Windef;

package Win32.AddOn is

   --------------------------
   --  LoadImage function  --
   --------------------------

   function LoadImageA (hInst     : Win32.Windef.HINSTANCE;
                        lpszName  : Win32.Winnt.LPCTSTR;
                        uType     : Win32.UINT;
                        cxDesired : Win32.INT;
                        cyDesired : Win32.INT;
                        FuLoad    : Win32.UINT) return Win32.Winnt.HANDLE;

   function LoadImageW (hInst     : Win32.Windef.HINSTANCE;
                        lpszName  : Win32.Winnt.LPCTSTR;
                        uType     : Win32.UINT;
                        cxDesired : Win32.INT;
                        cyDesired : Win32.INT;
                        fuLoad    : Win32.UINT) return Win32.Winnt.HANDLE;

   function LoadImage (hInst     : Win32.Windef.HINSTANCE;
                       lpszName  : Win32.Winnt.LPCTSTR;
                       uType     : Win32.UINT;
                       cxDesired : Win32.INT;
                       cyDesired : Win32.INT;
                       fuLoad    : Win32.UINT) return Win32.Winnt.HANDLE
     renames LoadImageA;

private

   --  import from user32.a
   pragma Import (StdCall, LoadImageA, "LoadImagaA");
   pragma Import (StdCall, LoadImageW, "LoadImagaW");

end Win32.AddOn;

-- 
--  Jerry van Dijk
--  Leiden, Holland
--
--  The early bird may get the worm, but the second mouse gets the cheese!!



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-04-05 10:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-03 21:08 win32ada coverage xiehang
2009-04-03 22:51 ` anon
2009-04-04  0:52   ` xiehang
2009-04-04  6:38   ` Jerry van Dijk
2009-04-05  4:30     ` xiehang
2009-04-05  5:58       ` anon
2009-04-05 10:44       ` Jerry van Dijk

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