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

  1. -- $Source: /home/harp/1/proto/monoBANK/winnt/keylook.adb,v $ 
  2. -- $Revision: 1.5 $ $Date: 95/12/18 17:03:15 $ $Author: mg $ 
  3.  
  4. pragma Linker_Options("-lwin32ada");
  5.  
  6.  
  7. with Ada.Command_Line;
  8. with Interfaces.C;
  9. with Interfaces.C.Strings;
  10. with Keylook_Pkg; use Keylook_Pkg;
  11. with Stdarg;
  12. with Stdarg.Inst;
  13. with Win32; use Win32;
  14. with Win32.Windef;
  15. with Win32.Wingdi;
  16. with Win32.Winmain;
  17. with Win32.Winuser;
  18.  
  19.  
  20. procedure KeyLook is
  21.  
  22.     -- global variables, visible to all procedures:
  23.     IgnoredL : Win32.LONG;
  24.     IgnoredA : Win32.Windef.ATOM;
  25.  
  26.  
  27.     function WinMain(
  28.     HINSTANCE    : Win32.Windef.HINSTANCE;
  29.     hPrevInstance: Win32.Windef.HINSTANCE;
  30.     lpszCmdLine  : Win32.PCSTR;
  31.     nCmdShow     : Win32.INT) return Win32.WPARAM is
  32.  
  33.     use type Interfaces.C.INT;
  34.     use type System.Address;    
  35.  
  36.     szAppName    : constant Win32.CHAR_Array := "KeyLook" & Nul;
  37.     szMesLook    : constant Win32.CHAR_Array := 
  38.                "Keyboard Message Looker - in Ada" & Nul;
  39.     hwnd         : Win32.Windef.HWND;
  40.     begin
  41.     if hPrevInstance = System.Null_Address then
  42.         wndclass.style         := Win32.Winuser.CS_HREDRAW or
  43.                                   Win32.Winuser.CS_VREDRAW;
  44.         wndclass.lpfnWndProc   := WndProc'access;
  45.         wndclass.cbClsExtra    := 0;
  46.         wndclass.cbWndExtra    := 0;
  47.         wndclass.hInstance     := hInstance;
  48.         wndclass.hIcon         := Win32.Winuser.LoadIcon(System.Null_Address, 
  49.                                   Win32.LPCSTR(Win32.Winuser.IDI_APPLICATION));
  50.         wndclass.hCursor       := Win32.Windef.HCURSOR(
  51.                                   Win32.Winuser.LoadCursor(System.Null_Address, 
  52.                       Win32.LPCSTR(Win32.Winuser.IDC_ARROW)));
  53.         wndclass.hbrBackground := Win32.Windef.HBRUSH(
  54.                      Win32.Wingdi.GetStockObject(
  55.                      Win32.Wingdi.WHITE_BRUSH));
  56.         wndclass.lpszMenuName  := null;
  57.         wndclass.lpszClassName := CP(szAppName);
  58.  
  59.         IgnoredA := Win32.Winuser.RegisterClass(wndclass'access);
  60.     end if;
  61.  
  62.     hwnd := Win32.Winuser.CreateWindow(
  63.              CP(szAppName),
  64.              CP(szMesLook),
  65.              Win32.Winuser.WS_OVERLAPPEDWINDOW,
  66.              Win32.Winuser.CW_USEDEFAULT,
  67.              Win32.Winuser.CW_USEDEFAULT,
  68.              Win32.Winuser.CW_USEDEFAULT,
  69.              Win32.Winuser.CW_USEDEFAULT,
  70.              System.Null_Address, 
  71.              System.Null_Address, 
  72.              hInstance, 
  73.              System.Null_Address);
  74.  
  75.     IgnoredB := Win32.Winuser.ShowWindow(hwnd, nCmdShow);
  76.     IgnoredB := Win32.Winuser.UpdateWindow(hwnd);
  77.  
  78.     while Win32.Winuser.GetMessage(msg'access,System.Null_Address,0,0) /= 0 loop
  79.         IgnoredB := Win32.Winuser.TranslateMessage(msg'access);
  80.         IgnoredL := Win32.Winuser.DispatchMessage(msg'access);
  81.     end loop;
  82.  
  83.     return msg.wParam;
  84.     end WinMain;
  85.  
  86.  
  87. begin    -- Keylook main body
  88.  
  89.     Ada.Command_Line.Set_Exit_Status(Ada.Command_Line.Exit_Status(WinMain(
  90.             Win32.Winmain.Get_hInstance,
  91.             Win32.Winmain.Get_hPrevInstance,
  92.             Win32.Winmain.Get_lpCmdline,
  93.             Win32.Winmain.Get_nCmdShow)));
  94.  
  95. -------------------------------------------------------------------------------
  96. --
  97. -- This program has been derived by Intermetrics, Inc. from the 
  98. -- keylook.c program in "Programming Windows 3.1", third edition, 
  99. -- by Charles Petzold, Microsoft Press.
  100. -- The program is derived from source code which is restricted 
  101. -- by the license and under the following copyrights:
  102. --
  103. --      Copyright (c) 1992 by Charles Petzold
  104. --
  105. --
  106. -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS PROVIDED "AS IS" WITHOUT 
  107. -- WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT 
  108. -- LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR 
  109. -- A PARTICULAR PURPOSE.  The user assumes the entire risk as to the accuracy 
  110. -- and the use of this file.  This file may be used only by licensees of 
  111. -- Microsoft Corporation's WIN32 Software Development Kit in accordance with 
  112. -- the terms of the licensee's End-User License Agreement for Microsoft 
  113. -- Software for the WIN32 Development Kit.
  114. --
  115. -- Copyright (c) Intermetrics, Inc. 1995
  116. -- Portions (c) 1985-1994 Microsoft Corporation with permission.
  117. -- Microsoft is a registered trademark and Windows and Windows NT are 
  118. -- trademarks of Microsoft Corporation.
  119. --
  120. -------------------------------------------------------------------------------
  121. end KeyLook;
  122.