diff --git a/reactos/apps/tests/Makefile b/reactos/apps/tests/Makefile index b9d81412ff3..c8a41e74822 100644 --- a/reactos/apps/tests/Makefile +++ b/reactos/apps/tests/Makefile @@ -7,8 +7,8 @@ PATH_TO_TOP = ../.. include $(PATH_TO_TOP)/rules.mak # test_old tests -TEST_APPS = SampleWindow alive apc args atomtest bench bitblt \ -button button2 capclock cliarea combo consume copymove count dibtest \ +TEST_APPS = SampleWindow alive apc args atomtest bench bitblt button \ +button2 capclock caretscliarea combo consume copymove count dibtest \ dump_shared_data edit enumwnd event file gditest global_mem hello \ hivetest icontest isotest lineclip linetest lock lpc messagebox mktime \ mstest multiwin mutex nptest patblt pipe primitives pteb regtest \ diff --git a/reactos/apps/tests/carets/.cvsignore b/reactos/apps/tests/carets/.cvsignore new file mode 100644 index 00000000000..d63774a7353 --- /dev/null +++ b/reactos/apps/tests/carets/.cvsignore @@ -0,0 +1,6 @@ +*.o +*.d +*.exe +*.coff +*.sym +*.map diff --git a/reactos/apps/tests/carets/caret.bmp b/reactos/apps/tests/carets/caret.bmp new file mode 100644 index 00000000000..5082a5b71a5 Binary files /dev/null and b/reactos/apps/tests/carets/caret.bmp differ diff --git a/reactos/apps/tests/carets/carets.c b/reactos/apps/tests/carets/carets.c new file mode 100644 index 00000000000..3c71e5c0470 --- /dev/null +++ b/reactos/apps/tests/carets/carets.c @@ -0,0 +1,150 @@ +#include +#include +#include "resource.h" + +static int CaretWidth = 2; +static int CaretHeight = 16; +static int CharWidth = 10; +static int CharHeight = 16; +static HBITMAP CaretBitmap; + +LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM); + +int WINAPI +WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) +{ + WNDCLASS wc; + MSG msg; + HWND hWnd; + + CaretBitmap = LoadBitmap(hInstance, (LPCTSTR)IDB_CARET); + + wc.lpszClassName = "CaretTestClass"; + 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)COLOR_WINDOW; + wc.lpszMenuName = NULL; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + if (RegisterClass(&wc) == 0) + { + fprintf(stderr, "RegisterClass failed (last error 0x%X)\n", + GetLastError()); + return(1); + } + + hWnd = CreateWindow(wc.lpszClassName, + "Caret Test", + WS_OVERLAPPEDWINDOW, + 0, + 0, + 200, + 250, + NULL, + NULL, + hInstance, + NULL); + if (hWnd == NULL) + { + fprintf(stderr, "CreateWindow failed (last error 0x%X)\n", + GetLastError()); + return(1); + } + + ShowWindow(hWnd, nCmdShow); + + while(GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return msg.wParam; +} + +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + POINT pt; + switch(msg) + { + case WM_ACTIVATE: + switch(LOWORD(wParam)) + { + case WA_ACTIVE: + case WA_CLICKACTIVE: + if(!ShowCaret(hWnd)) + DbgPrint("ShowCaret(0x%x)\n", hWnd); + break; + case WA_INACTIVE: + if(!HideCaret(hWnd)) + DbgPrint("HideCaret(0x%x)\n", hWnd); + break; + } + break; + + case WM_KEYDOWN: + if(!GetCaretPos(&pt)) + { + DbgPrint("GetCaretPos() failed!\n"); + break; + } + switch(wParam) + { + case VK_LEFT: + pt.x -= CharWidth; + break; + case VK_UP: + pt.y -= CharHeight; + break; + case VK_RIGHT: + pt.x += CharWidth; + break; + case VK_DOWN: + pt.y += CharHeight; + break; + } + if(!SetCaretPos(pt.x, pt.y)) + DbgPrint("SetCaretPos() failed!\n"); + break; + + case WM_RBUTTONDOWN: + if(!CreateCaret(hWnd, CaretBitmap, 0, 0)) + DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd); + else + if(!ShowCaret(hWnd)) + DbgPrint("ShowCaret(0x%x)\n", hWnd); + break; + + case WM_LBUTTONDOWN: + if(!CreateCaret(hWnd, (HBITMAP)0, CaretWidth, CaretHeight)) + DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd); + else + if(!ShowCaret(hWnd)) + DbgPrint("ShowCaret(0x%x)\n", hWnd); + break; + + case WM_CREATE: + if(!CreateCaret(hWnd, (HBITMAP)0, CaretWidth, CaretHeight)) + DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd); + else + if(!SetCaretPos(1, 1)) + DbgPrint("SetCaretPos(%i, %i) failed!\n", 1, 1); + break; + + case WM_DESTROY: + if(!DestroyCaret()) + DbgPrint("DestroyCaret() failed!\n"); + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hWnd, msg, wParam, lParam); + } + return 0; +} diff --git a/reactos/apps/tests/carets/carets.rc b/reactos/apps/tests/carets/carets.rc new file mode 100644 index 00000000000..46206dad917 --- /dev/null +++ b/reactos/apps/tests/carets/carets.rc @@ -0,0 +1,5 @@ +#include +#include +#include "resource.h" + +IDB_CARET BITMAP DISCARDABLE "caret.bmp" diff --git a/reactos/apps/tests/carets/makefile b/reactos/apps/tests/carets/makefile new file mode 100644 index 00000000000..a5f1c33e7c4 --- /dev/null +++ b/reactos/apps/tests/carets/makefile @@ -0,0 +1,21 @@ +# $Id: makefile,v 1.1 2003/10/15 18:28:54 weiden Exp $ + +PATH_TO_TOP = ../../.. + +TARGET_NORC = no + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = carets + +TARGET_SDKLIBS = kernel32.a gdi32.a ntdll.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/reactos/apps/tests/carets/resource.h b/reactos/apps/tests/carets/resource.h new file mode 100644 index 00000000000..4550828495a --- /dev/null +++ b/reactos/apps/tests/carets/resource.h @@ -0,0 +1 @@ +#define IDB_CARET 101