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

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