2003-12-07 Casper S. Hornstrup <chorns@users.sourceforge.net>
authorCasper Hornstrup <chorns@users.sourceforge.net>
Sun, 7 Dec 2003 12:40:22 +0000 (12:40 +0000)
committerCasper Hornstrup <chorns@users.sourceforge.net>
Sun, 7 Dec 2003 12:40:22 +0000 (12:40 +0000)
* apps/tests/accelerator: New directory.
* apps/tests/accelerator/accelerator.c: New file.
* apps/tests/accelerator/.cvsignore: Ditto.
* apps/tests/accelerator/Makefile: Ditto.
* apps/tests/Makefile (TEST_APPS): Add accelerator.

svn path=/trunk/; revision=6890

reactos/ChangeLog
reactos/apps/tests/Makefile
reactos/apps/tests/accelerator/.cvsignore [new file with mode: 0644]
reactos/apps/tests/accelerator/Makefile [new file with mode: 0644]
reactos/apps/tests/accelerator/accelerator.c [new file with mode: 0644]

index 252f24b..360799e 100644 (file)
@@ -1,3 +1,11 @@
+2003-12-07  Casper S. Hornstrup  <chorns@users.sourceforge.net>
+
+       * apps/tests/accelerator: New directory.
+       * apps/tests/accelerator/accelerator.c: New file.
+       * apps/tests/accelerator/.cvsignore: Ditto.
+       * apps/tests/accelerator/Makefile: Ditto.
+       * apps/tests/Makefile (TEST_APPS): Add accelerator.
+
 2003-12-07  Casper S. Hornstrup  <chorns@users.sourceforge.net>
 
        * regtests/Makefile: Generate regression test registrations.
index 2b0dab2..a0d845d 100644 (file)
@@ -7,7 +7,7 @@ PATH_TO_TOP = ../..
 include $(PATH_TO_TOP)/rules.mak
 
 # test_old tests
-TEST_APPS = SampleWindow alive apc args atomtest bench bitblt button \
+TEST_APPS = accelerator SampleWindow alive apc args atomtest bench bitblt button \
 button2 capclock carets cliarea combo consume copymove count dibtest \
 dump_shared_data edit enumwnd event file global_mem hello \
 hivetest hotkey icontest isotest lineclip linetest lock lpc messagebox \
