home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / packages / win32ada / data.z / WININFO.ADB < prev    next >
Encoding:
Text File  |  1995-12-05  |  4.4 KB  |  126 lines

  1. -- $Source: /home/harp/1/proto/monoBANK/winnt/wininfo.adb,v $ 
  2. -- $Revision: 1.1 $ $Date: 95/02/11 13:50:20 $ $Author: mg $ 
  3. -- $Id: wininfo.adb 1.2 1995/01/25 15:56:04 teg Exp teg $
  4. --
  5. --  This is a translation of wininfo.c which is a member of the Microsoft 
  6. --  gdidemo sample application.
  7. --
  8. -- | WINDOW INFORMATION MODULE
  9. -- |   This module contains the routines which deal with obtaining the extra
  10. -- |   object information associated with a window.  For these to work, the
  11. -- |   window class must reserve the 0th word of the win-class object to be
  12. -- |   used to hold global-memory handle.
  13.  
  14.  
  15. with Win32.WinDef;
  16. with Win32.WinBase;
  17. with Win32.WinUser;
  18.  
  19. with Interfaces.C;
  20. with Convert;
  21.  
  22. package body Wininfo is
  23.  
  24.   use type Interfaces.C.Int;
  25.   use type Interfaces.C.Long;
  26.   use type System.Address;
  27.   use type Win32.BOOL;
  28.  
  29.   -- dummy return values
  30.   lResult : Win32.LONG;
  31.   
  32. -- | ALLOC WINDOW INFO
  33. -- |   This routine allocates memory out of the application heap for storing
  34. -- |   extra memory for the Win32.dow.  It is alway referenced as offset 0.
  35. function AllocWindowInfo (hWnd_p : Win32.WinDef.HWND;
  36.                           wSize  : Win32.WORD) return Win32.BOOL is
  37.   hsd : Win32.Winnt.HANDLE;
  38. begin
  39.   hsd := Win32.Winnt.HANDLE
  40.            (Win32.WinBase.LocalAlloc (Win32.WinBase.LHND, Win32.UINT (wSize)));
  41.   --     if(hsd = LocalAlloc(LHND,(WORD)wSize))
  42.   if hsd /= System.Null_Address then 
  43.     lResult := Win32.WinUser.SetWindowLong(hWnd_p, 0, 
  44.                                            Convert.HANDLE_TO_LONG (hsd));
  45.     return Win32.TRUE;
  46.   else
  47.     return Win32.FALSE;
  48.   end if;
  49. end AllocWindowInfo; 
  50.  
  51.  
  52. -- | LOCK WINDOW INFO
  53. -- |   This routine de-references the extra-memory associated with the Window.
  54. -- |   it locks the object and gives the caller a pointer to the memory.
  55. function LockWindowInfo (hWnd_p : Win32.WinDef.HWND) return 
  56.                                                      Win32.Winnt.HANDLE is
  57.   hMem : Win32.Winnt.HANDLE;
  58.   pMem : Win32.LPVOID;
  59.   lMem : Win32.LONG;
  60. begin
  61.   --     if(hMem = (HANDLE)GetWindowLong(hWnd,0))
  62.   lMem := Win32.WinUser.GetWindowLong (hWnd_p, 0);
  63.   if lMem /= 0 then
  64.     hMem := Convert.LONG_TO_HANDLE (lMem);
  65.     pMem := Win32.WinBase.LocalLock (Win32.Windef.HLOCAL (hMem));
  66.     --         pMem = (PVOID)LocalLock(hMem);
  67.   end if;
  68.   return Win32.Winnt.HANDLE (pMem);
  69. end LockWindowInfo;
  70.  
  71.  
  72. -- | UNLOCK WINDOW INFO
  73. -- |   This routine unlocks the memory the caller has previously locked.
  74. function UnlockWindowInfo (hwnd_p : Win32.WinDef.HWND) return Win32.BOOL is
  75.   hMem : Win32.Winnt.HANDLE;
  76.   lMem : Win32.LONG;
  77.   bResult : Win32.BOOL;
  78. begin
  79.   lMem := Win32.WinUser.GetWindowLong (hWnd_p, 0);
  80.   if lMem /= 0 then
  81.     hMem := Convert.LONG_TO_HANDLE (lMem);
  82.     if Win32.WinBase.LocalUnlock (Win32.Windef.HLOCAL (hMem)) = 
  83.                                                        Win32.FALSE then
  84.       return Win32.TRUE;
  85.     end if; 
  86.   end if;
  87.   return Win32.FALSE;
  88.  
  89. end UnlockWindowInfo;
  90.  
  91.  
  92. -- | FREE WINDOW INFO
  93. -- |   This routine frees the object memory associated with the Win32.dow.
  94. function FreeWindowInfo (hwnd_p : Win32.WinDef.HWND) return Win32.BOOL is
  95.   hMem : Win32.WinDef.HLOCAL;
  96.   lMem : Win32.LONG;
  97. begin
  98.   lMem := Win32.WinUser.GetWindowLong (hWnd_p, 0);
  99.   if lMem /= 0 then
  100.     hMem := Win32.WinDef.HLOCAL (Convert.LONG_TO_HANDLE (lMem));
  101.     hMem := Win32.WinBase.LocalFree (hMem);
  102.   end if;
  103.   return Win32.TRUE;
  104.     
  105. end FreeWindowInfo;
  106.  
  107. -------------------------------------------------------------------------------
  108. --
  109. -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS PROVIDED "AS IS" WITHOUT 
  110. -- WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT 
  111. -- LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR 
  112. -- A PARTICULAR PURPOSE.  The user assumes the entire risk as to the accuracy 
  113. -- and the use of this file.  This file may be used only by licensees of 
  114. -- Microsoft Corporation's WIN32 Software Development Kit in accordance with 
  115. -- the terms of the licensee's End-User License Agreement for Microsoft 
  116. -- Software for the WIN32 Development Kit.
  117. --
  118. -- Copyright (c) Intermetrics, Inc. 1995
  119. -- Portions (c) 1985-1994 Microsoft Corporation with permission.
  120. -- Microsoft is a registered trademark and Windows and Windows NT are 
  121. -- trademarks of Microsoft Corporation.
  122. --
  123. -------------------------------------------------------------------------------
  124.  
  125. end Wininfo;
  126.