home *** CD-ROM | disk | FTP | other *** search
- -- $Source: /home/harp/1/proto/monoBANK/winnt/zoomin.adb,v $
- -- $Revision: 1.2 $ $Date: 95/02/11 14:30:50 $ $Author: mg $
- --
- --/****************************** Module Header *******************************
- --* Module Name: zoomin.c
- --*
- --* Microsoft ZoomIn utility. This tool magnifies a portion of the screen,
- --* allowing you to see things at a pixel level.
- --*
- --* History:
- --* 01/01/88 Created.
- --* 01/01/92 Ported to NT.
- --* 03/06/92 Cleanup.
- --* 10/20/94 Ported To Ada. (mps)
- --* 01/23/95 Ported to Inmet bindings
- --*
- --****************************************************************************/
- --
-
- pragma Linker_Options("-lwin32ada");
-
-
- with Win32;
- with Win32.WinDef;
- with Win32.WinUser;
- with Win32.WinGdi;
- with Win32.Malloc;
- with Win32.Utils;
- with Win32.WinMain;
- with Interfaces.C;
- with Unchecked_Conversion;
- with Zoomin_Pkg;
-
- use Win32;
- use Win32.WinDef;
- use Zoomin_Pkg;
-
- procedure Zoomin is
-
- package ZP renames Zoomin_Pkg;
-
- use type Win32.BOOL;
- use type Win32.LONG;
- use type Win32.INT;
- use type Interfaces.C.Unsigned;
- use type Interfaces.C.Unsigned_Short;
- use type Win32.Wingdi.PLOGPALETTE;
- use type System.Address;
-
-
- --
- --/************************************************************************
- --* CreatePhysicalPalette
- --*
- --* Creates a palette for the app to use. The palette references the
- --* physical palette, so that it can properly display images grabbed
- --* from palette managed apps.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- function CreatePhysicalPalette return WinDef.HPALETTE is
-
- pragma Suppress(range_check); -- this version doesn't use "extensible arrays"
-
- PPAL : Win32.Wingdi.PLOGPALETTE;
- HPAL : Win32.Windef.HPALETTE := System.Null_Address;
-
- function Void_To_Logpalette is new Unchecked_Conversion(
- Win32.PVOID, Win32.WinGdi.PLOGPALETTE);
- begin
- PPAL := Void_To_Logpalette(
- Win32.Malloc.Malloc((Win32.WinGdi.LOGPALETTE'size)/8 +
- NPAL*((WinGdi.PALETTEENTRY'size)/8)));
- if PPAL /= null then
- PPAL.PALVERSION := 16#300#;
- PPAL.PALNUMENTRIES := NPAL;
- for I in 0..NPAL - 1 loop
- PPAL.PALPALENTRY(I).PEFLAGS := Win32.BYTE(WinGdi.PC_EXPLICIT);
- PPAL.PALPALENTRY(I).PERED := Win32.BYTE(I);
- PPAL.PALPALENTRY(I).PEGREEN := 0;
- PPAL.PALPALENTRY(I).PEBLUE := 0;
- end loop;
- HPAL := WinGdi.CreatePalette(PPAL);
- end if;
- return HPAL;
- end CreatePhysicalPalette;
-
-
- --
- --/************************************************************************
- --* InitInstance
- --*
- --* Instance initialization for the app.
- --*
- --* Arguments:
- --*
- --* History:
- --*
- --************************************************************************/
- --
- function InitInstance(HINST : Win32.Windef.HINSTANCE;
- CMDSHOW : Win32.INT) return Win32.BOOL is
-
- icon : constant LPCSTR := ZP.CP(ZP.icon_str);
- DX : Win32.LONG;
- DY : Win32.LONG;
- FLSTYLE : Win32.DWORD;
- RC : Win32.Windef.LPRECT;
- BRESULT : Win32.BOOL;
- IRESULT : Win32.INT;
- SYSTEM_MSG : Win32.LPSTR;
- ERROR_LEN : Win32.DWORD;
-
- begin
- GHINST := HINST;
- -- /*
- -- * Register a class for the main application window.
- -- */
- ZP.WC.HCURSOR := WinUser.LoadCursor(System.Null_Address,
- LPCSTR(WinUser.IDC_ARROW));
- ZP.WC.HICON := WinUser.LoadIcon(HINST, icon);
- ZP.WC.LPSZMENUNAME := LPCSTR(WinUser.MakeIntResource(IDMENU_ZOOMIN));
- ZP.WC.LPSZCLASSNAME := SZAPPNAME;
- ZP.WC.HBRBACKGROUND := WinDef.HBRUSH(WinGdi.GetStockObject(WinGdi.BLACK_BRUSH));
- ZP.WC.HINSTANCE := HINST;
- ZP.WC.STYLE := WinUser.CS_BYTEALIGNCLIENT or
- WinUser.CS_VREDRAW or
- WinUser.CS_HREDRAW;
- ZP.WC.LPFNWNDPROC := ZP.AppWndProc'access;
- ZP.WC.CBWNDEXTRA := 0;
- ZP.WC.CBCLSEXTRA := 0;
-
- if WinUser.RegisterClass(ZP.WC'access) = 0 then
- SYSTEM_MSG := Win32.LPSTR(ZP.CP(ZP.BUFFER));
- ERROR_LEN := Win32.WinBase.FormatMessage(
- Win32.WinBase.format_message_from_system,
- System.Null_Address,
- Win32.WinBase.GetLastError,
- DWORD(Win32.WinNT.MakeLangId(
- Win32.WinNT.lang_english,
- Win32.WinNT.sublang_english_us)),
- SYSTEM_MSG,
- DWORD(ZP.BUFFER'last));
- IRESULT := Win32.WinUser.MessageBox(
- Win32.WinUser.GetFocus,
- LPCSTR(SYSTEM_MSG),
- icon,
- Win32.WinUser.MB_OK);
-
- return Win32.FALSE;
- end if;
-
- GHACCELTABLE := WinUser.LoadAccelerators(HINST,
- LPCSTR(WinUser.MakeIntResource(IDACCEL_ZOOMIN)));
- if GHACCELTABLE = System.Null_Address then
- return Win32.FALSE;
- end if;
-
- GHPALPHYSICAL := CreatePhysicalPalette;
- if GHPALPHYSICAL = System.Null_Address then
- return Win32.FALSE;
- end if;
-
- GCXSCREENMAX := Win32.LONG(WinUser.GetSystemMetrics(WinUser.SM_CXSCREEN) - 1);
- GCYSCREENMAX := Win32.LONG(WinUser.GetSystemMetrics(WinUser.SM_CYSCREEN) - 1);
-
- FLSTYLE := WinUser.WS_CAPTION or WinUser.WS_OVERLAPPED or
- WinUser.WS_SYSMENU or WinUser.WS_THICKFRAME or
- WinUser.WS_MINIMIZEBOX or WinUser.WS_VSCROLL;
-
- DX := 44 * GNZOOM;
- DY := 36 * GNZOOM;
-
- RC := new WinDef.RECT;
- bResult := WinUser.SetRect(RC, 0, 0, INT (DX), INT (DY));
- bResult := WinUser.AdjustWindowRect(RC, FLSTYLE, Win32.TRUE);
-
- GHWNDAPP := WinUser.CreateWindow(
- lpClassName => SZAPPNAME,
- lpWindowName => SZAPPNAME,
- dwStyle => FLSTYLE,
- X => WinUser.CW_USEDEFAULT,
- Y => 0,
- nWidth => INT (RC.RIGHT - RC.LEFT),
- nHeight => INT (RC.BOTTOM - RC.TOP),
- hWndParent => System.Null_Address,
- hMenu => System.Null_Address,
- hInstance => HINST,
- lpParam => System.Null_Address);
-
- if GHWNDAPP = System.Null_Address then
- return Win32.FALSE;
- end if;
-
- bResult := WinUser.ShowWindow(GHWNDAPP, CMDSHOW);
-
- return Win32.TRUE;
- end InitInstance;
-
- --
- --
- --/************************************************************************
- --* Zoomin
- --*
- --* Main entry point for the application.
- --*
- --* Arguments:
- --*
- --* History:
- --*
- --************************************************************************/
- --
- begin
- GNZOOM := 4;
- GFREFENABLE := Win32.FALSE;
- GNREFINTERVAL := 20;
- GFTRACKING := Win32.FALSE;
- GPTZOOM := new POINT'(100,100);
- HINST := Win32.WinMain.Get_hInstance;
- NCMDSHOW := Win32.WinMain.Get_nCmdShow;
- if InitInstance(HINST, NCMDSHOW) = Win32.FALSE then
- return;
- end if;
- -- /*
- -- * Polling messages from event queue
- -- */
- MESSAGE := new WinUser.MSG;
- while WinUser.GetMessage(MESSAGE, System.Null_Address, 0, 0) = Win32.TRUE loop
- --
- -- For now, keep like this...need to correct NULL_PTR.
- --
- -- if WinUser.TranslateAccelerator(GHWNDAPP, GHACCELTABLE, MESSAGE) =
- -- INT (Win32.FALSE)
- -- then
- bResult := WinUser.TranslateMessage(WinUser.ac_MSG_t(MESSAGE));
- longResult := WinUser.DispatchMessage(WinUser.ac_MSG_t(MESSAGE));
- -- end if;
- end loop;
-
- -------------------------------------------------------------------------------
- --
- -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS PROVIDED "AS IS" WITHOUT
- -- WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
- -- LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR
- -- A PARTICULAR PURPOSE. The user assumes the entire risk as to the accuracy
- -- and the use of this file. This file may be used only by licensees of
- -- Microsoft Corporation's WIN32 Software Development Kit in accordance with
- -- the terms of the licensee's End-User License Agreement for Microsoft
- -- Software for the WIN32 Development Kit.
- --
- -- Copyright (c) Intermetrics, Inc. 1995
- -- Portions (c) 1985-1994 Microsoft Corporation with permission.
- -- Microsoft is a registered trademark and Windows and Windows NT are
- -- trademarks of Microsoft Corporation.
- --
- -------------------------------------------------------------------------------
-
- end Zoomin;
-