[ros-diffs] [cfinck] 27811: Add a "magnify" application developed by Marc Piulachs (marc.piulachs AT codexchange DOT net) Isn't finished and lights up some bugs in ReactOS, but at least it's a start See issue #2463 for more details.

cfinck at svn.reactos.org cfinck at svn.reactos.org
Wed Jul 25 20:00:56 CEST 2007


Author: cfinck
Date: Wed Jul 25 22:00:56 2007
New Revision: 27811

URL: http://svn.reactos.org/svn/reactos?rev=27811&view=rev
Log:
Add a "magnify" application developed by Marc Piulachs (marc.piulachs AT codexchange DOT net)
Isn't finished and lights up some bugs in ReactOS, but at least it's a start
See issue #2463 for more details.

Added:
    trunk/rosapps/magnify/
    trunk/rosapps/magnify/lang/
    trunk/rosapps/magnify/lang/en-US.rc
    trunk/rosapps/magnify/magnifier.c
    trunk/rosapps/magnify/magnifier.h
    trunk/rosapps/magnify/magnify.rbuild
    trunk/rosapps/magnify/magnify.rc
    trunk/rosapps/magnify/res/
    trunk/rosapps/magnify/res/magnify.ico   (with props)
    trunk/rosapps/magnify/resource.h
    trunk/rosapps/magnify/settings.c
Modified:
    trunk/rosapps/directory.rbuild

Modified: trunk/rosapps/directory.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/directory.rbuild?rev=27811&r1=27810&r2=27811&view=diff
==============================================================================
--- trunk/rosapps/directory.rbuild (original)
+++ trunk/rosapps/directory.rbuild Wed Jul 25 22:00:56 2007
@@ -44,6 +44,11 @@
 	<xi:include href="lib/directory.rbuild" />
 </directory>
 -->
+
+<directory name="magnify">
+	<xi:include href="magnify/magnify.rbuild" />
+</directory>
+
 <directory name="mc">
 	<xi:include href="mc/mc.rbuild" />
 </directory>

Added: trunk/rosapps/magnify/lang/en-US.rc
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/magnify/lang/en-US.rc?rev=27811&view=auto
==============================================================================
--- trunk/rosapps/magnify/lang/en-US.rc (added)
+++ trunk/rosapps/magnify/lang/en-US.rc Wed Jul 25 22:00:56 2007
@@ -1,0 +1,213 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON                ICON                    "res/magnify.ico"
+#endif    // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_MAGNIFIER           ICON                    "res/Magnify.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDC_MAGNIFIER MENU 
+BEGIN
+    POPUP "&File"
+    BEGIN
+        MENUITEM "E&xit",                       IDM_EXIT
+        MENUITEM "&Options",                    IDM_OPTIONS
+        MENUITEM SEPARATOR
+        MENUITEM "&About ...",                  IDM_ABOUT
+    END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDC_MAGNIFIER ACCELERATORS 
+BEGIN
+    "?",            IDM_ABOUT,              ASCII,  ALT
+    "/",            IDM_ABOUT,              ASCII,  ALT
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUTBOX DIALOGEX 22, 17, 220, 75
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_CAPTION | WS_SYSMENU
+CAPTION "About"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+    ICON            IDI_MAGNIFIER,IDC_MYICON,14,9,20,20
+    LTEXT           "Magnifier Version 1.0",IDC_STATIC,49,10,119,8,SS_NOPREFIX
+    LTEXT           "Copyright (C) 2007 Marc Piulachs (marc.piulachs at codexchange.net)",IDC_STATIC,48,24,125,22
+    PUSHBUTTON      "Ok",IDOK,162,48,50,14
+END
+
+IDD_DIALOGOPTIONS DIALOGEX 0, 0, 153, 182
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Magnifier Settings"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+    DEFPUSHBUTTON   "Exit",IDOK,96,161,50,14
+    PUSHBUTTON      "Help",IDOK,38,161,50,14
+    LTEXT           "Magnification level :",IDC_STATIC,6,12,68,8
+    COMBOBOX        IDC_ZOOM,72,6,63,66,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+    GROUPBOX        "Tracking",IDC_STATIC,7,25,139,59
+    GROUPBOX        "Presentation",IDC_STATIC,7,87,139,57
+    CONTROL         "Follow mouse cursor",IDC_FOLLOWMOUSECHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,42,114,10
+    CONTROL         "Follow keyboard focus",IDC_FOLOWKEYBOARDCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,54,114,10
+    CONTROL         "Follow text editing",IDC_FOLLOWTEXTEDITINGCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,66,114,10
+    CONTROL         "Invert colors",IDC_INVERTCOLORSCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,102,114,10
+    CONTROL         "Start Minimized",IDC_STARTMINIMIZEDCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,114,114,10
+    CONTROL         "Show Magnifier",IDC_SHOWMAGNIFIERCHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,126,114,10
+END
+
+IDD_WARNINGDIALOG DIALOGEX 0, 0, 250, 97
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION
+CAPTION "ReactOS Magnifier"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+    DEFPUSHBUTTON   "OK",IDOK,193,76,50,14
+    ICON            IDI_MAGNIFIER,IDC_STATIC,7,17,20,20
+    LTEXT           "Magnifier is intended to provide a minium level of funcionality for users with slight visual impairments. Most users with visual impairments will need a magnigication utility with higher funcionality for deily use.",IDC_STATIC,36,7,207,33
+    CONTROL         "Do not show this message again",IDC_SHOWWARNINGCHECK,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,43,80,137,10
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE 
+BEGIN
+    "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+    "#include ""windows.h""\r\n"
+    "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO 
+BEGIN
+    IDD_DIALOGOPTIONS, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 146
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 175
+    END
+
+    IDD_WARNINGDIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 243
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 90
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE 
+BEGIN
+    IDS_APP_TITLE           "Magnifier"
+    IDC_MAGNIFIER           "MAGNIFIER"
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+

