home *** CD-ROM | disk | FTP | other *** search
- -- $Source: /home/harp/1/proto/monoBANK/winnt/pcx.adb,v $
- -- $Revision: 1.1 $ $Date: 95/02/12 10:22:48 $ $Author: mg $
- -- $Id: pcx.adb 1.5 1995/02/08 18:30:27 mps Exp mps $
- --
- -- PROGRAM: pcx.adb
- --
- -- PURPOSE: Provide display of PCX files
- --
- -- COMMENTS:
- -- The LabTek PCX Application Example is a sample application
- -- that you can use to get an idea of how to perform some of the simple
- -- functionality that the Windows GDI API implements.
- -- Note that no 'use' clauses were used to help get a better idea on where
- -- various type are located in the binding. Readability improves greatly
- -- once a 'use Win32;' is used.
- --
- -- NOTES:
- -- There is currently no help file.
- -- pcxops.adb uses Unix style opens and reads instead of the Win32 variants.
- --
-
- pragma Linker_Options("-lwin32ada");
-
-
- with AliasPkg; use AliasPkg;
- with Interfaces.C;
- with File;
- with PcxOps;
- with PcxChild;
- with Win32.WinMain;
- with Win32.WinUser;
- with Win32.WinBase;
- with Win32.WinGdi;
- with Win32.WinDef;
- with Unchecked_Conversion;
-
- procedure Pcx is
-
- use type Interfaces.C.INT;
- use type Interfaces.C.UNSIGNED_SHORT;
- use type Win32.BOOL;
-
-
- MSG : Win32.WinUser.LPMSG; -- ptr to current message
- HACCELTABLE : Win32.WinDef.HACCEL; -- translates accelerator msgs
- BOX_ACTIVE : BOOLEAN; -- is rectangle being sized?
- RECTANGLE_DRAWN : BOOLEAN; -- was rectangle drawn? (to erase)
- REPAINT_WANTED : BOOLEAN; -- repaint during resizing?
- BRESULT : Win32.BOOL; -- temp to hold results
- LRESULT : Win32.LRESULT; -- temp to hold results
-
- --
- -- Unchecked_Conversions.
- -- This translates from an integer to an HBRUSH.
- --
- function Int_To_HBrush is new Unchecked_Conversion(Win32.INT,
- Win32.WinDef.HBRUSH);
-
-
- --
- -- Register the window and the "child" windows.
- --
- function InitApplication(HINST : Win32.WinDef.HINSTANCE) return Win32.BOOL is
-
-
- begin
- WC.STYLE := Win32.WinUser.CS_HREDRAW or Win32.WinUser.CS_VREDRAW;
- WC.LPFNWNDPROC := WndProc'access;
- WC.CBCLSEXTRA := 0;
- WC.CBWNDEXTRA := 0;
- WC.HINSTANCE := HINST;
- WC.HICON := Win32.WinUser.LoadIcon(HINST, szappname);
- WC.HCURSOR := Win32.WinUser.LoadCursor(System.Null_Address,
- Win32.LPCSTR(Win32.WinUser.IDC_ARROW));
- WC.HBRBACKGROUND := Int_To_HBrush(Win32.WinUser.COLOR_WINDOW + 1);
- WC.LPSZMENUNAME := szappname;
- WC.LPSZCLASSNAME := szappname;
- --
- -- Register the main window class.
- --
- if Win32.BOOL(Win32.WinUser.RegisterClass(WC'access)) /=
- Win32.FALSE then
- WC.STYLE := Win32.WinUser.CS_HREDRAW or Win32.WinUser.CS_VREDRAW;
- WC.LPFNWNDPROC := PcxChild.ChildWndProc'access;
- WC.CBCLSEXTRA := 0;
- WC.CBWNDEXTRA := 0;
- WC.HINSTANCE := HINST;
- WC.HICON := Win32.WinUser.LoadIcon(HINST, szappname);
- WC.HCURSOR := Win32.WinUser.LoadCursor(System.Null_Address,
- Win32.LPCSTR(Win32.WinUser.IDC_ARROW));
- WC.HBRBACKGROUND := Int_To_HBrush(Win32.WinUser.COLOR_WINDOW + 1);
- WC.LPSZMENUNAME := null;
- WC.LPSZCLASSNAME := PcxChild.SZCHILDNAME;
- --
- -- Register the child window class and return success/failure code.
- --
- return Win32.BOOL(Win32.WinUser.RegisterClass(WC'access));
- else
- return Win32.FALSE;
- end if;
- end InitApplication;
-
- --
- -- Create the window for use with PCX.
- --
- function InitInstance(HINST : Win32.WinDef.HINSTANCE;
- NCMDSHOW : Win32.INT) return Win32.BOOL is
-
- use type System.Address;
-
- HWND : Win32.WinDef.HWND;
- begin
- --
- -- Create a main window for this application instance.
- --
- HWND := Win32.WinUser.CreateWindow(
- lpClassName => szappname,
- lpWindowName => CP(pcxTitle),
- dwStyle => Win32.WinUser.WS_OVERLAPPEDWINDOW,
- X => Win32.WinUser.CW_USEDEFAULT,
- Y => Win32.WinUser.CW_USEDEFAULT,
- nWidth => 300,
- nHeight => 200,
- hWndParent => System.Null_Address,
- hMenu => System.Null_Address,
- hInstance => HINST,
- lpParam => System.Null_Address);
- --
- -- If window could not be created, return "failure".
- --
- if HWND = System.Null_Address then
- return Win32.FALSE;
- end if;
- --
- -- Make the window visible; update its client area; and return "success".
- --
- BRESULT := Win32.WinUser.ShowWindow(HWND, NCMDSHOW); -- Show the window
- BRESULT := Win32.WinUser.UpdateWindow(HWND); -- Sends WM_PAINT message
-
- return Win32.TRUE;
- end InitInstance;
-
-
- begin -- pcx
- FILE_DISPLAYED := FALSE;
- BOX_ACTIVE := FALSE;
- RECTANGLE_DRAWN := FALSE;
- REPAINT_WANTED := TRUE;
- HINST := Win32.WinMain.Get_Hinstance;
- BRESULT := InitApplication(HINST);
- BRESULT := InitInstance(HINST, Win32.WinMain.Get_nCmdShow);
- HACCELTABLE := Win32.WinUser.LoadAccelerators(HINST, szappname);
-
- --
- -- Acquire and dispatch messages until a WM_QUIT message is received.
- --
- MSG := new Win32.WinUser.MSG;
- while (Win32.WinUser.GetMessage (MSG, System.Null_Address, 0, 0) /= 0) loop
- IRESULT := Win32.WinUser.TranslateAccelerator(MSG.HWND, HACCELTABLE, MSG);
- BRESULT := Win32.WinUser.TranslateMessage(Win32.WinUser.ac_MSG_t(MSG));
- LRESULT := Win32.WinUser.DispatchMessage(Win32.WinUser.ac_MSG_t(MSG));
- end loop;
-
- -------------------------------------------------------------------------------
- --
- -- THIS FILE AND ANY ASSOCIATED DOCUMENTATION IS FURNISHED "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.
- --
- -- Copyright (c) Intermetrics, Inc. 1995
- -- Royalty-free, unlimited, worldwide, non-exclusive use, modification,
- -- reproduction and further distribution of this file is permitted.
- --
- -------------------------------------------------------------------------------
-
- end Pcx;