home *** CD-ROM | disk | FTP | other *** search
- -- $Source: /home/harp/1/proto/monoBANK/winnt/zoomin_ext.adb,v $
- -- $Revision: 1.2 $ $Date: 95/02/11 14:30:54 $ $Author: mg $
- --
- -- NOTE:
- --
- -- This version of zoomin attempts to use the extensible arrays package.
- -- It does not work correctly at this time. I (MPS) tracked the bug down
- -- to the call in InitInstance: bResult := ShowWindow(GHWNDAPP, CMDSHOW);
- -- It is possible that gnat 2.02 does not handle generics well and as a result
- -- is scribbling over memory somewhere. It is also possible that I do not
- -- fully comprehend how to use the package Extensible.
- -- Using DBG however, I was able to verify that the same addresses are generated
- -- for both PPAL and PALPALENTRY.
- --
- --/****************************** 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
- --*
- --****************************************************************************/
- --
- 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 Extensible;
-
- use Win32;
- use Win32.WinDef;
-
- procedure Zoomin is
-
- use type Win32.BOOL;
- use type Win32.LONG;
- use type Win32.INT;
- use type Interfaces.C.Unsigned;
- use type Interfaces.C.Unsigned_Short;
-
- MENU_HELP_ABOUT : constant := 100;
- MENU_EDIT_COPY : constant := 200;
- MENU_EDIT_REFRESH : constant := 201;
- MENU_OPTIONS_REFRESHRATE : constant := 300;
- DID_ABOUT : constant := 1000;
- DID_REFRESHRATE : constant := 1100;
- DID_REFRESHRATEENABLE : constant := 1101;
- DID_REFRESHRATEINTERVAL : constant := 1102;
- IDMENU_ZOOMIN : constant := 2000;
- IDACCEL_ZOOMIN : constant := 3000;
- IDTIMER_ZOOMIN : constant := 4000;
-
- MIN_ZOOM : constant := 1;
- MAX_ZOOM : constant := 32;
- FASTDELTA : constant := 8;
- MM10PERINCH : constant := 254; -- Tenths of a millimeter per inch.
- NPAL : constant := 256; -- Number of palette entries.
-
- appname : aliased constant Interfaces.C.CHAR_ARRAY := -- Application name
- Interfaces.C.To_C("Ada 9x ZoomIn");
- SZAPPNAME : constant LPCSTR := appname(appname'first)'access;
- GHINST : Windef.HINSTANCE; -- Instance handle.
- GHWNDAPP : Windef.HWND; -- Main window handle.
- GHACCELTABLE : Windef.HACCEL; -- Main accelerator table.
- GNZOOM : Win32.LONG; -- Zoom (magnification) factor.
- GHPALPHYSICAL : Windef.HPALETTE; -- Handle to the physical palette.
- GCXSCREENMAX : Win32.LONG; -- Width of the screen (less 1).
- GCYSCREENMAX : Win32.LONG; -- Height of the screen (less 1).
- GCXZOOMED : Win32.LONG; -- Client width in zoomed pixels.
- GCYZOOMED : Win32.LONG; -- Client height in zoomed pixels.
- GFREFENABLE : Win32.BOOL; -- TRUE if refresh is enabled.
- GNREFINTERVAL : Win32.UINT; -- Refresh interval in 10ths of sec.
- GFTRACKING : Win32.BOOL; -- TRUE if tracking is in progress.
- GPTZOOM : Windef.LPPOINT; -- center of the zoomed area.
- MESSAGE : WinUser.LPMSG;
- HINST : Windef.HINSTANCE;
- NCMDSHOW : Win32.INT;
- -- dummy return values for some of the WinAPI function calls
- bResult : Win32.BOOL;
- siResult : Win32.INT;
- hResult : WinDef.HPALETTE;
- hgdiResult : WinDef.HGDIOBJ;
- handResult : Winnt.HANDLE;
- longResult : Win32.LONG;
- hcurResult : WinDef.HCURSOR;
- uResult : Win32.UINT;
-
- --
- -- This function was a macro in zoomin.h.
- --
- function Bound(X : Win32.LONG;
- MIN : Win32.LONG;
- MAX : Win32.LONG) return Win32.LONG is
-
- RETVAL : Win32.LONG;
-
- begin
- RETVAL := X;
- if X < MIN then
- RETVAL := MIN;
- elsif X > MAX then
- RETVAL := MAX;
- end if;
- return RETVAL;
- end Bound;
-
-
- --
- --/************************************************************************
- --* 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
-
- HPAL : WinDef.HPALETTE := null;
- LOGPALPTR : Win32.WinGdi.PLOGPALETTE;
- PAL : aliased Win32.WinGdi.LOGPALETTE;
-
- package Ext is new Extensible(Win32.WinGdi.LOGPALETTE,
- Win32.WinGdi.PALETTEENTRY,
- PAL.PALPALENTRY'position);
-
- function To_Plogpalette is new Unchecked_Conversion(Ext.Fixed_Ptr,
- Win32.WinGdi.PLOGPALETTE);
-
- PPAL : Ext.Extended_Ptr;
- PALPALENTRY : Ext.Big_Array_Ptr;
-
-
- begin
- PPAL := Ext.Allocate(NPAL);
- PALPALENTRY := Ext.Array_Part(PPAL);
- --if PPAL /= null then
- Ext.Fixed_Part(PPAL).PALVERSION := 16#300#;
- Ext.Fixed_Part(PPAL).PALNUMENTRIES := NPAL;
- for I in Interfaces.C.Unsigned range 0..NPAL - 1 loop
- PALPALENTRY(I).PEFLAGS := Win32.BYTE(WinGdi.PC_EXPLICIT);
- PALPALENTRY(I).PERED := Win32.BYTE(I);
- PALPALENTRY(I).PEGREEN := 0;
- PALPALENTRY(I).PEBLUE := 0;
- end loop;
- LOGPALPTR := To_Plogpalette(Ext.Fixed_Part(PPAL));
- HPAL := WinGdi.CreatePalette(LOGPALPTR);
- --end if;
- return HPAL;
- exception
- when constraint_error => HPAL := null; -- for breakpointing
- when others => HPAL := null; -- for breakpointing
- end CreatePhysicalPalette;
-
-
- --
- --/************************************************************************
- --* CalcZoomedSize
- --*
- --* Calculates some globals. This routine needs to be called any
- --* time that the size of the app or the zoom factor changes.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- procedure CalcZoomedSize is
-
- RC : WinDef.LPRECT;
-
- begin
- RC := new WinDef.RECT;
- bResult := WinUser.GetClientRect(GHWNDAPP, RC);
-
- GCXZOOMED := (RC.RIGHT / GNZOOM) + 1;
- GCYZOOMED := (RC.BOTTOM / GNZOOM) + 1;
- end CalcZoomedSize;
-
- --
- --/************************************************************************
- --* DoTheZoomIn
- --*
- --* Does the actual paint of the zoomed image.
- --*
- --* Arguments:
- --* HDC hdc - If not NULL, this hdc will be used to paint with.
- --* If NULL, a dc for the apps window will be obtained.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- procedure DoTheZoomIn(HDC_IN : WinDef.HDC) is
-
- HDC_P : WinDef.HDC;
- FRELEASE : Win32.BOOL;
- HPALOLD : WinDef.HPALETTE := null;
- HDCSCREEN : WinDef.HDC;
- X : Win32.LONG;
- Y : Win32.LONG;
-
- begin
- if HDC_IN = null then
- HDC_P := WinUser.GetDC(GHWNDAPP);
- FRELEASE := Win32.TRUE;
- else
- HDC_P := HDC_IN;
- FRELEASE := Win32.FALSE;
- end if;
- if GHPALPHYSICAL /= null then
- HPALOLD := WinGdi.SelectPalette(HDC_P, GHPALPHYSICAL, Win32.FALSE);
- uResult := WinGdi.RealizePalette(HDC_P);
- end if;
-
- -- /*
- -- * The point must not include areas outside the screen dimensions.
- -- */
- X := BOUND(GPTZOOM.X, GCXZOOMED / 2, GCXSCREENMAX - (GCXZOOMED / 2));
- Y := BOUND(GPTZOOM.Y, GCYZOOMED / 2, GCYSCREENMAX - (GCYZOOMED / 2));
-
- HDCSCREEN := WinUser.GetDC(null);
- siResult := WinGdi.SetStretchBltMode(HDC_P, WinGdi.COLORONCOLOR);
- bResult := WinGdi.StretchBlt(HDC_P, 0, 0,
- INT (GNZOOM * GCXZOOMED),
- INT (GNZOOM * GCYZOOMED),
- HDCSCREEN,
- INT (X - GCXZOOMED / 2),
- INT (Y - GCYZOOMED / 2),
- INT (GCXZOOMED),
- INT (GCYZOOMED), WinGdi.SRCCOPY);
- siResult := WinUser.ReleaseDC(null, HDCSCREEN);
-
- if HPALOLD /= null then
- hResult := WinGdi.SelectPalette(HDC_P, HPALOLD, Win32.FALSE);
- end if;
-
- if FRELEASE /= Win32.FALSE then
- siResult := WinUser.ReleaseDC(GHWNDAPP, HDC_P);
- end if;
- end DoTheZoomIn;
-
- --
- --/************************************************************************
- --* MoveView
- --*
- --* This function moves the current view around.
- --*
- --* Arguments:
- --* INT nDirectionCode - Direction to move. Must be VK_UP, VK_DOWN,
- --* VK_LEFT or VK_RIGHT.
- --* BOOL fFast - TRUE if the move should jump a larger increment.
- --* If FALSE, the move is just one pixel.
- --* BOOL fPeg - If TRUE, the view will be pegged to the screen
- --* boundary in the specified direction. This overides
- --* the fFast parameter.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- procedure MoveView(NDIRECTIONCODE : Win32.WPARAM;
- FFAST : Win32.BOOL;
- FPEG : Win32.BOOL) is
-
- DDELTA : Win32.LONG;
-
- begin
- if FFAST /= Win32.FALSE then
- DDELTA := FASTDELTA;
- else
- DDELTA := 1;
- end if;
- case NDIRECTIONCODE is
- when WinUser.VK_UP =>
- if FPEG /= Win32.FALSE then
- GPTZOOM.Y := GCYZOOMED / 2;
- else
- GPTZOOM.Y := GPTZOOM.Y - DDELTA;
- end if;
- GPTZOOM.Y := BOUND(GPTZOOM.Y, 0, GCYSCREENMAX);
-
- when WinUser.VK_DOWN =>
- if FPEG /= Win32.FALSE then
- GPTZOOM.Y := GCYSCREENMAX - (GCYZOOMED / 2);
- else
- GPTZOOM.Y := GPTZOOM.Y + DDELTA;
- end if;
- GPTZOOM.Y := BOUND(GPTZOOM.Y, 0, GCYSCREENMAX);
-
- when WinUser.VK_LEFT =>
- if FPEG /= Win32.FALSE then
- GPTZOOM.X := GCXZOOMED / 2;
- else
- GPTZOOM.X := GPTZOOM.X - DDELTA;
- end if;
- GPTZOOM.X := BOUND(GPTZOOM.X, 0, GCXSCREENMAX);
-
- when WinUser.VK_RIGHT =>
- if FPEG /= Win32.FALSE then
- GPTZOOM.X := GCXSCREENMAX - (GCXZOOMED / 2);
- else
- GPTZOOM.X := GPTZOOM.X + DDELTA;
- end if;
- GPTZOOM.X := BOUND(GPTZOOM.X, 0, GCXSCREENMAX);
-
- when others => null;
- end case;
- DoTheZoomIn(null);
- end MoveView;
-
- --
- --/************************************************************************
- --* DrawZoomRect
- --*
- --* This function draws the tracking rectangle. The size and shape of
- --* the rectangle will be proportional to the size and shape of the
- --* app's client, and will be affected by the zoom factor as well.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- procedure DrawZoomRect is
-
- HDC_P : WinDef.HDC;
- RC : WinDef.LPRECT;
- X : Win32.LONG;
- Y : Win32.LONG;
-
- begin
- X := BOUND(GPTZOOM.X, GCXZOOMED / 2, GCXSCREENMAX - (GCXZOOMED / 2));
- Y := BOUND(GPTZOOM.Y, GCYZOOMED / 2, GCYSCREENMAX - (GCYZOOMED / 2));
-
- RC := new WinDef.RECT;
-
- RC.LEFT := X - GCXZOOMED / 2;
- RC.TOP := Y - GCYZOOMED / 2;
- RC.RIGHT := RC.LEFT + GCXZOOMED;
- RC.BOTTOM := RC.TOP + GCYZOOMED;
-
- bResult := WinUser.InflateRect(RC, 1, 1);
-
- HDC_P := WinUser.GetDC(null);
-
- bResult := WinGdi.PatBlt(HDC_P, Win32.INT (RC.LEFT),
- Win32.INT (RC.TOP), Win32.INT (RC.RIGHT-RC.LEFT),
- 1, WinGdi.DSTINVERT);
- -- note: input types INT can also be input as Win32.INT
- bResult := WinGdi.PatBlt(HDC_P, INT (RC.LEFT),
- INT (RC.BOTTOM), 1,
- INT (-(RC.BOTTOM-RC.TOP)),
- WinGdi.DSTINVERT);
- bResult := WinGdi.PatBlt(HDC_P, INT (RC.RIGHT-1),
- INT (RC.TOP), 1,
- INT (RC.BOTTOM-RC.TOP),
- WinGdi.DSTINVERT);
- bResult := WinGdi.PatBlt(HDC_P, INT (RC.RIGHT),
- INT (RC.BOTTOM-1),
- INT (-(RC.RIGHT-RC.LEFT)), 1,
- WinGdi.DSTINVERT);
-
- siResult := WinUser.ReleaseDC(null, HDC_P);
- end DrawZoomRect;
-
- --
- --/************************************************************************
- --* EnableRefresh
- --*
- --* This function turns on or off the auto-refresh feature.
- --*
- --* Arguments:
- --* BOOL fEnable - TRUE to turn the refresh feature on, FALSE to
- --* turn it off.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- procedure EnableRefresh(FENABLE : Win32.BOOL) is
-
- URESULT : Win32.UINT;
-
- begin
- if FENABLE = Win32.TRUE then
- -- /*
- -- * Already enabled. Do nothing.
- -- */
- if GFREFENABLE = Win32.TRUE then
- return;
- end if;
- URESULT := WinUser.SetTimer(GHWNDAPP, idtimer_zoomin,
- GNREFINTERVAL * 100, null);
- if URESULT /= 0 then
- GFREFENABLE := Win32.TRUE;
- end if;
- else
- -- /*
- -- * Not enabled yet. Do nothing.
- -- */
- if GFREFENABLE = Win32.FALSE then
- return;
- end if;
- bResult := WinUser.KillTimer(GHWNDAPP, idtimer_zoomin);
- GFREFENABLE := Win32.FALSE;
- end if;
- end EnableRefresh;
-
- --
- --/************************************************************************
- --* CopyToClipboard
- --*
- --* This function copies the client area image of the app into the
- --* clipboard.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- procedure CopyToClipboard is
-
- HDCSRC : WinDef.HDC;
- HDCDST : WinDef.HDC;
- RC : WinDef.LPRECT;
- HBM : WinDef.HBITMAP;
- RESULT : Win32.BOOL;
- DEVCAPS : INT;
- SIZE_X : INT;
- SIZE_Y : INT;
-
- begin
- RESULT := WinUser.OpenClipboard(GHWNDAPP);
- if RESULT = Win32.TRUE then
- bResult := WinUser.EmptyClipboard;
- HDCSRC := WinUser.GetDC(GHWNDAPP);
- if HDCSRC /= null then
- RC := new WinDef.RECT;
- bResult := WinUser.GetClientRect(GHWNDAPP, RC);
- HBM := WinGdi.CreateCompatibleBitmap(HDCSRC,
- INT (RC.RIGHT - RC.LEFT),
- INT (RC.BOTTOM - RC.TOP));
- if HBM /= null then
- HDCDST := WinGdi.CreateCompatibleDC(HDCSRC);
- if HDCDST /= null then
- -- /*
- -- * Calculate the dimensions of the bitmap and
- -- * convert them to tenths of a millimeter for
- -- * setting the size with the SetBitmapDimensionEx
- -- * call. This allows programs like WinWord to
- -- * retrieve the bitmap and know what size to
- -- * display it as.
- -- */
-
- DEVCAPS := WinGdi.GetDeviceCaps(HDCSRC, WinGdi.LOGPIXELSX);
- SIZE_X := INT ((RC.RIGHT - RC.LEFT) * mm10perinch) / DEVCAPS;
- DEVCAPS := WinGdi.GetDeviceCaps(HDCSRC, WinGdi.LOGPIXELSY);
- SIZE_Y := INT ((RC.BOTTOM - RC.TOP) * mm10perinch) / DEVCAPS;
- bResult := WinGdi.SetBitmapDimensionEx(HBM, SIZE_X, SIZE_Y, null);
- hgdiResult := WinGdi.SelectObject(HDCDST, WinDef.HGDIOBJ(HBM));
- bResult := WinGdi.BitBlt(HDCDST, 0, 0,
- INT (RC.RIGHT - RC.LEFT),
- INT (RC.BOTTOM - RC.TOP),
- HDCSRC,
- INT (RC.LEFT),
- INT (RC.TOP), WinGdi.SRCCOPY);
- bResult := WinGdi.DeleteDC(HDCDST);
- handResult := WinUser.SetClipboardData(WinUser.CF_BITMAP,
- Winnt.HANDLE (HBM));
- else
- bResult := WinGdi.DeleteObject(WinDef.HGDIOBJ(HBM));
- end if;
- end if;
- end if;
- siResult := WinUser.ReleaseDC(ghwndApp, hdcSrc);
- bResult := WinUser.CloseClipboard;
- else
- bResult := WinUser.MessageBeep(0);
- end if;
- end CopyToClipBoard;
-
- --
- --/************************************************************************
- --* AboutDlgProc
- --*
- --* This is the About Box dialog procedure.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- function AboutDlgProc(HWND_P : WinDef.HWND;
- MSG : Win32.UINT;
- WPARAM_P : Win32.WPARAM;
- LPARAM_P : Win32.LPARAM) return Win32.BOOL;
- pragma Convention(Stdcall, AboutDlgProc);
-
- function AboutDlgProc(HWND_P : WinDef.HWND;
- MSG : Win32.UINT;
- WPARAM_P : Win32.WPARAM;
- LPARAM_P : Win32.LPARAM) return Win32.BOOL is
-
- RETVAL : Win32.BOOL;
-
- begin
- case MSG is
- when WinUser.WM_INITDIALOG =>
- RETVAL := Win32.TRUE;
-
- when WinUser.WM_COMMAND =>
- bResult := WinUser.EndDialog(HWND_P, WinUser.IDOK);
- RETVAL := Win32.TRUE;
-
- when others =>
- RETVAL := Win32.FALSE;
-
- end case;
- return RETVAL;
- end AboutDlgProc;
-
- --
- --/************************************************************************
- --* RefreshRateDlgProc
- --*
- --* This is the Refresh Rate dialog procedure.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- function RefreshRateDlgProc(HWND_P : WinDef.HWND;
- MSG : Win32.UINT;
- WPARAM_P : Win32.WPARAM;
- LPARAM_P : Win32.LPARAM) return Win32.BOOL;
- pragma Convention(Stdcall, RefreshRateDlgProc);
-
- function RefreshRateDlgProc(HWND_P : WinDef.HWND;
- MSG : Win32.UINT;
- WPARAM_P : Win32.WPARAM;
- LPARAM_P : Win32.LPARAM) return Win32.BOOL is
-
- FTRANSLATED : aliased Win32.BYTE;
- RETVAL : Win32.BOOL;
-
- begin
- RETVAL := Win32.FALSE;
- case MSG is
- when WinUser.WM_INITDIALOG =>
- longResult := WinUser.SendDlgItemMessage(HWND_P, did_refreshrateinterval,
- WinUser.EM_LIMITTEXT, 3, 0);
- bResult := WinUser.SetDlgItemInt(HWND_P, did_refreshrateinterval,
- GNREFINTERVAL, Win32.FALSE);
- bResult := WinUser.CheckDlgButton(HWND_P, did_refreshrateenable,
- Win32.UINT(GFREFENABLE));
- RETVAL := Win32.TRUE;
-
- when WinUser.WM_COMMAND =>
- case Utils.LoWord(DWORD(WPARAM_P)) is
- when WinUser.IDOK =>
- GNREFINTERVAL := WinUSer.GetDlgItemInt(HWND_P,
- did_refreshrateinterval,
- FTRANSLATED'access,
- Win32.FALSE);
- -- /*
- -- * Stop any existing timers then start one with the
- -- * new interval if requested to.
- -- */
- EnableRefresh(Win32.FALSE);
- EnableRefresh(Win32.BOOL(
- WinUser.IsDlgButtonChecked(HWND_P, did_refreshrateenable)));
- bResult := WinUser.EndDialog(HWND_P, WinUser.IDOK);
-
- when WinUser.IDCANCEL =>
- bResult := WinUser.EndDialog(HWND_P, WinUser.IDCANCEL);
-
- when others =>
- null;
- end case;
-
- when others =>
- null;
- end case;
- return RETVAL;
- end RefreshRateDlgProc;
-
- --/************************************************************************
- --* AppWndProc
- --*
- --* Main window proc for the zoomin utility.
- --*
- --* Arguments:
- --* Standard window proc args.
- --*
- --* History:
- --*
- --************************************************************************/
- --
- function AppWndProc(HWND_P : WinDef.HWND;
- MSG : Win32.UINT;
- WPARAM_P : Win32.WPARAM;
- LPARAM_P : Win32.LPARAM) return Win32.LRESULT;
- pragma Convention(Stdcall, AppWndProc);
-
- function AppWndProc(HWND_P : WinDef.HWND;
- MSG : Win32.UINT;
- WPARAM_P : Win32.WPARAM;
- LPARAM_P : Win32.LPARAM) return Win32.LRESULT is
-
- PS : WinUser.LPPAINTSTRUCT;
- HCUROLD : WinDef.HCURSOR;
- RETVAL : Win32.LRESULT;
-
- begin
- RETVAL := 0;
- case MSG is
- when WinUser.WM_CREATE =>
- bResult := WinUser.SetScrollRange(hwnd_p, WinUser.SB_VERT,
- MIN_ZOOM, MAX_ZOOM,
- Win32.FALSE);
- siResult := WinUser.SetScrollPos(hwnd_p, WinUser.SB_VERT,
- INT (GNZOOM), Win32.FALSE);
-
- when WinUser.WM_TIMER =>
- -- /*
- -- * Update on every timer message. The cursor will be
- -- * flashed to the hourglash for some visual feedback
- -- * of when a snapshot is being taken.
- -- */
- HCUROLD := WinUser.SetCursor(WinUser.LoadCursor(null,
- LPCSTR(WinUser.IDC_WAIT)));
- DoTheZoomIn(null);
- hcurResult := WinUser.SetCursor(HCUROLD);
-
- when WinUser.WM_PAINT =>
- PS := new WinUser.PAINTSTRUCT;
- handResult := Winnt.HANDLE(WinUser.BeginPaint(HWND_P, PS));
- DoTheZoomIn(PS.HDC);
- bResult := WinUser.EndPaint(HWND_P, Win32.WinUser.ac_PAINTt(PS));
-
- when WinUser.WM_SIZE =>
- CalcZoomedSize;
-
- when WinUser.WM_LBUTTONDOWN =>
- GPTZOOM.X := Win32.LONG(Utils.LoWord(DWORD(LPARAM_P)));
- GPTZOOM.Y := Win32.LONG(Utils.HiWord(DWORD(LPARAM_P)));
- bResult := WinUser.ClientToScreen(HWND_P, GPTZOOM);
- DrawZoomRect;
- DoTheZoomIn(null);
-
- handResult := Winnt.HANDLE (WinUser.SetCapture(HWND_P));
- GFTRACKING := Win32.TRUE;
-
- when WinUser.WM_MOUSEMOVE =>
- if GFTRACKING = Win32.TRUE then
- DrawZoomRect;
- GPTZOOM.X := Win32.LONG(Utils.LoWord(DWORD(LPARAM_P)));
- GPTZOOM.Y := Win32.LONG(Utils.HiWord(DWORD(LPARAM_P)));
- bResult := WinUser.ClientToScreen(HWND_P, GPTZOOM);
- DrawZoomRect;
- DoTheZoomIn(null);
- end if;
-
- when WinUser.WM_LBUTTONUP =>
- if gfTracking = Win32.TRUE then
- DrawZoomRect;
- bResult := WinUser.ReleaseCapture;
- GFTRACKING := Win32.FALSE;
- end if;
-
- when WinUser.WM_VSCROLL =>
- case Utils.LoWord(DWORD(WPARAM_P)) is
- when WinUser.SB_LINEDOWN =>
- GNZOOM := GNZOOM + 1;
-
- when WinUser.SB_LINEUP =>
- GNZOOM := GNZOOM - 1;
-
- when WinUser.SB_PAGEUP =>
- GNZOOM := GNZOOM - 2;
-
- when WinUser.SB_PAGEDOWN =>
- GNZOOM := GNZOOM + 2;
-
- when WinUser.SB_THUMBPOSITION | WinUser.SB_THUMBTRACK =>
- GNZOOM := Win32.LONG(Utils.HiWord(DWORD(WPARAM_P)));
-
- when others => null;
- end case;
-
- GNZOOM := BOUND(GNZOOM, MIN_ZOOM, MAX_ZOOM);
- siResult := WinUser.SetScrollPos(HWND_P, WinUser.SB_VERT,
- INT (GNZOOM), Win32.TRUE);
- CalcZoomedSize;
- DoTheZoomIn(null);
-
- when WinUser.WM_KEYDOWN =>
- case WPARAM_P is
- when WinUser.VK_UP |
- WinUser.VK_DOWN |
- WinUser.VK_LEFT |
- WinUser.VK_RIGHT =>
- MoveView(WPARAM_P,
- Win32.BOOL(Win32.USHORT (Win32.USHORT (
- WinUser.GetKeyState(WinUser.VK_SHIFT)) and
- Win32.USHORT(16#8000#))),
- Win32.BOOL(Win32.USHORT (Win32.USHORT (
- WinUser.GetKeyState(WinUser.VK_CONTROL)) and
- Win32.USHORT(16#8000#))));
- when others => null;
- end case;
-
- when WinUser.WM_COMMAND =>
- case Utils.LoWord(DWORD(WPARAM_P)) is
- when MENU_EDIT_COPY =>
- CopyToClipBoard;
-
- when MENU_EDIT_REFRESH =>
- DoTheZoomIn(null);
-
- when MENU_OPTIONS_REFRESHRATE =>
- siResult := WinUser.DialogBox(GHINST,
- LPCSTR(WinUser.MAKEINTRESOURCE(DID_REFRESHRATE)),
- HWND_P,
- RefreshRateDlgProc'access);
-
- when MENU_HELP_ABOUT =>
- siResult := WinUser.DialogBox(GHINST,
- LPCSTR(WinUser.MAKEINTRESOURCE(DID_ABOUT)),
- HWND_P,
- AboutDlgProc'access);
-
- when others => null;
- end case;
-
- when WinUser.WM_CLOSE =>
- if GHPALPHYSICAL /= null then
- bResult := WinGdi.DeleteObject(WinDef.HGDIOBJ(GHPALPHYSICAL));
- end if;
- bResult := WinUser.DestroyWindow(HWND_P);
-
- when WinUser.WM_DESTROY =>
- WinUser.PostQuitMessage(0);
-
- when others =>
- RETVAL := WinUser.DefWindowProc(HWND_P, MSG, WPARAM_P, LPARAM_P);
- end case;
- return RETVAL;
- end AppWndProc;
-
- --
- --/************************************************************************
- --* InitInstance
- --*
- --* Instance initialization for the app.
- --*
- --* Arguments:
- --*
- --* History:
- --*
- --************************************************************************/
- --
- function InitInstance(HINST : WinDef.HINSTANCE;
- CMDSHOW : Win32.INT) return Win32.BOOL is
-
- icon_str : aliased constant Interfaces.C.CHAR_ARRAY :=
- Interfaces.C.To_C("zoomin");
- icon : constant LPCSTR := icon_str(icon_str'first)'access;
-
- WC : aliased WinUser.WNDCLASS;
- DX : Win32.LONG;
- DY : Win32.LONG;
- FLSTYLE : Win32.DWORD;
- RC : WinDef.LPRECT;
- BRESULT : BOOL;
- IRESULT : INT;
- BUFFER : aliased Interfaces.C.CHAR_ARRAY(0..1023);
- SYSTEM_MSG : LPSTR;
- ERROR_LEN : DWORD;
-
- begin
- GHINST := HINST;
- -- /*
- -- * Register a class for the main application window.
- -- */
- --WC := new WinUser.WNDCLASS_T;
- WC.HCURSOR := WinUser.LoadCursor(null, LPCSTR(WinUser.IDC_ARROW));
- WC.HICON := WinUser.LoadIcon(HINST, icon);
- WC.LPSZMENUNAME := LPCSTR(WinUser.MakeIntResource(IDMENU_ZOOMIN));
- WC.LPSZCLASSNAME := SZAPPNAME;
- WC.HBRBACKGROUND := WinDef.HBRUSH(WinGdi.GetStockObject(WinGdi.BLACK_BRUSH));
- WC.HINSTANCE := HINST;
- WC.STYLE := WinUser.CS_BYTEALIGNCLIENT or WinUser.CS_VREDRAW or
- WinUser.CS_HREDRAW;
- WC.LPFNWNDPROC := AppWndProc'access;
- WC.CBWNDEXTRA := 0;
- WC.CBCLSEXTRA := 0;
-
- if WinUser.RegisterClass(WC'access) = 0 then
- SYSTEM_MSG := BUFFER(BUFFER'first)'access;
- ERROR_LEN := Win32.WinBase.FormatMessage(
- Win32.WinBase.format_message_from_system,
- null,
- Win32.WinBase.GetLastError,
- DWORD(Win32.WinNT.MakeLangId(
- Win32.WinNT.lang_english,
- Win32.WinNT.sublang_english_us)),
- SYSTEM_MSG,
- DWORD(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 = null then
- return Win32.FALSE;
- end if;
-
- GHPALPHYSICAL := CreatePhysicalPalette;
- if GHPALPHYSICAL = null 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 => null,
- hMenu => null,
- hInstance => HINST,
- lpParam => null);
-
- if GHWNDAPP = null 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, null, 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;
-