home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / packages / win32ada / data.z / win32-winuser.adb < prev    next >
Encoding:
Text File  |  1995-12-01  |  12.0 KB  |  307 lines

  1. -- $Source: /home/harp/1/proto/monoBANK/winnt/win32-winuser.adb,v $ 
  2. -- $Revision: 1.9 $ $Date: 95/02/07 12:13:01 $ $Author: mg $ 
  3. -------------------------------------------------------------------------------
  4. --
  5. -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS FURNISHED "AS IS" WITHOUT 
  6. -- WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
  7. -- TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR 
  8. -- PURPOSE.  The user assumes the entire risk as to the accuracy and the 
  9. -- use of this file.
  10. --
  11. -- Copyright (c) Intermetrics, Inc. 1995
  12. -- Royalty-free, unlimited, worldwide, non-exclusive use, modification, 
  13. -- reproduction and further distribution of this file is permitted.
  14. --
  15. -------------------------------------------------------------------------------
  16.  
  17.  
  18. with Ada.Unchecked_Conversion;
  19. with Stdarg.Impl;
  20.  
  21. package body Win32.Winuser is
  22.  
  23.     function MAKEINTRESOURCEA (wInteger: WORD) return LPSTR is
  24.                                                             -- winuser.h:102
  25.         function To_LPSTR is new Ada.Unchecked_Conversion (DWORD, LPSTR);
  26.     begin
  27.         return To_LPSTR(Win32.Utils.MAKELONG(wInteger, 0));
  28.     end MAKEINTRESOURCEA;
  29.  
  30.     function MAKEINTRESOURCEW (wInteger: WORD) return LPWSTR is
  31.                                                             -- winuser.h:103
  32.         function To_LPWSTR is new Ada.Unchecked_Conversion (DWORD, LPWSTR);
  33.     begin
  34.         return To_LPWSTR(Win32.Utils.MAKELONG(wInteger, 0));
  35.     end MAKEINTRESOURCEW;
  36.  
  37.     procedure POINTSTOPOINT(PT : out Win32.Windef.POINT;
  38.                             PTS: in  Win32.Windef.POINTS) is
  39.     begin
  40.         -- This looks real different from the C, but I think it does
  41.         -- the same thing!
  42.         PT.X := LONG(PTS.X);
  43.         PT.Y := LONG(PTS.Y);
  44.     end POINTSTOPOINT;
  45.  
  46.     function POINTTOPOINTS(PT:Win32.Windef.POINT) return Win32.Windef.POINTS is
  47.         PTS: Win32.Windef.POINTS;
  48.     begin
  49.         PTS.X := SHORT(PT.X);
  50.         PTS.Y := SHORT(PT.Y);
  51.         return PTS;
  52.     end POINTTOPOINTS;
  53.  
  54.     function MAKEWPARAM(L, H: WORD) return WPARAM is
  55.     begin
  56.         return WPARAM(Win32.Windef.MAKELONG(Low => L, High => H));
  57.     end MAKEWPARAM;
  58.  
  59.     function MAKELPARAM(L, H: WORD) return LPARAM is
  60.     begin
  61.         return LPARAM(Win32.Windef.MAKELONG(Low => L, High => H));
  62.     end MAKELPARAM;
  63.  
  64.     function MAKELRESULT(L, H: WORD) return LRESULT is
  65.     begin
  66.         return LRESULT(Win32.Windef.MAKELONG(Low => L, High => H));
  67.     end MAKELRESULT;
  68.  
  69.     function ExitWindows (dwReserved : DWORD;
  70.                           uReturnCode: UINT) return Win32.BOOL is
  71.         use type Win32.BOOL;
  72.     begin
  73.         if ExitWindowsEx(EWX_LOGOFF, -1) = 0 then
  74.             return 0;
  75.         else
  76.             return 1;
  77.         end if;
  78.     end ExitWindows;
  79.  
  80.     function CreateWindowA(lpClassName : Win32.LPCSTR;
  81.                            lpWindowName: Win32.LPCSTR;
  82.                            dwStyle     : Win32.DWORD;
  83.                            X           : Win32.INT;
  84.                            Y           : Win32.INT;
  85.                            nWidth      : Win32.INT;
  86.                            nHeight     : Win32.INT;
  87.                            hWndParent  : Win32.Windef.HWND;
  88.                            hMenu       : Win32.Windef.HMENU;
  89.                            hInstance   : Win32.Windef.HINSTANCE;
  90.                            lpParam     : Win32.LPVOID)
  91.                                          return Win32.Windef.HWND is
  92.  
  93.     begin
  94.          return CreateWindowEXA(0, lpClassName, lpWindowName, dwStyle,
  95.                                 x, y, nWidth, nHeight, hWndParent, hMenu, 
  96.                                 hInstance, lpParam);
  97.     end CreateWindowA;
  98.  
  99.     function CreateWindowW(lpClassName : Win32.LPCWSTR;
  100.                              lpWindowName: Win32.LPCWSTR;
  101.                              dwStyle     : Win32.DWORD;
  102.                              X           : Win32.INT;
  103.                              Y           : Win32.INT;
  104.                              nWidth      : Win32.INT;
  105.                              nHeight     : Win32.INT;
  106.                              hWndParent  : Win32.Windef.HWND;
  107.                              hMenu       : Win32.Windef.HMENU;
  108.                              hInstance   : Win32.Windef.HINSTANCE;
  109.                              lpParam     : Win32.LPVOID)
  110.                                            return Win32.Windef.HWND is
  111.     begin
  112.         return CreateWindowEXW(0, lpClassName, lpWindowName, dwStyle,
  113.                                x, y, nWidth, nHeight, hWndParent, hMenu, 
  114.                                hInstance, lpParam);
  115.     end CreateWindowW;
  116.  
  117.     function CreateDialogA(hInstance     : Win32.Windef.HINSTANCE;
  118.                            lpTemplateName: Win32.LPCSTR;
  119.                            hWndParent    : Win32.Windef.HWND;
  120.                            lpDialogFunc  : DLGPROC)
  121.         return Win32.Windef.HWND is
  122.     begin
  123.         return CreateDialogParamA (hInstance, lpTemplateName,
  124.                                    hWndParent, lpDialogFunc, 0);
  125.     end CreateDialogA;
  126.  
  127.     function CreateDialogW(hInstance     : Win32.Windef.HINSTANCE;
  128.                            lpTemplateName: Win32.LPCWSTR;
  129.                            hWndParent    : Win32.Windef.HWND;
  130.                            lpDialogFunc  : DLGPROC)
  131.         return Win32.Windef.HWND is
  132.     begin
  133.         return CreateDialogParamW (hInstance, lpTemplateName,
  134.                                    hWndParent, lpDialogFunc, 0);
  135.     end CreateDialogW;
  136.  
  137.     function CreateDialogIndirectA(hInstance   : Win32.Windef.HINSTANCE;
  138.                                    lpTemplate  : LPCDLGTEMPLATEA;
  139.                                    hWndParent  : Win32.Windef.HWND;
  140.                                    lpDialogFunc: DLGPROC)
  141.         return Win32.Windef.HWND is
  142.     begin
  143.         return CreateDialogIndirectParamA(
  144.             hInstance, lpTemplate, hWndParent, lpDialogFunc, 0);
  145.     end CreateDialogIndirectA;
  146.  
  147.     function CreateDialogIndirectW(hInstance   : Win32.Windef.HINSTANCE;
  148.                                    lpTemplate  : LPCDLGTEMPLATEW;
  149.                                    hWndParent  : Win32.Windef.HWND;
  150.                                    lpDialogFunc: DLGPROC)
  151.         return Win32.Windef.HWND is
  152.     begin
  153.         return CreateDialogIndirectParamW(
  154.             hInstance, lpTemplate, hWndParent, lpDialogFunc, 0);
  155.     end CreateDialogIndirectW;
  156.  
  157.     function DialogBoxA(hInstance     : Win32.Windef.HINSTANCE;
  158.                         lpTemplateName: Win32.LPCSTR;
  159.                         hWndParent    : Win32.Windef.HWND;
  160.                         lpDialogFunc  : DLGPROC)
  161.         return Win32.INT is
  162.     begin
  163.         return DialogBoxParamA(hInstance, lpTemplateName, 
  164.                                hWndParent, lpDialogFunc, 0);
  165.     end DialogBoxA;
  166.  
  167.     function DialogBoxW(hInstance     : Win32.Windef.HINSTANCE;
  168.                         lpTemplateName: Win32.LPCWSTR;
  169.                         hWndParent    : Win32.Windef.HWND;
  170.                         lpDialogFunc  : DLGPROC)
  171.         return Win32.INT is
  172.     begin
  173.         return DialogBoxParamW(hInstance, lpTemplateName, 
  174.                                hWndParent, lpDialogFunc, 0);
  175.     end DialogBoxW;
  176.  
  177.     function DialogBoxIndirectA(hInstance      : Win32.Windef.HINSTANCE;
  178.                                 hDialogTemplate: LPCDLGTEMPLATEA;
  179.                                 hWndParent     : Win32.Windef.HWND;
  180.                                 lpDialogFunc   : DLGPROC)
  181.         return Win32.INT is
  182.     begin
  183.         return DialogBoxIndirectParamA(hInstance, hDialogTemplate, 
  184.                                        hWndParent, lpDialogFunc, 0);
  185.     end DialogBoxIndirectA;
  186.  
  187.     function DialogBoxIndirectW(hInstance      : Win32.Windef.HINSTANCE;
  188.                                 hDialogTemplate: LPCDLGTEMPLATEW;
  189.                                 hWndParent     : Win32.Windef.HWND;
  190.                                 lpDialogFunc   : DLGPROC)
  191.           return Win32.INT is
  192.     begin
  193.         return DialogBoxIndirectParamW(hInstance, hDialogTemplate, 
  194.                                        hWndParent, lpDialogFunc, 0);
  195.     end DialogBoxIndirectW;
  196.  
  197.     function GetWindowTask(H: Win32.Windef.HWND) return Win32.Winnt.HANDLE is
  198.         Res: DWORD;
  199.         function To_Handle is new Ada.Unchecked_Conversion (
  200.             DWORD, Win32.Winnt.HANDLE);
  201.     begin
  202.         Res := GetWindowThreadProcessId(H, null);
  203.         return To_Handle(Res);
  204.     end GetWindowTask;
  205.  
  206.     function DefHookProc(nCode : Win32.INT;
  207.                          wParam: Win32.WPARAM;
  208.                          lParam: Win32.LPARAM;
  209.                          phhk  : access Win32.Windef.HHOOK)
  210.                                     return Win32.LRESULT is
  211.     begin
  212.         return CallNextHookEx(phhk.all, nCode, wParam, lParam);
  213.     end DefHookProc;
  214.  
  215.     function CopyCursor(hcur: Win32.Windef.HCURSOR) 
  216.         return Win32.Windef.HCURSOR is
  217.     begin
  218.         return Win32.Windef.HCURSOR(CopyIcon(Win32.Windef.HICON(hcur)));
  219.     end CopyCursor;
  220.  
  221.     function wsprintfA(
  222.         lpOut  : LPSTR;
  223.         lpFmt  : LPCSTR;
  224.         arglist: Stdarg.ArgList := Stdarg.Empty) return Win32.INT is
  225.                                                             -- winuser.h:155
  226.  
  227.         use Stdarg, Stdarg.Impl;
  228.  
  229.         function "&" is new Stdarg.Concat(LPSTR);
  230.         function "&" is new Stdarg.Concat(LPCSTR);
  231.  
  232.         Complete_Args: Stdarg.ArgList :=
  233.             Stdarg.Empty & lpOut & lpFmt & arglist;
  234.  
  235.         function C_wsprintfA return Win32.INT;
  236.         pragma Import(C, C_wsprintfA, "wsprintfA");
  237.  
  238.         function To_INT is new Ada.Unchecked_Conversion(
  239.                          Stdarg.C_Param, Win32.INT);
  240.     begin
  241.         return To_INT(F_Varargs(
  242.             C_wsprintfA'Address,
  243.             ArgCount(Complete_Args),
  244.             Address_of_First_Arg(Complete_Args)));
  245.  
  246.     end wsprintfA;
  247.  
  248.     function wsprintfW(
  249.         lpOut  : LPWSTR;
  250.         lpFmt  : LPCWSTR;
  251.         arglist: Stdarg.ArgList := Stdarg.Empty) return Win32.INT is
  252.                                                             -- winuser.h:155
  253.  
  254.         use Stdarg, Stdarg.Impl;
  255.  
  256.         function "&" is new Stdarg.Concat(LPWSTR);
  257.         function "&" is new Stdarg.Concat(LPCWSTR);
  258.  
  259.         Complete_Args: Stdarg.ArgList :=
  260.             Stdarg.Empty & lpOut & lpFmt & arglist;
  261.  
  262.         function C_wsprintfW return Win32.INT;
  263.         pragma Import(C, C_wsprintfW, "wsprintfW");
  264.  
  265.         function To_INT is new Ada.Unchecked_Conversion(
  266.                          Stdarg.C_Param, Win32.INT);
  267.     begin
  268.         return To_INT(F_Varargs(
  269.             C_wsprintfW'Address,
  270.             ArgCount(Complete_Args),
  271.             Address_of_First_Arg(Complete_Args)));
  272.  
  273.     end wsprintfW;
  274.  
  275.  
  276.     function wvsprintfA(lpOut  : Win32.LPSTR;
  277.                         lpFmt  : Win32.LPCSTR;
  278.                         arglist: Stdarg.ArgList := Stdarg.Empty)
  279.                                  return Win32.INT is
  280.  
  281.         function doit(  lpOut  : Win32.LPSTR;
  282.                         lpFmt  : Win32.LPCSTR;
  283.                         arglist: Stdarg.Impl.Param_Access)
  284.                                      return Win32.INT;
  285.  
  286.         pragma Import(Stdcall, doit, "wvsprintfA");
  287.     begin
  288.         return doit(lpOut, lpFmt, Stdarg.Impl.Address_of_First_Arg(arglist));
  289.     end wvsprintfA;
  290.  
  291.     function wvsprintfW(lpOut     : Win32.LPWSTR;
  292.                         lpFmt     : Win32.LPCWSTR;
  293.                         arglist: Stdarg.ArgList := Stdarg.Empty)
  294.                                  return Win32.INT is
  295.  
  296.         function doit(  lpOut  : Win32.LPWSTR;
  297.                         lpFmt  : Win32.LPCWSTR;
  298.                         arglist: Stdarg.Impl.Param_Access)
  299.                                      return Win32.INT;
  300.  
  301.         pragma Import(Stdcall, doit, "wvsprintfW");
  302.     begin
  303.         return doit(lpOut, lpFmt, Stdarg.Impl.Address_of_First_Arg(arglist));
  304.     end wvsprintfW;
  305.  
  306. end Win32.Winuser;
  307.