diff --git a/reactos/apps/tests/accelerator/.cvsignore b/reactos/apps/tests/accelerator/.cvsignore
new file mode 100644 (file)
index 0000000..e247138
--- /dev/null
@@ -0,0 +1,6 @@
+*.o
+*.d
+*.exe
+*.coff
+*.sym
+*.map
\ No newline at end of file
diff --git a/reactos/apps/tests/accelerator/Makefile b/reactos/apps/tests/accelerator/Makefile
new file mode 100644 (file)
index 0000000..2ea8d4f
--- /dev/null
@@ -0,0 +1,19 @@
+PATH_TO_TOP = ../../..
+
+TARGET_NORC = yes
+
+TARGET_TYPE = program
+
+TARGET_APPTYPE = windows
+
+TARGET_NAME = accelerator
+
+#TARGET_SDKLIBS = kernel32.a user32.a
+
+TARGET_OBJECTS = accelerator.o
+
+TARGET_CFLAGS = -Wall -Werror
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
diff --git a/reactos/apps/tests/accelerator/accelerator.c b/reactos/apps/tests/accelerator/accelerator.c
new file mode 100644 (file)
index 0000000..0b7aca6
--- /dev/null
@@ -0,0 +1,161 @@
+#include <windows.h>
+#include <stdio.h>
+#include <string.h>
+
+#define ID_ACCEL1 0x100
+#define ID_ACCEL2 0x101
+#define ID_ACCEL3 0x102
+#define ID_ACCEL4 0x103
+
+/*
+ * {fVirt, key, cmd}
+ * fVirt |= FVIRTKEY | FCONTROL | FALT | FSHIFT
+ */
+//static HFONT tf;
+static ACCEL Accelerators[4] = {
+       { FVIRTKEY, VK_A, ID_ACCEL1},
+       { FVIRTKEY | FSHIFT, VK_A, ID_ACCEL2},
+       { FVIRTKEY | FCONTROL, VK_A, ID_ACCEL3},
+       { FVIRTKEY | FALT, VK_A, ID_ACCEL4}};
+static HACCEL hAcceleratorTable;
+static char Event[200];
+
+LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
+
+int WINAPI 
+WinMain(HINSTANCE hInstance,
+       HINSTANCE hPrevInstance,
+       LPSTR lpszCmdLine,
+       int nCmdShow)
+{
+  WNDCLASS wc;
+  MSG msg;
+  HWND hWnd;
+
+  wc.lpszClassName = "AcceleratorTest";
+  wc.lpfnWndProc = MainWndProc;
+  wc.style = CS_VREDRAW | CS_HREDRAW;
+  wc.hInstance = hInstance;
+  wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
+  wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
+  wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
+  wc.lpszMenuName = NULL;
+  wc.cbClsExtra = 0;
+  wc.cbWndExtra = 0;
+  if (RegisterClass(&wc) == 0)
+    {
+      fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
+             GetLastError());
+      return(1);
+    }
+
+  hWnd = CreateWindow("AcceleratorTest",
+                     "Accelerator Test",
+                     WS_OVERLAPPEDWINDOW,
+                     0,
+                     0,
+                     CW_USEDEFAULT,
+                     CW_USEDEFAULT,
+                     NULL,
+                     NULL,
+                     hInstance,
+                     NULL);
+  if (hWnd == NULL)
+    {
+      fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
+             GetLastError());
+      return(1);
+    }
+
+  /*tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
+       ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
+       DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");*/
+
+  Event[0] = 0;
+
+  ShowWindow(hWnd, nCmdShow);
+
+  hAcceleratorTable = CreateAcceleratorTable(Accelerators,
+       sizeof(Accelerators)/sizeof(Accelerators[1]));
+  if (hAcceleratorTable == NULL)
+    {
+      fprintf(stderr, "CreateAcceleratorTable failed (last error 0x%lX)\n",
+             GetLastError());
+      return(1);
+    }
+
+  while(GetMessage(&msg, NULL, 0, 0))
+    {
+         if (!TranslateAccelerator(hWnd, hAcceleratorTable, &msg))
+           {
+          TranslateMessage(&msg);
+          DispatchMessage(&msg);
+           }
+    }
+
+  if (!DestroyAcceleratorTable(hAcceleratorTable))
+    {
+      fprintf(stderr, "DestroyAcceleratorTable failed (last error 0x%lX)\n",
+             GetLastError());
+      return(1);
+    }
+
+  //DeleteObject(tf);
+
+  return msg.wParam;
+}
+
+LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+       PAINTSTRUCT ps;
+       HDC hDC;
+       char buf[200];
+
+       switch(msg)
+       {
+       case WM_PAINT:
+      hDC = BeginPaint(hWnd, &ps);
+         //SelectObject(hDC, tf);
+         sprintf(buf, "Event: '%s'", Event);
+         TextOut(hDC, 10, 10, buf, strlen(buf));
+         EndPaint(hWnd, &ps);
+         break;
+
+       case WM_DESTROY:
+         PostQuitMessage(0);
+         break;
+
+    case WM_COMMAND:
+
+         switch (LOWORD(wParam))
+         {
+         case ID_ACCEL1:
+           strcpy(Event, "A");
+               break;
+
+         case ID_ACCEL2:
+           strcpy(Event, "SHIFT+A");
+               break;
+
+         case ID_ACCEL3:
+           strcpy(Event, "CTRL+A");
+               break;
+
+         case ID_ACCEL4:
+           strcpy(Event, "ALT+A");
+               break;
+
+         default:
+           sprintf(Event, "%d", LOWORD(wParam));
+               break;
+         }
+
+         InvalidateRect(hWnd, NULL, TRUE);
+         UpdateWindow(hWnd);
+         break;
+
+       default:
+         return DefWindowProc(hWnd, msg, wParam, lParam);
+       }
+       return 0;
+}