Added: trunk/rosapps/magnify/magnifier.c
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/magnify/magnifier.c?rev=27811&view=auto
==============================================================================
--- trunk/rosapps/magnify/magnifier.c (added)
+++ trunk/rosapps/magnify/magnifier.c Wed Jul 25 22:00:56 2007
@@ -1,0 +1,562 @@
+/*
+ * PROJECT:     ReactOS Magnify
+ * LICENSE:     GPL - See COPYING in the top level directory
+ * FILE:        base/applications/magnify/magnifier.c
+ * PURPOSE:     
+ * COPYRIGHT:   Copyright 2007 Marc Piulachs <marc.piulachs at codexchange.net>
+ *
+ */
+
+#include <windows.h>
+//#include <stdio.h>
+#include <shellapi.h>
+
+#include "shellapi.h"
+#include "windows.h"
+
+#include "magnifier.h"
+#include "resource.h"
+
+#define MAX_LOADSTRING 100
+
+// Global Variables:
+HINSTANCE hInst;								// current instance
+HWND hMainWnd;
+
+TCHAR szTitle[MAX_LOADSTRING];					// The title bar text
+TCHAR szWindowClass[MAX_LOADSTRING];			// the main window class name
+
+#define REPAINT_SPEED	100
+
+HWND hDesktopWindow = NULL;
+
+//Current magnified area
+POINT cp;
+
+//Last positions
+POINT pMouse;
+POINT pCaret;
+POINT pFocus;
+
+// Forward declarations of functions included in this code module:
+ATOM				MyRegisterClass(HINSTANCE hInstance);
+BOOL				InitInstance(HINSTANCE, int);
+LRESULT CALLBACK	WndProc(HWND, UINT, WPARAM, LPARAM);
+INT_PTR CALLBACK	AboutProc(HWND, UINT, WPARAM, LPARAM);
+INT_PTR CALLBACK	OptionsProc(HWND, UINT, WPARAM, LPARAM);
+INT_PTR CALLBACK	WarningProc(HWND, UINT, WPARAM, LPARAM);
+
+int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+	UNREFERENCED_PARAMETER(hPrevInstance);
+	UNREFERENCED_PARAMETER(lpCmdLine);
+
+ 	// TODO: Place code here.
+	MSG msg;
+	HACCEL hAccelTable;
+
+	// Initialize global strings
+	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+	LoadString(hInstance, IDC_MAGNIFIER, szWindowClass, MAX_LOADSTRING);
+	MyRegisterClass(hInstance);
+
+	// Perform application initialization:
+	if (!InitInstance (hInstance, nCmdShow))
+	{
+		return FALSE;
+	}
+
+	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_MAGNIFIER));
+
+	// Main message loop:
+	while (GetMessage(&msg, NULL, 0, 0))
+	{
+		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
+		{
+			TranslateMessage(&msg);
+			DispatchMessage(&msg);
+		}
+	}
+
+	return (int) msg.wParam;
+}
+
+
+
+//
+//  FUNCTION: MyRegisterClass()
+//
+//  PURPOSE: Registers the window class.
+//
+//  COMMENTS:
+//
+//    This function and its usage are only necessary if you want this code
+//    to be compatible with Win32 systems prior to the 'RegisterClassEx'
+//    function that was added to Windows 95. It is important to call this function
+//    so that the application will get 'well formed' small icons associated
+//    with it.
+//
+ATOM MyRegisterClass(HINSTANCE hInstance)
+{
+	WNDCLASSEX wcex;
+
+	wcex.cbSize = sizeof(WNDCLASSEX);
+
+	wcex.style			= CS_HREDRAW | CS_VREDRAW; 
+	wcex.lpfnWndProc	= WndProc;
+	wcex.cbClsExtra		= 0;
+	wcex.cbWndExtra		= 0;
+	wcex.hInstance		= hInstance;
+	wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAGNIFIER));
+	wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
+	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
+	wcex.lpszMenuName	= MAKEINTRESOURCE(IDC_MAGNIFIER);
+	wcex.lpszClassName	= szWindowClass;
+	wcex.hIconSm		= LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
+
+	return RegisterClassEx(&wcex);
+}
+
+//
+//   FUNCTION: InitInstance(HINSTANCE, int)
+//
+//   PURPOSE: Saves instance handle and creates main window
+//
+//   COMMENTS:
+//
+//        In this function, we save the instance handle in a global variable and
+//        create and display the main program window.
+//
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+   hInst = hInstance; // Store instance handle in our global variable
+
+	// Create the Window
+   hMainWnd = CreateWindowEx(
+	    WS_EX_TOPMOST,
+		szWindowClass, 
+		szTitle, 
+		WS_OVERLAPPEDWINDOW,
+		CW_USEDEFAULT, 
+		CW_USEDEFAULT, 
+		CW_USEDEFAULT, 
+		CW_USEDEFAULT, 
+		NULL, 
+		NULL, 
+		hInstance, 
+		NULL);
+
+   if (!hMainWnd)
+   {
+      return FALSE;
+   }
+
+   ShowWindow(hMainWnd, nCmdShow);
+   UpdateWindow(hMainWnd);
+
+   return TRUE;
+}
+
+void Refresh ()
+{
+	if (!IsIconic(hMainWnd))
+	{
+		// Invalidate the client area forcing a WM_PAINT message 
+		InvalidateRgn(hMainWnd, NULL, TRUE); 
+	}
+}
+
+void Draw(HDC aDc)
+{
+	HDC desktopHdc = NULL;
+	HDC HdcStrech;
+	HANDLE hOld;
+	HBITMAP HbmpStrech;
+
+	RECT R;
+	RECT appRect;
+	DWORD rop = SRCCOPY;
+	HCURSOR hCursor;
+	CURSORINFO info;
+
+	desktopHdc = GetWindowDC (hDesktopWindow);
+
+	GetClientRect(hMainWnd, &appRect);
+	GetWindowRect(hDesktopWindow, &R);
+
+    memset(&info, 0, sizeof(info));
+    info.cbSize = sizeof(info);
+    GetCursorInfo(&info);
+    hCursor = info.hCursor;
+
+	 /* Create a memory DC compatible with client area DC.*/ 
+	HdcStrech = CreateCompatibleDC(desktopHdc); 
+	   
+	/* Create a bitmap compatible with the client area DC.*/ 
+	HbmpStrech = CreateCompatibleBitmap(
+		desktopHdc,
+		R.right,
+		R.bottom); 
+
+	/* Select our bitmap in memory DC and save the old one.*/ 
+	hOld = SelectObject (HdcStrech , HbmpStrech);
+
+	/* Paint the screen bitmap to our in memory DC */
+	BitBlt(
+		HdcStrech,
+		0,
+		0,
+		R.right,
+		R.bottom,
+		desktopHdc,
+		0,
+		0,
+		SRCCOPY);
+
+	/* Draw the mouse pointer in the right position */
+	DrawIcon(
+		HdcStrech , 
+		pMouse.x - 10, 
+		pMouse.y - 10, 
+		hCursor);
+
+	int Width = (R.right - R.left);
+	int Height = (R.bottom - R.top);
+
+	int AppWidth = (appRect.right - appRect.left);
+	int AppHeight = (appRect.bottom - appRect.top);
+
+	LONG blitAreaWidth = AppWidth / iZoom;
+	LONG blitAreaHeight = AppHeight / iZoom;
+
+	LONG blitAreaX = (cp.x) - (blitAreaWidth /2);
+	LONG blitAreaY = (cp.y) - (blitAreaHeight /2);
+
+	if (blitAreaX < 0)
+	{
+	   blitAreaX = 0;
+	}
+
+	if (blitAreaY < 0)
+	{
+	   blitAreaY = 0;
+	}
+
+	if (blitAreaX > (Width - blitAreaWidth))
+	{
+		blitAreaX = (Width - blitAreaWidth);
+	}
+
+	if (blitAreaY > (Height - blitAreaHeight))
+	{
+		blitAreaY = (Height - blitAreaHeight);
+	}
+
+	if (bInvertColors)
+	{
+		rop = NOTSRCCOPY;
+	}
+
+	StretchBlt(
+		HdcStrech,
+		0,
+		0,
+		AppWidth,
+		AppHeight,
+		HdcStrech,
+		blitAreaX,
+		blitAreaY,
+		blitAreaWidth,
+		blitAreaHeight,
+		rop);
+
+	/* Blast the image from memory DC to client DC.*/ 
+	BitBlt (
+		aDc,
+		0 , 
+		0 , 
+		AppWidth ,
+		AppHeight ,
+		HdcStrech ,
+		0 ,
+		0 , 
+		SRCCOPY);
+
+	/* Cleanup.*/ 
+	SelectObject (HdcStrech, hOld);
+	DeleteObject (HbmpStrech);
+	DeleteDC (HdcStrech);
+}
+
+//
+//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
+//
+//  PURPOSE:  Processes messages for the main window.
+//
+//  WM_COMMAND	- process the application menu
+//  WM_PAINT	- Paint the main window
+//  WM_DESTROY	- post a quit message and return
+//
+//
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+	int wmId, wmEvent;
+
+	switch (message)
+	{
+		case WM_TIMER:
+		{
+			POINT pNewMouse;
+			POINT pNewCaret;
+			POINT pNewFocus;
+
+			//Get current mouse position 
+			GetCursorPos (&pNewMouse);
+
+			//Get caret position
+			HWND hwnd1 = GetForegroundWindow (); 
+			DWORD a = GetWindowThreadProcessId(hwnd1, NULL); 
+			DWORD b = GetCurrentThreadId(); 
+			AttachThreadInput (a, b, TRUE); 
+			HWND hwnd2 = GetFocus(); 
+
+			GetCaretPos( &pNewCaret); 
+			ClientToScreen (hwnd2, (LPPOINT) &pNewCaret); 
+			AttachThreadInput (a, b, FALSE); 
+
+			//Get current control focus
+			HWND hwnd3 = GetFocus ();
+			RECT controlRect;
+			GetWindowRect (hwnd3 , &controlRect);
+			pNewFocus.x = controlRect.left;
+			pNewFocus.y = controlRect.top;
+
+			//If mouse has moved ....
+			if (((pMouse.x != pNewMouse.x) || (pMouse.y != pNewMouse.y)) && bFollowMouse)
+			{
+				//Update to new position
+				pMouse = pNewMouse;
+				cp = pNewMouse;
+				Refresh();
+			}
+			else if (((pCaret.x != pNewCaret.x) || (pCaret.y != pNewCaret.y)) && bFollowCaret)
+			{
+				//Update to new position
+				pCaret = pNewCaret;
+				cp = pNewCaret;
+				Refresh();
+			}
+			else if (((pFocus.x != pNewFocus.x) || (pFocus.y != pNewFocus.y)) && bFollowFocus)
+			{
+				//Update to new position
+				pFocus = pNewFocus;
+				cp = pNewFocus;
+				Refresh();
+			}
+		}
+		break;
+	case WM_COMMAND:
+		wmId    = LOWORD(wParam);
+		wmEvent = HIWORD(wParam);
+		// Parse the menu selections:
+		switch (wmId)
+		{
+			case IDM_OPTIONS:
+				DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOGOPTIONS), hWnd, (DLGPROC)OptionsProc);
+				break;
+			case IDM_ABOUT:
+				DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)AboutProc);
+				break;
+			case IDM_EXIT:
+				DestroyWindow(hWnd);
+				break;
+			default:
+				return DefWindowProc(hWnd, message, wParam, lParam);
+		}
+		break;
+   case WM_PAINT:
+		{
+			PAINTSTRUCT PaintStruct;
+			HDC dc;
+			dc = BeginPaint(hWnd, &PaintStruct);
+			Draw(dc);
+			EndPaint(hWnd, &PaintStruct);
+		}
+      break;
+   case WM_ERASEBKGND:
+		//handle WM_ERASEBKGND by simply returning non-zero because we did all the drawing in WM_PAINT. 
+	   break;
+	case WM_DESTROY:
+		//Save settings to registry
+		SaveSettings ();
+		KillTimer (hWnd , 1);
+		PostQuitMessage(0);
+		break;
+	case WM_CREATE:
+			//Load settings from registry
+			LoadSettings ();
+
+			//Get the desktop window
+			hDesktopWindow = GetDesktopWindow();
+			
+			if (bShowWarning)
+			{
+				DialogBox (hInst, MAKEINTRESOURCE(IDD_WARNINGDIALOG), hWnd, (DLGPROC)WarningProc);
+			}
+
+			if (bStartMinimized)
+			{
+				ShowWindow (hMainWnd, SW_MINIMIZE );
+			}
+			
+			//Set the timer 
+			SetTimer (hWnd , 1, REPAINT_SPEED , NULL);
+			break;
+	default:
+		return DefWindowProc(hWnd, message, wParam, lParam);
+	}
+	return 0;
+}
+
+// Message handler for about box.
+INT_PTR CALLBACK AboutProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+	UNREFERENCED_PARAMETER(lParam);
+	switch (message)
+	{
+	case WM_INITDIALOG:
+		return (INT_PTR)TRUE;
+
+	case WM_COMMAND:
+		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
+		{
+			EndDialog(hDlg, LOWORD(wParam));
+			return (INT_PTR)TRUE;
+		}
+		break;
+	}
+	return (INT_PTR)FALSE;
+}
+
+// Message handler for options box.
+INT_PTR CALLBACK OptionsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+	UNREFERENCED_PARAMETER(lParam);
+	switch (message)
+	{
+		case WM_INITDIALOG:
+		{
+			//Add the zoom items....
+			SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("1"));
+			SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("2"));
+			SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("3"));
+			SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("4"));
+			SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("5"));
+			SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("6"));
+			SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("7"));
+			SendDlgItemMessage(hDlg, IDC_ZOOM, CB_ADDSTRING, 0, (LPARAM)("8"));
+
+			//
+			SendDlgItemMessage(hDlg, IDC_ZOOM, CB_SETCURSEL, iZoom - 1, 0);
+
+			if (bFollowMouse)
+				SendDlgItemMessage(hDlg,IDC_FOLLOWMOUSECHECK,BM_SETCHECK , wParam ,0);
+
+			if (bFollowFocus)
+				SendDlgItemMessage(hDlg,IDC_FOLOWKEYBOARDCHECK,BM_SETCHECK , wParam ,0);
+
+			if (bFollowCaret)
+				SendDlgItemMessage(hDlg,IDC_FOLLOWTEXTEDITINGCHECK,BM_SETCHECK , wParam ,0);
+
+			if (bInvertColors)
+				SendDlgItemMessage(hDlg,IDC_INVERTCOLORSCHECK,BM_SETCHECK , wParam ,0);
+
+			if (bStartMinimized)
+				SendDlgItemMessage(hDlg,IDC_STARTMINIMIZEDCHECK,BM_SETCHECK , wParam ,0);
+
+			if (bShowMagnifier)
+				SendDlgItemMessage(hDlg,IDC_SHOWMAGNIFIERCHECK,BM_SETCHECK , wParam ,0);
+
+			return (INT_PTR)TRUE;
+		}
+	case WM_COMMAND:
+		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
+		{
+			EndDialog(hDlg, LOWORD(wParam));
+			return (INT_PTR)TRUE;
+		}
+		if (LOWORD(wParam) == IDOK)
+		{
+		}
+		if (LOWORD(wParam) == IDHELP)
+		{
+			MessageBox(hDlg , TEXT("Magnifier help not available yet!") , TEXT("Help") , MB_OK);
+		}
+		switch(LOWORD(wParam))
+		{
+            case IDC_ZOOM:
+				if(HIWORD(wParam) == CBN_SELCHANGE) 
+				{ 
+					HWND hCombo = GetDlgItem(hDlg,IDC_ZOOM);
+
+					/* Get index of current selection and the text of that selection. */ 
+					iZoom = SendMessage( hCombo, CB_GETCURSEL, (WPARAM) wParam, (LPARAM) lParam ) + 1;
+
+					//Update the magnigier UI
+					Refresh ();
+				}
+				break;
+			case IDC_INVERTCOLORSCHECK:
+				bInvertColors = IsDlgButtonChecked (hDlg, IDC_INVERTCOLORSCHECK);
+				Refresh ();
+				break;
+			case IDC_FOLLOWMOUSECHECK:
+				bFollowMouse = IsDlgButtonChecked (hDlg, IDC_FOLLOWMOUSECHECK);
+				break;
+			case IDC_FOLOWKEYBOARDCHECK:
+				bFollowFocus = IsDlgButtonChecked (hDlg, IDC_FOLOWKEYBOARDCHECK);
+				break;
+			case IDC_FOLLOWTEXTEDITINGCHECK:
+				bFollowCaret = IsDlgButtonChecked (hDlg, IDC_FOLLOWTEXTEDITINGCHECK);
+				break;
+			case IDC_STARTMINIMIZEDCHECK:
+				bStartMinimized = IsDlgButtonChecked (hDlg, IDC_STARTMINIMIZEDCHECK);
+				break;
+			case IDC_SHOWMAGNIFIER:
+				bShowMagnifier = IsDlgButtonChecked (hDlg, IDC_SHOWMAGNIFIERCHECK);
+				if (bShowMagnifier){
+					ShowWindow (hMainWnd , SW_SHOW);
+				}else{
+					ShowWindow (hMainWnd , SW_HIDE);
+				}
+				break;
+		}
+	}
+	return (INT_PTR)FALSE;
+}
+
+// Message handler for warning box.
+INT_PTR CALLBACK WarningProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+	UNREFERENCED_PARAMETER(lParam);
+
+	switch (message)
+	{
+		case WM_INITDIALOG:
+			return (INT_PTR)TRUE;
+		case WM_COMMAND:
+			switch(LOWORD(wParam))
+			{
+				case IDC_SHOWWARNINGCHECK:
+					bShowWarning = !IsDlgButtonChecked (hDlg, IDC_SHOWWARNINGCHECK);
+					break;
+			}
+			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
+			{
+				EndDialog(hDlg, LOWORD(wParam));
+				return (INT_PTR)TRUE;
+			}
+			break;
+	}
+	return (INT_PTR)FALSE;
+}

Added: trunk/rosapps/magnify/magnifier.h
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/magnify/magnifier.h?rev=27811&view=auto
==============================================================================
--- trunk/rosapps/magnify/magnifier.h (added)
+++ trunk/rosapps/magnify/magnifier.h Wed Jul 25 22:00:56 2007
@@ -1,0 +1,36 @@
+/*
+ * WineCalc (magnifier.h)
+ *
+ * Copyright 2007 Marc Piulachs
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+//////////////////////////////////////////////////////////////////
+
+int iZoom;
+
+BOOL bShowWarning;
+
+BOOL bFollowMouse;
+BOOL bFollowFocus;
+BOOL bFollowCaret;
+
+BOOL bInvertColors;
+BOOL bStartMinimized;
+BOOL bShowMagnifier;
+
+void LoadSettings();
+void SaveSettings();

Added: trunk/rosapps/magnify/magnify.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/magnify/magnify.rbuild?rev=27811&view=auto
==============================================================================
--- trunk/rosapps/magnify/magnify.rbuild (added)
+++ trunk/rosapps/magnify/magnify.rbuild Wed Jul 25 22:00:56 2007
@@ -1,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
+<module name="magnify" type="win32gui" installbase="system32" installname="magnify.exe">
+	<include base="magnify">.</include>
+	<define name="__USE_W32API" />
+	<define name="_WIN32_IE">0x0600</define>
+	<define name="_WIN32_WINNT">0x0501</define>
+	<library>user32</library>
+	<library>gdi32</library>
+	<library>advapi32</library>
+	<library>shell32</library>
+	<library>kernel32</library>
+	<file>magnifier.c</file>
+	<file>settings.c</file>
+	<file>magnify.rc</file>
+</module>

Added: trunk/rosapps/magnify/magnify.rc
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/magnify/magnify.rc?rev=27811&view=auto
==============================================================================
--- trunk/rosapps/magnify/magnify.rc (added)
+++ trunk/rosapps/magnify/magnify.rc Wed Jul 25 22:00:56 2007
@@ -1,0 +1,11 @@
+#include <windows.h>
+#include <commctrl.h>
+#include "resource.h"
+
+#define REACTOS_STR_FILE_DESCRIPTION    "ReactOS Magnifier\0"
+#define REACTOS_STR_INTERNAL_NAME       "magnify\0"
+#define REACTOS_STR_ORIGINAL_FILENAME   "magnify.exe\0"
+
+#include <reactos/version.rc>
+
+#include "lang/en-US.rc"

Added: trunk/rosapps/magnify/res/magnify.ico
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/magnify/res/magnify.ico?rev=27811&view=auto
==============================================================================
Binary file - no diff available.

Propchange: trunk/rosapps/magnify/res/magnify.ico
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: trunk/rosapps/magnify/resource.h
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/magnify/resource.h?rev=27811&view=auto
==============================================================================
--- trunk/rosapps/magnify/resource.h (added)
+++ trunk/rosapps/magnify/resource.h Wed Jul 25 22:00:56 2007
@@ -1,0 +1,43 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Magnifier.rc
+//
+#define IDC_MYICON                      2
+#define IDD_MAGNIFIER_DIALOG            102
+#define IDS_APP_TITLE                   103
+#define IDD_ABOUTBOX                    103
+#define IDM_ABOUT                       104
+#define IDM_EXIT                        105
+#define IDI_MAGNIFIER                   107
+#define IDI_SMALL                       108
+#define IDC_MAGNIFIER                   109
+#define IDR_MAINFRAME                   128
+#define IDD_DIALOGOPTIONS               129
+#define IDD_WARNINGDIALOG               130
+#define IDC_ZOOM                        1000
+#define IDC_CHECK1                      1001
+#define IDC_FOLOWKEYBOARDCHECK          1002
+#define IDC_FOLLOWTEXTEDITINGCHECK      1003
+#define IDC_INVERTCOLORSCHECK           1004
+#define IDC_STARTMINIMIZEDCHECK         1005
+#define IDC_SHOWMAGNIFIER               1006
+#define IDC_SHOWMAGNIFIERCHECK          1006
+#define IDC_FOLLOWMOUSECHECK            1007
+#define IDC_SHOWWARNINGCHECK            1009
+#define IDC_BUTTON1                     1008
+#define ID_FILE_OPTIONS                 32771
+#define ID_OPTIONS                      32772
+#define IDM_OPTIONS                     32773
+#define IDC_STATIC                      -1
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC                     1
+#define _APS_NEXT_RESOURCE_VALUE        131
+#define _APS_NEXT_COMMAND_VALUE         32774
+#define _APS_NEXT_CONTROL_VALUE         1009
+#define _APS_NEXT_SYMED_VALUE           110
+#endif
+#endif

Added: trunk/rosapps/magnify/settings.c
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/magnify/settings.c?rev=27811&view=auto
==============================================================================
--- trunk/rosapps/magnify/settings.c (added)
+++ trunk/rosapps/magnify/settings.c Wed Jul 25 22:00:56 2007
@@ -1,0 +1,89 @@
+#include <windows.h>
+#include <tchar.h>
+#include "magnifier.h"
+
+int iZoom = 3;
+
+BOOL bShowWarning = TRUE;
+
+BOOL bFollowMouse = TRUE;
+BOOL bFollowFocus = TRUE;
+BOOL bFollowCaret = TRUE;
+
+BOOL bInvertColors = FALSE;
+BOOL bStartMinimized = FALSE;
+BOOL bShowMagnifier = TRUE;
+
+void LoadSettings()
+{
+	HKEY hkey;
+	LONG value;
+	ULONG len;
+
+	RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0,
+		_T(""), 0, KEY_READ, NULL, &hkey, NULL);
+
+	if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryMagLevel"),  0, 0, (BYTE *)&value, &len))
+	{
+		if(value >= 0 && value <= 9)
+			iZoom  = value;
+	}
+
+	if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("ShowWarning"), 0, 0, (BYTE *)&value, &len))
+		bShowWarning = (value == 0 ? FALSE : TRUE);
+
+	if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryInvertColors"), 0, 0, (BYTE *)&value, &len))
+		bInvertColors = (value == 0 ? FALSE : TRUE);
+
+	if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryStartMinimized"), 0, 0, (BYTE *)&value, &len))
+		bStartMinimized = (value == 0 ? FALSE : TRUE);
+
+	if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackCursor"), 0, 0, (BYTE *)&value, &len))
+		bFollowMouse = (value == 0 ? FALSE : TRUE);
+
+	if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackFocus"), 0, 0, (BYTE *)&value, &len))
+		bFollowFocus = (value == 0 ? FALSE : TRUE);
+
+	if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, 0, (BYTE *)&value, &len))
+		bFollowFocus = (value == 0 ? FALSE : TRUE);
+
+	if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("StationaryTrackText"), 0, 0, (BYTE *)&value, &len))
+		bFollowCaret = (value == 0 ? FALSE : TRUE);
+
+	RegCloseKey(hkey);
+}
+
+void SaveSettings()
+{
+	HKEY hkey;
+	LONG value;
+
+	RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Magnify"), 0,
+		_T(""), 0, KEY_WRITE, NULL, &hkey, NULL);
+
+	value = iZoom;
+	RegSetValueEx(hkey, _T("StationaryMagLevel"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
+
+	value = bShowWarning;
+	RegSetValueEx(hkey, _T("ShowWarning"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
+
+	value = bInvertColors;
+	RegSetValueEx(hkey, _T("StationaryInvertColors"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
+
+	value = bStartMinimized;
+	RegSetValueEx(hkey, _T("StationaryStartMinimized"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
+
+	value = bFollowMouse;
+	RegSetValueEx(hkey, _T("StationaryTrackCursor"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
+
+	value = bFollowFocus;
+	RegSetValueEx(hkey, _T("StationaryTrackFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
+
+	value = bFollowFocus;
+	RegSetValueEx(hkey, _T("StationaryTrackSecondaryFocus"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
+
+	value = bFollowCaret;
+	RegSetValueEx(hkey, _T("StationaryTrackText"), 0, REG_DWORD, (BYTE *)&value, sizeof value);
+
+	RegCloseKey(hkey);
+}




More information about the Ros-diffs mailing list