diff --git a/rosapps/tests/bench/.cvsignore b/rosapps/tests/bench/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/bench/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/bench/bench-syscall.c b/rosapps/tests/bench/bench-syscall.c new file mode 100644 index 00000000000..447bc0f1e24 --- /dev/null +++ b/rosapps/tests/bench/bench-syscall.c @@ -0,0 +1,8 @@ +/* + * + */ + +int main(int argc, char* argv[]) +{ + +} diff --git a/rosapps/tests/bench/bench-thread.c b/rosapps/tests/bench/bench-thread.c new file mode 100644 index 00000000000..6648a254b8a --- /dev/null +++ b/rosapps/tests/bench/bench-thread.c @@ -0,0 +1,81 @@ +#include +#include + +#define NR_THREADS (30) + + +DWORD WINAPI +thread_main1(LPVOID param) +{ + printf("Thread 1 running (Counter %lu)\n", (DWORD)param); + SleepEx(INFINITE, TRUE); + return 0; +} + + +DWORD WINAPI +thread_main2(LPVOID param) +{ + printf("Thread 2 running (Counter %lu)\n", (DWORD)param); + Sleep(INFINITE); + return 0; +} + + +int main (void) +{ + DWORD i=0; + DWORD id; + +#if 1 + printf("Creating %d threads...\n",NR_THREADS*2); + for (i=0;i + * Updates can be downloaded at: + * + * Please do not hesistate to e-mail me at dmc27@ee.cornell.edu + * if you have any questions about this code. + */ + + +#include +#include + +HINSTANCE HInst; +const char* WndClassName = "GMainWnd"; +LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam, + LPARAM LParam); + + +int APIENTRY WinMain(HINSTANCE HInstance, HINSTANCE HPrevInstance, + LPTSTR lpCmdLine, int nCmdShow) +{ + WNDCLASS wc; + MSG msg; + + HInst = HInstance; + + memset(&wc, 0, sizeof(WNDCLASS)); + + wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS; + wc.lpfnWndProc = MainWndProc; + wc.hInstance = HInstance; + wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW); + /* wc.hbrBackground = reinterpret_cast(COLOR_BTNFACE + 1); */ + wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wc.lpszClassName = WndClassName; + + if (RegisterClass(&wc)) + { + HWND HWnd = + CreateWindow( + WndClassName, TEXT("BitBlt Bitmap Rendering Demo"), + WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | + WS_VISIBLE | WS_CLIPSIBLINGS, + 0, 0, 220, 230, + NULL, NULL, HInst, NULL + ); + + if (HWnd) + { + ShowWindow(HWnd, nCmdShow); + UpdateWindow(HWnd); + + while (GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + } + return 0; +} + +/* image related */ +BITMAP bmp; +LPCSTR filename = TEXT("lena.bmp"); +HDC HMemDC = NULL; +HBITMAP HOldBmp = NULL; + +LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam, + LPARAM LParam) +{ + switch (Msg) + { + case WM_CREATE: + { + /* create a memory DC */ + HMemDC = CreateCompatibleDC(NULL); + if (HMemDC) + { + /* load a bitmap from file */ + HBITMAP HBmp = + /* static_cast */( + LoadImage(HInst, filename, IMAGE_BITMAP, + 0, 0, LR_LOADFROMFILE) + ); + if (HBmp) + { + /* extract dimensions of the bitmap */ + GetObject(HBmp, sizeof(BITMAP), &bmp); + + /* associate the bitmap with the memory DC */ + /* HOldBmp = static_cast */ + (SelectObject(HMemDC, HBmp) + ); + } + } + } + case WM_PAINT: + { + PAINTSTRUCT ps; + const HDC Hdc = BeginPaint(HWnd, &ps); +#if 0 + try +#endif + { + + /* TODO: add palette support (see Chapter 9)... */ + + + BitBlt(Hdc, 20, 15, + bmp.bmWidth, bmp.bmHeight, + HMemDC, 0, 0, + SRCCOPY); + } +#if 0 + catch (...) +#endif + { + EndPaint(HWnd, &ps); + } + EndPaint(HWnd, &ps); + break; + } + case WM_DESTROY: + { + /* clean up */ + DeleteObject(SelectObject(HMemDC, HOldBmp)); + DeleteDC(HMemDC); + + PostQuitMessage(0); + return 0; + } + } + return DefWindowProc(HWnd, Msg, WParam, LParam); +} diff --git a/rosapps/tests/bitblt/lena.bmp b/rosapps/tests/bitblt/lena.bmp new file mode 100644 index 00000000000..e9916963852 Binary files /dev/null and b/rosapps/tests/bitblt/lena.bmp differ diff --git a/rosapps/tests/bitblt/makefile b/rosapps/tests/bitblt/makefile new file mode 100644 index 00000000000..6c009b3545f --- /dev/null +++ b/rosapps/tests/bitblt/makefile @@ -0,0 +1,22 @@ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = bitblt + +TARGET_SDKLIBS = kernel32.a gdi32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror -D__USE_W32API + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/button/.cvsignore b/rosapps/tests/button/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/button/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/button/Makefile b/rosapps/tests/button/Makefile new file mode 100644 index 00000000000..383ba5ae459 --- /dev/null +++ b/rosapps/tests/button/Makefile @@ -0,0 +1,22 @@ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = btntest + +TARGET_SDKLIBS = kernel32.a gdi32.a + +TARGET_OBJECTS = buttontst.o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/button/buttontst.c b/rosapps/tests/button/buttontst.c new file mode 100644 index 00000000000..c12887b6aee --- /dev/null +++ b/rosapps/tests/button/buttontst.c @@ -0,0 +1,107 @@ +/* Based on Radoslaw Sokol's static control test. */ +#include + +static LPSTR BUTTON_CLASS = "BUTTON"; +static LPSTR TEST_WND_CLASS = "TESTWND"; + +#ifdef NDEBUG + #define DPRINT(s) (void)0 +#else + #define DPRINT(s) OutputDebugStringA("BUTTONTEST: " s "\n") +#endif + +HINSTANCE AppInstance = NULL; + +LRESULT WmCreate( + HWND Wnd) +{ + DPRINT("WM_CREATE (enter)."); + DPRINT("test 1"); + CreateWindowEx(0, BUTTON_CLASS, "PushButton", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE, + 10, 10, 150, 30, Wnd, NULL, AppInstance, NULL); + DPRINT("test 2"); + CreateWindowEx(0, BUTTON_CLASS, "DefPushButton", BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE, + 10, 40, 150, 30, Wnd, NULL, AppInstance, NULL); + DPRINT("test 3"); + CreateWindowEx(0, BUTTON_CLASS, "AutoRadioButton", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, + 10, 70, 150, 30, Wnd, NULL, AppInstance, NULL); + DPRINT("test 4"); + CreateWindowEx(0, BUTTON_CLASS, "AutoCheckBox", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE, + 10, 100, 150, 30, Wnd, NULL, AppInstance, NULL); + + DPRINT("WM_CREATE (leave)."); + return 0; +} + +LRESULT CALLBACK TestWndProc( + HWND Wnd, + UINT Msg, + WPARAM wParam, + LPARAM lParam) +{ + switch (Msg) { + case WM_CREATE: + return WmCreate(Wnd); + case WM_DESTROY: + PostQuitMessage(0); + return 0; + default: + return DefWindowProc(Wnd, Msg, wParam, lParam); + } +} + +int STDCALL WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nShowCmd) +{ + ATOM Result; + MSG Msg; + HWND MainWindow; + WNDCLASSEX TestWndClass = {0}; + DPRINT("Application starting up."); + // Remember instance handle. + AppInstance = GetModuleHandle(NULL); + // Register test window class. + TestWndClass.cbSize = sizeof(WNDCLASSEX); + TestWndClass.lpfnWndProc = &TestWndProc; + TestWndClass.hInstance = AppInstance; + TestWndClass.hCursor = LoadCursor(0, (LPCTSTR)IDC_ARROW); + TestWndClass.hbrBackground = CreateSolidBrush(RGB(255,255,230)); + TestWndClass.lpszClassName = TEST_WND_CLASS; + Result = RegisterClassEx(&TestWndClass); + if (Result == 0) { + DPRINT("Error registering class."); + MessageBox(0, "Error registering test window class.", + "Button control test", MB_ICONSTOP | MB_OK); + ExitProcess(0); + } + // Create main window. + DPRINT("Creating main window."); + MainWindow = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_CLIENTEDGE, + TEST_WND_CLASS, "Button test", + WS_OVERLAPPEDWINDOW, 50, 50, 180, 365, + NULL, NULL, AppInstance, NULL); + if (MainWindow == 0) { + DPRINT("Error creating main window."); + UnregisterClass(TEST_WND_CLASS, AppInstance); + MessageBox(0, "Error creating test window.", + "Static control test", MB_ICONSTOP | MB_OK); + ExitProcess(0); + } + DPRINT("Showing main window."); + ShowWindow(MainWindow, SW_SHOWNORMAL); + UpdateWindow(MainWindow); + // Run message loop. + DPRINT("Entering message loop."); + while (GetMessage(&Msg, NULL, 0, 0) > 0) { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + // Unregister window class. + UnregisterClass(TEST_WND_CLASS, AppInstance); + DPRINT("Exiting."); + + return Msg.wParam; +} diff --git a/rosapps/tests/button2/.cvsignore b/rosapps/tests/button2/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/button2/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/button2/Makefile b/rosapps/tests/button2/Makefile new file mode 100644 index 00000000000..7d96224d6cb --- /dev/null +++ b/rosapps/tests/button2/Makefile @@ -0,0 +1,22 @@ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = btntest2 + +TARGET_SDKLIBS = kernel32.a gdi32.a + +TARGET_OBJECTS = buttontst2.o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/button2/buttontst2.c b/rosapps/tests/button2/buttontst2.c new file mode 100644 index 00000000000..b16c905e1aa --- /dev/null +++ b/rosapps/tests/button2/buttontst2.c @@ -0,0 +1,219 @@ +#include +#include + +HFONT tf; +LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM); + +int WINAPI +WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) +{ + WNDCLASS wc; + MSG msg; + HWND hWnd; + HWND hbtn[26]; + + wc.lpszClassName = "ButtonTest"; + 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("ButtonTest", + "Button 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"); + + ShowWindow(hWnd, nCmdShow); + + hbtn[0] = CreateWindow( + "BUTTON","BS_DEFPUSHBUTTON",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, + 10, 10, 200, 40, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[1] = CreateWindow( + "BUTTON","BS_3STATE",WS_VISIBLE | WS_CHILD | BS_3STATE, + 10, 60, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[2] = CreateWindow( + "BUTTON","BS_AUTO3STATE",WS_VISIBLE | WS_CHILD | BS_AUTO3STATE, + 10, 90, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[3] = CreateWindow( + "BUTTON","BS_AUTOCHECKBOX",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, + 10, 120, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[4] = CreateWindow( + "BUTTON","BS_AUTORADIOBUTTON",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON, + 10, 150, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[5] = CreateWindow( + "BUTTON","BS_CHECKBOX",WS_VISIBLE | WS_CHILD | BS_CHECKBOX, + 10, 180, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[6] = CreateWindow( + "BUTTON","BS_GROUPBOX",WS_VISIBLE | WS_CHILD | BS_GROUPBOX, + 10, 210, 200, 80, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[7] = CreateWindow( + "BUTTON","BS_PUSHBUTTON",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, + 20, 230, 180, 30, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[8] = CreateWindow( + "BUTTON","BS_RADIOBUTTON",WS_VISIBLE | WS_CHILD | BS_RADIOBUTTON, + 10, 300, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[9] = CreateWindow( + "BUTTON","BS_AUTORADIOBUTTON",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON, + 220, 160, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[10] = CreateWindow( + "BUTTON","BS_DEFPUSHBUTTON|BS_BOTTOM",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_BOTTOM, + 220, 10, 250, 40, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[11] = CreateWindow( + "BUTTON","BS_DEFPUSHBUTTON|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_LEFT, + 480, 10, 250, 40, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[12] = CreateWindow( + "BUTTON","BS_DEFPUSHBUTTON|BS_RIGHT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_RIGHT |BS_MULTILINE, + 740, 10, 150, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[13] = CreateWindow( + "BUTTON","BS_AUTORADIOBUTTON|BS_TOP",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_TOP, + 220, 60, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + // Other Combinations + + hbtn[14] = CreateWindow( + "BUTTON","BS_AUTORADIOBUTTON|BS_BOTTOM|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_BOTTOM | BS_MULTILINE, + 480, 60, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[15] = CreateWindow( + "BUTTON","BS_AUTORADIOBUTTON|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_LEFT, + 740, 80, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[16] = CreateWindow( + "BUTTON","BS_AUTORADIOBUTTON|BS_RIGHT|BS_TOP",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_RIGHT | BS_TOP, + 220, 130, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[17] = CreateWindow( + "BUTTON","BS_AUTORADIOBUTTON|BS_TOP|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_TOP| BS_MULTILINE, + 480, 130, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[18] = CreateWindow( + "BUTTON","BS_AUTOCHECKBOX|BS_BOTTOM|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_BOTTOM | BS_MULTILINE, + 740, 130, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[19] = CreateWindow( + "BUTTON","BS_AUTOCHECKBOX|BS_TOP|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE, + 480, 190, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[20] = CreateWindow( + "BUTTON","BS_AUTOCHECKBOX|BS_LEFT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_LEFT | BS_MULTILINE, + 220, 230, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[21] = CreateWindow( + "BUTTON","BS_AUTOCHECKBOX|BS_RIGHT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_RIGHT | BS_MULTILINE, + 480, 240, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[22] = CreateWindow( + "BUTTON","BS_GROUPBOX|BS_TOP",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_TOP, + 10, 340, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[23] = CreateWindow( + "BUTTON","BS_GROUPBOX|BS_BOTTOM",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_BOTTOM, + 10, 410, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[24] = CreateWindow( + "BUTTON","BS_GROUPBOXBOX|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_LEFT, + 520, 340, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + hbtn[25] = CreateWindow( + "BUTTON","BS_GROUPBOX|BS_RIGHT|BS_BOTTOM",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_BOTTOM | BS_RIGHT, + 300, 340, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),NULL); + + while(GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + DeleteObject(tf); + + return msg.wParam; +} + +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PAINTSTRUCT ps; + HDC hDC; + + switch(msg) + { + case WM_PAINT: + hDC = BeginPaint(hWnd, &ps); + SelectObject(hDC, tf); + EndPaint(hWnd, &ps); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + case WM_COMMAND: + switch(HIWORD(wParam)) + { + case BN_CLICKED: + printf("BUTTON CLICKED !\n"); + break; + case BN_DBLCLK: + printf("BUTTON DOUBLE-CLICKED !\n"); + break; + case BN_PUSHED: + printf("BUTTON PUSHED !\n"); + break; + case BN_PAINT: + printf("BUTTON PAINTED !\n"); + break; + case BN_UNPUSHED: + printf("BUTTON UNPUSHED !\n"); + break; + + } + break; + + default: + return DefWindowProc(hWnd, msg, wParam, lParam); + } + return 0; +} diff --git a/rosapps/tests/capclock/.cvsignore b/rosapps/tests/capclock/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/capclock/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/capclock/Makefile b/rosapps/tests/capclock/Makefile new file mode 100644 index 00000000000..abc30f70091 --- /dev/null +++ b/rosapps/tests/capclock/Makefile @@ -0,0 +1,20 @@ + +PATH_TO_TOP = ../../../reactos + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = capclock + +TARGET_SDKLIBS = kernel32.a + +TARGET_OBJECTS = capclock.o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/capclock/capclock.c b/rosapps/tests/capclock/capclock.c new file mode 100644 index 00000000000..6a45468f093 --- /dev/null +++ b/rosapps/tests/capclock/capclock.c @@ -0,0 +1,70 @@ +/* $Id: capclock.c,v 1.1 2004/10/21 05:11:59 sedwards Exp $ + * + * DESCRIPTION: Simple Win32 Caption Clock + * PROJECT : ReactOS (test applications) + * AUTHOR : Emanuele Aliberti + * DATE : 2003-09-03 + * LICENSE : GNU GPL v2.0 + */ +#include +#include + +UINT Timer = 1; + +static BOOL CALLBACK DialogFunc(HWND,UINT,WPARAM,LPARAM); +static VOID CALLBACK TimerProc(HWND,UINT,UINT,DWORD); + + +INT STDCALL WinMain (HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, INT nCmdShow) +{ + WNDCLASS wc; + + ZeroMemory (& wc, sizeof wc); + wc.lpfnWndProc = DefDlgProc; + wc.cbWndExtra = DLGWINDOWEXTRA; + wc.hInstance = hinst; + wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW); + wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); + wc.lpszClassName = "CapClock"; + RegisterClass (& wc); + return DialogBox(hinst, MAKEINTRESOURCE(2), NULL, DialogFunc); + +} +static int InitializeApp (HWND hDlg,WPARAM wParam, LPARAM lParam) +{ + Timer = SetTimer (hDlg,Timer,1000,TimerProc); + TimerProc (hDlg,0,0,0); + return 1; +} +static INT_PTR CALLBACK DialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + InitializeApp(hwndDlg,wParam,lParam); + return TRUE; + case WM_CLOSE: + KillTimer (hwndDlg,Timer); + EndDialog(hwndDlg,0); + return TRUE; + } + return FALSE; +} +static VOID CALLBACK TimerProc (HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime) +{ + CHAR text [20]; + SYSTEMTIME lt; + + GetLocalTime (& lt); + wsprintf ( + text, + "%d-%02d-%02d %02d:%02d:%02d", + lt.wYear, + lt.wMonth, + lt.wDay, + lt.wHour, + lt.wMinute, + lt.wSecond); + SetWindowText (hwnd, text); +} +/* EOF */ diff --git a/rosapps/tests/capclock/capclock.ico b/rosapps/tests/capclock/capclock.ico new file mode 100644 index 00000000000..0b52fb0ccde Binary files /dev/null and b/rosapps/tests/capclock/capclock.ico differ diff --git a/rosapps/tests/capclock/capclock.rc b/rosapps/tests/capclock/capclock.rc new file mode 100644 index 00000000000..e3aada7e88a --- /dev/null +++ b/rosapps/tests/capclock/capclock.rc @@ -0,0 +1,20 @@ +/* $Id: capclock.rc,v 1.1 2004/10/21 05:11:59 sedwards Exp $ */ + +#include + +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS W32 Caption Clock\0" +#define REACTOS_STR_INTERNAL_NAME "capclock\0" +#define REACTOS_STR_ORIGINAL_FILENAME "capclock.exe\0" +#include + +/* Icons */ + +1 ICON "capclock.ico" + +/* Dialogs */ + +2 DIALOG 6, 18, 132, 0 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +FONT 8, "Microsoft Sans Serif" +BEGIN +END diff --git a/rosapps/tests/carets/.cvsignore b/rosapps/tests/carets/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/carets/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/carets/caret.bmp b/rosapps/tests/carets/caret.bmp new file mode 100644 index 00000000000..5082a5b71a5 Binary files /dev/null and b/rosapps/tests/carets/caret.bmp differ diff --git a/rosapps/tests/carets/carets.c b/rosapps/tests/carets/carets.c new file mode 100644 index 00000000000..49007810578 --- /dev/null +++ b/rosapps/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%lX)\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%lX)\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/rosapps/tests/carets/carets.rc b/rosapps/tests/carets/carets.rc new file mode 100644 index 00000000000..46206dad917 --- /dev/null +++ b/rosapps/tests/carets/carets.rc @@ -0,0 +1,5 @@ +#include +#include +#include "resource.h" + +IDB_CARET BITMAP DISCARDABLE "caret.bmp" diff --git a/rosapps/tests/carets/makefile b/rosapps/tests/carets/makefile new file mode 100644 index 00000000000..01c43bc5c6d --- /dev/null +++ b/rosapps/tests/carets/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2004/10/21 05:11:59 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +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 + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/carets/resource.h b/rosapps/tests/carets/resource.h new file mode 100644 index 00000000000..4550828495a --- /dev/null +++ b/rosapps/tests/carets/resource.h @@ -0,0 +1 @@ +#define IDB_CARET 101 diff --git a/rosapps/tests/combo/.cvsignore b/rosapps/tests/combo/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/combo/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/combo/combotst.c b/rosapps/tests/combo/combotst.c new file mode 100644 index 00000000000..f99fc87da91 --- /dev/null +++ b/rosapps/tests/combo/combotst.c @@ -0,0 +1,687 @@ +/* ComboBox Control Test for ReactOS. + +* This is a test program. Not made to be fast, small +* easy to mantain, or portable. + +* I'm not erasing text because I don't want to use other functions from the API +* or make this more complex. Also Fonts are not heavily used. + +* This source code is in the PUBLIC DOMAIN and has NO WARRANTY. +* by Waldo Alvarez Caņizares , started July 11, 2003. */ + +//#define WIN32_LEAN_AND_MEAN +#include +#include "utils.h" + +#define CONTROLCLASS "COMBOBOX" /* the class name */ +#define CONTROLCLASSW L"COMBOBOX" /* the class name in unicode*/ + +#define WINDOWWIDTH 560 +#define WINDOWHEIGHT 350 + +/* --- Command IDs of some buttons --- */ +#define CREATEWINDOW_ID 106 +#define CREATEWINDOWEX_ID 107 +#define CREATEWINDOWW_ID 108 +#define INITPAGE_ID 400 +#define SECONDPAGE_ID 401 +#define BACKFIRSTPAGE_ID 402 + +/* --- Position where the result text goes --- */ +#define ResultX 0 +#define ResultY 305 + +/* --- Position where the notify text goes --- */ +#define NOTIFYX 390 +#define NOTIFYY 285 + +/* --- The width of most buttons --- */ +#define CHECKBUTWIDTH 190 +#define SCROLLAMOUNT -15 + +/* Size of buffer to hold resulting strings from conversion +and returned by messages */ +#define BUFFERLEN 80 +char TextBuffer[BUFFERLEN]={'R','e','s','u','l','t',':',' '}; + +HWND g_hwnd = NULL; +HINSTANCE g_hInst = NULL; + +int pos = 10; +int n = 0; +int yButPos = 10; +int xButPos = 0; + +DWORD ComboStyle = 0; + +/* --- Control coordinates --- */ +#define CONTROLPOSX 390 +#define CONTROLPOSY 10 +DWORD ControlWidth = 160; +DWORD ControlHeight = 150; + +static RECT srect = {CONTROLPOSX,CONTROLPOSY,WINDOWWIDTH,WINDOWHEIGHT}; + +HWND hwndEdit = NULL; + +RECT rect; +DWORD StartP,EndP; +HWND hwnd; /* main window handle */ + +char AddString[] = "string added"; + +typedef void FunctionHandler(HWND,DWORD,WPARAM,LPARAM); +typedef FunctionHandler* LPFUNCTIONHANDLER; + +void PrintTextXY(char* Text,int x,int y,int len, RECT rect) + { + HDC hdc; + hdc = GetDC (g_hwnd); + SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)); + + TextOut (hdc, x,y,Text,len); + ReleaseDC (g_hwnd, hdc); + + ValidateRect (g_hwnd, &rect); + } + +static +VOID +HandlePrintReturnHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam) + { + LRESULT ret; + RECT rect; + ret = SendMessage(handle,Msg,wParam,lParam); + htoa((unsigned int)ret,&TextBuffer[8]); + GetWindowRect(g_hwnd,&rect); + PrintTextXY(TextBuffer,ResultX,ResultY,16,rect); + } + + +static +VOID +HandlePrintReturnStr(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam) + { + LRESULT ret; + RECT rect; + + TextBuffer[8] = (char)(BUFFERLEN - 8); /* Setting the max size to put chars in first byte */ + ret = SendMessage(handle,Msg,wParam,lParam); + GetWindowRect(g_hwnd,&rect); + PrintTextXY(TextBuffer,ResultX,ResultY,8+(int)ret,rect); + } + +static +VOID +HandlePrintRect(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam) + { + RECT rect; + TextBuffer[8] = (char)(BUFFERLEN - 8); /* Setting the max size to put chars in first byte */ + SendMessage(handle,Msg,wParam,lParam); + + htoa(rect.top,&TextBuffer[8]); + TextBuffer[8+8] = ' '; + htoa(rect.bottom,&TextBuffer[8+8+1]); + TextBuffer[8+8+8+1] = ' '; + htoa(rect.left,&TextBuffer[8+8+8+1+1]); + TextBuffer[8+8+8+8+1+1] = ' '; + htoa(rect.right,&TextBuffer[8+8+8+8+1+1+1]); + + GetWindowRect(g_hwnd,&rect); + PrintTextXY(TextBuffer,ResultX,ResultY,8+4*9-1,rect); + } + +struct + { + char* Text; /* Text for the button */ + DWORD MsgCode; /* Message Code */ + WPARAM wParam; /* Well hope you can understand this */ + LPARAM lParam; /* ditto */ + LPFUNCTIONHANDLER Handler; /* Funtion called to handle the result of each message */ + } +Msg[] = + { + {"CB_ADDSTRING",CB_ADDSTRING,0,(LPARAM)&AddString,&HandlePrintReturnHex}, + {"CB_ADDSTRING - long",CB_ADDSTRING,0,(LPARAM)"very loooooooooong striiinnnnnnnnnggg",&HandlePrintReturnHex}, + {"CB_DELETESTRING",CB_DELETESTRING,2,0,&HandlePrintReturnHex}, /* remember to catch WM_DELETEITEM*/ + + /* What a message, why M$ decided to implement his thing ? */ + {"CB_DIR - drives",CB_DIR,DDL_DRIVES, + /* Hoping that most machines have this */ + (LPARAM)"C:\\", + &HandlePrintReturnHex}, + + {"CB_DIR - dirs",CB_DIR,DDL_DIRECTORY,(LPARAM)"C:\\*",&HandlePrintReturnHex}, + + {"CB_DIR - files",CB_DIR, + DDL_ARCHIVE | DDL_EXCLUSIVE | DDL_HIDDEN | DDL_READONLY | DDL_READWRITE | DDL_SYSTEM, + (LPARAM)"C:\\*",&HandlePrintReturnHex}, + + /* Do not forget WM_COMPAREITEM */ + + {"CB_FINDSTRING",CB_FINDSTRING,1,(LPARAM)"str",&HandlePrintReturnHex}, + {"CB_FINDSTRINGEXACT(-1)",CB_FINDSTRINGEXACT,-1,(LPARAM)&AddString,&HandlePrintReturnHex}, + {"CB_FINDSTRINGEXACT(2)",CB_FINDSTRINGEXACT,2,(LPARAM)&AddString,&HandlePrintReturnHex}, + + /* "CB_GETCOMBOBOXINFO",CB_GETCOMBOBOXINFO,0,0,&HandlePrintReturnHex, winXP & .net server remember to handle the struct */ + + {"CB_GETCOUNT",CB_GETCOUNT,0,0,&HandlePrintReturnHex}, + + {"CB_GETCURSEL",CB_GETCURSEL,0,0,&HandlePrintReturnHex}, + + /* To implement "CB_GETEDITSEL - vars",CB_GETEDITSEL,,,&HandlePrintReturnHex, */ + + {"CB_GETEXTENDEDUI",CB_GETEXTENDEDUI,0,0,&HandlePrintReturnHex}, + {"CB_GETHORIZONTALEXTENT",CB_GETHORIZONTALEXTENT,0,0,&HandlePrintReturnHex}, + + + + {"CB_GETLBTEXT",CB_GETLBTEXT,1,(LPARAM)&TextBuffer[8],&HandlePrintReturnStr}, + {"CB_GETLBTEXTLEN",CB_GETLBTEXTLEN,1,0,&HandlePrintReturnHex}, + {"CB_GETLOCALE",CB_GETLOCALE,0,0,&HandlePrintReturnHex}, + + /* "CB_GETMINVISIBLE",CB_GETMINVISIBLE,0,0,&HandlePrintReturnHex, Included in Windows XP and Windows .NET Server. */ + + {"CB_GETTOPINDEX",CB_GETTOPINDEX,0,0,&HandlePrintReturnHex}, + + {"CB_INITSTORAGE",CB_INITSTORAGE,10,200,&HandlePrintReturnHex}, + {"CB_INSERTSTRING",CB_INSERTSTRING,2,(LPARAM)"inserted string",&HandlePrintReturnHex}, + + {"CB_LIMITTEXT",CB_LIMITTEXT,10,0,&HandlePrintReturnHex}, + {"CB_RESETCONTENT",CB_RESETCONTENT ,0,0,&HandlePrintReturnHex}, + {"CB_SELECTSTRING",CB_SELECTSTRING,2,(LPARAM)"str",&HandlePrintReturnHex}, + {"CB_SETCURSEL",CB_SETCURSEL,1,0,&HandlePrintReturnHex}, + + {"CB_SETDROPPEDWIDTH",CB_SETDROPPEDWIDTH,250,0,&HandlePrintReturnHex}, + + {"CB_SETEXTENDEDUI - set",CB_SETEXTENDEDUI,TRUE,0,&HandlePrintReturnHex}, + {"CB_SETEXTENDEDUI - clear",CB_SETEXTENDEDUI,FALSE,0,&HandlePrintReturnHex}, + + /* + * win2k have a small bug with this ^ , if you press F4 while it is cleared, + * the combobox is using style cbs_dropdown + * and the pointer is over the edit box then the mouse pointer is not changed + * to an arrow + */ + + {"CB_SETHORIZONTALEXTENT",CB_SETHORIZONTALEXTENT,500,0,&HandlePrintReturnHex}, + + {"CB_GETITEMDATA",CB_GETITEMDATA,1,0,&HandlePrintReturnHex}, + {"CB_SETITEMDATA",CB_SETITEMDATA,1,0x791031,&HandlePrintReturnHex}, + + {"CB_SETITEMHEIGHT",CB_SETITEMHEIGHT,-1,30,&HandlePrintReturnHex}, + {"CB_GETITEMHEIGHT",CB_GETITEMHEIGHT,2,0,&HandlePrintReturnHex}, + + /* "CB_SETMINVISIBLE",CB_SETMINVISIBLE,4,0,&HandlePrintReturnHex, Included in Windows XP and Windows .NET Server */ + + {"CB_GETEDITSEL",CB_GETEDITSEL,(WPARAM)NULL,(LPARAM)NULL,&HandlePrintReturnHex}, + {"CB_SETEDITSEL",CB_SETEDITSEL,0,0x00020005,&HandlePrintReturnHex}, + {"CB_SETEDITSEL - clear",CB_SETEDITSEL,0,0xFFFFFFFF,&HandlePrintReturnHex}, + + {"CB_SETTOPINDEX",CB_SETTOPINDEX,3,0,&HandlePrintReturnHex}, + + {"CB_SHOWDROPDOWN - true",CB_SHOWDROPDOWN,TRUE,0,&HandlePrintReturnHex}, + {"CB_SHOWDROPDOWN - false",CB_SHOWDROPDOWN,FALSE,0,&HandlePrintReturnHex}, + + {"CB_GETDROPPEDCONTROLRECT",CB_GETDROPPEDCONTROLRECT,0,(LPARAM)&rect,&HandlePrintRect}, + {"CB_GETDROPPEDSTATE",CB_GETDROPPEDSTATE,0,0,&HandlePrintReturnHex}, + {"CB_GETDROPPEDWIDTH",CB_GETDROPPEDWIDTH,0,0,&HandlePrintReturnHex}, + + {"WM_PASTE",WM_PASTE,0,0,&HandlePrintReturnHex}, + }; + +#define MAXMESSAGEBUTTONS 40 + +struct + { + char* Name; /* Text for the button */ + DWORD Code; /* Style Code */ + } +Styles[] = { + {"WS_DISABLED",WS_DISABLED}, + {"CBS_AUTOHSCROLL",CBS_AUTOHSCROLL}, + {"CBS_DISABLENOSCROLL",CBS_DISABLENOSCROLL}, + {"CBS_DROPDOWN",CBS_DROPDOWN}, + {"CBS_DROPDOWNLIST",CBS_DROPDOWNLIST}, + {"CBS_HASSTRINGS",CBS_HASSTRINGS}, + {"CBS_LOWERCASE",CBS_LOWERCASE}, + {"CBS_NOINTEGRALHEIGHT",CBS_NOINTEGRALHEIGHT}, + {"CBS_OEMCONVERT",CBS_OEMCONVERT}, + {"CBS_OWNERDRAWFIXED",CBS_OWNERDRAWFIXED}, + {"CBS_OWNERDRAWVARIABLE",CBS_OWNERDRAWVARIABLE}, + {"CBS_SIMPLE",CBS_SIMPLE}, + {"CBS_SORT",CBS_SORT}, + {"CBS_UPPERCASE",CBS_UPPERCASE}, + {"CBS_DISABLENOSCROLL",CBS_DISABLENOSCROLL}, + {"WS_HSCROLL",WS_HSCROLL}, + {"WS_VSCROLL",WS_VSCROLL} + }; + +/* The number of check buttons we have. +* Maybe some calculations at compile time would be better +*/ + +#define NUMBERCHECKS 17 + +#define NUMBERBUTTONS NUMBERCHECKS + 7 +HWND Buttons[NUMBERBUTTONS]; +HWND MessageButtons[MAXMESSAGEBUTTONS]; +HWND Back1But,Back2But; +HWND NextBut; + +HWND +CreateCheckButton(const char* lpWindowName, DWORD xSize, DWORD id) + { + HWND h; + h = CreateWindowEx(0, + "BUTTON", + lpWindowName, + WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, + xButPos, /* x */ + yButPos, /* y */ + xSize, /* nWidth */ + 20, /* nHeight */ + g_hwnd, + (HMENU) id, + g_hInst, + NULL + ); + yButPos += 21; + return h; + } + +HWND +CreatePushButton(const char* lpWindowName, DWORD xSize, DWORD id,DWORD Style) + { + + HWND h = CreateWindow("BUTTON", + lpWindowName, + WS_CHILD | BS_PUSHBUTTON | Style, + xButPos, /* x */ + yButPos, /* y */ + xSize, /* nWidth */ + 20, /* nHeight */ + g_hwnd, + (HMENU) id, + g_hInst, + NULL + ); + + yButPos += 21; + return h; + } + +VOID +ReadNHide() + { + int i; + ComboStyle = 0; + for (i=0 ; i< NUMBERCHECKS ; i++) + { + if(BST_CHECKED == SendMessage(Buttons[i],BM_GETCHECK,0,0)) + ComboStyle |= Styles[i].Code; + ShowWindow(Buttons[i],SW_HIDE); + } + + for (; i< NUMBERBUTTONS ; i++)ShowWindow(Buttons[i],SW_HIDE); + for (i=0 ; i< 26 ; i++) ShowWindow(MessageButtons[i],SW_SHOW); + + ShowWindow(Back1But,SW_SHOW); + ShowWindow(NextBut,SW_SHOW); + } + +VOID +ForwardToSecondPage() + { + int i; + for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_HIDE); + for(;i= 600) + { + Msg[LOWORD(wParam)-600].Handler(hwndEdit, + Msg[LOWORD(wParam)-600].MsgCode, + Msg[LOWORD(wParam)-600].wParam, + Msg[LOWORD(wParam)-600].lParam); + break; + } + + switch(LOWORD(wParam)){ + + case 100: + ControlWidth += 10; + break; + + case 101: + ControlWidth -= 10; + break; + + case 102: + ControlHeight += 10; + break; + + case 103: + ControlHeight -= 10; + break; + + case INITPAGE_ID: + BackToInitialPage(); + break; + + case SECONDPAGE_ID: + ForwardToSecondPage(); + break; + + case BACKFIRSTPAGE_ID: + BackToFirstPage(); + break; + + case CREATEWINDOW_ID: + ReadNHide(); + srect.top = CONTROLPOSY + ControlHeight; + hwndEdit = CreateWindow(CONTROLCLASS, + NULL, + ComboStyle | WS_CHILD | WS_VISIBLE, + CONTROLPOSX, + CONTROLPOSY, + ControlWidth, + ControlHeight, + g_hwnd, + NULL, + g_hInst, + NULL); + break; + + case CREATEWINDOWEX_ID: + ReadNHide(); + srect.top = CONTROLPOSY + ControlHeight; + hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, + CONTROLCLASS, + NULL, + ComboStyle | WS_CHILD | WS_VISIBLE , + CONTROLPOSX, + CONTROLPOSY, + ControlWidth, + ControlHeight, + g_hwnd, + NULL, + g_hInst, + NULL); + break; + + case CREATEWINDOWW_ID: + ReadNHide(); + srect.top = CONTROLPOSY + ControlHeight; + hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE, + CONTROLCLASSW, + NULL, + ComboStyle | WS_CHILD | WS_VISIBLE , + CONTROLPOSX, + CONTROLPOSY, + ControlWidth, + ControlHeight, + g_hwnd, + NULL, + g_hInst, + NULL); + break; + } + + if (lParam == (LPARAM)hwndEdit) + switch(HIWORD(wParam)) + { + case CBN_DROPDOWN: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_DROPDOWN notification",NOTIFYX,NOTIFYY,25,srect); + break; + + case CBN_CLOSEUP: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_CLOSEUP notification",NOTIFYX,NOTIFYY,24,srect); + break; + + case CBN_DBLCLK: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_DBLCLK notification",NOTIFYX,NOTIFYY,23,srect); + break; + + case CBN_EDITCHANGE: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_EDITCHANGE notification",NOTIFYX,NOTIFYY,27,srect); + break; + + case CBN_ERRSPACE: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_ERRSPACE notification",NOTIFYX,NOTIFYY,25,srect); + break; + + case CBN_KILLFOCUS: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_KILLFOCUS notification",NOTIFYX,NOTIFYY,26,srect); + break; + + case CBN_EDITUPDATE: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_EDITUPDATE notification",NOTIFYX,NOTIFYY,27,srect); + break; + + case CBN_SELCHANGE: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_SELCHANGE notification",NOTIFYX,NOTIFYY,26,srect); + break; + + case CBN_SELENDCANCEL: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_SELENDCANCEL notification",NOTIFYX,NOTIFYY,29,srect); + break; + + case CBN_SETFOCUS: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_SETFOCUS notification",NOTIFYX,NOTIFYY,25,srect); + break; + + case CBN_SELENDOK: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("CBN_SELENDOK notification",NOTIFYX,NOTIFYY,25,srect); + break; + } + + return DefWindowProc ( hwnd, msg, wParam, lParam ); + + case WM_MEASUREITEM: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("WM_MEASUREITEM called",NOTIFYX,NOTIFYY,21,srect); + break; + + case WM_COMPAREITEM: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("WM_COMPAREITEM called",NOTIFYX,NOTIFYY,21,srect); + break; + + case WM_DRAWITEM: + ScrollWindow (hwnd, 0, SCROLLAMOUNT, &srect, &srect); + PrintTextXY("WM_DRAWITEM called",NOTIFYX,NOTIFYY,18,srect); + break; + + case WM_SIZE : + return 0; + + case WM_CLOSE: + DestroyWindow (g_hwnd); + return 0; + + case WM_QUERYENDSESSION: + return 0; + + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + return DefWindowProc ( hwnd, msg, wParam, lParam ); + } + + +HWND +RegisterAndCreateWindow (HINSTANCE hInst, + const char* className, + const char* title) + { + WNDCLASSEX wc; + + + g_hInst = hInst; + + wc.cbSize = sizeof (WNDCLASSEX); + + wc.lpfnWndProc = WndProc; /* window procedure */ + wc.hInstance = hInst; /* owner of the class */ + + wc.lpszClassName = className; + wc.hCursor = LoadCursor ( 0, (LPCTSTR)IDC_ARROW ); + wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hIcon = 0; + wc.hIconSm = 0; + wc.lpszMenuName = 0; + + if ( !RegisterClassEx ( &wc ) ) + return NULL; + + hwnd = CreateWindowEx ( + 0, /* dwStyleEx */ + className, /* class name */ + title, /* window title */ + + WS_OVERLAPPEDWINDOW, /* dwStyle */ + + 1, /* x */ + 1, /* y */ + WINDOWWIDTH, /* width */ + WINDOWHEIGHT, /* height */ + NULL, /* hwndParent */ + NULL, /* hMenu */ + hInst, + 0 + ); + + if (!hwnd) return NULL; + + ShowWindow (hwnd, SW_SHOW); + UpdateWindow (hwnd); + + return hwnd; + } + +int +WINAPI +WinMain ( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow ) + { + char className [] = "ComboBox Control Test"; + MSG msg; + + RegisterAndCreateWindow ( hInst, className, "ComboBox Control Test" ); + + while (GetMessage (&msg, NULL, 0, 0)) + { + TranslateMessage (&msg); + DispatchMessage (&msg); + } + return (int)msg.wParam; + } diff --git a/rosapps/tests/combo/makefile b/rosapps/tests/combo/makefile new file mode 100644 index 00000000000..fb80f9306e7 --- /dev/null +++ b/rosapps/tests/combo/makefile @@ -0,0 +1,25 @@ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = combotst + +TARGET_SDKLIBS = kernel32.a gdi32.a + +TARGET_OBJECTS = \ + combotst.o \ + utils.o + +TARGET_CFLAGS = -Wall -Werror + + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/combo/utils.c b/rosapps/tests/combo/utils.c new file mode 100644 index 00000000000..f1eff54609f --- /dev/null +++ b/rosapps/tests/combo/utils.c @@ -0,0 +1,33 @@ +/* + * Edit Control Test for ReactOS, quick n' dirty. There you go + * This source code is in the PUBLIC DOMAIN and has NO WARRANTY. + * by Waldo Alvarez Caņizares , June 22, 2003. + */ + +#include + +static const char hexvals[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; +VOID htoa (unsigned int val, char *buf) +{ + int i; + buf += 7; + + for (i=0;i<8;i++) + { + *buf-- = hexvals[val & 0x0000000F]; + val = val >> 4; + } +} + + +VOID strcpy_(char *dst, const char *src) +{ + const char* p = src; + while ((*dst++ = *p++)) {} +} + +VOID strcpyw_(wchar_t* dst,wchar_t* src) +{ + const wchar_t* p = src; + while ((*dst++ = *p++)) {} +} diff --git a/rosapps/tests/combo/utils.h b/rosapps/tests/combo/utils.h new file mode 100644 index 00000000000..f6a12649c1e --- /dev/null +++ b/rosapps/tests/combo/utils.h @@ -0,0 +1,9 @@ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +VOID htoa (unsigned int, char *); +VOID strcpy_(char *, const char *); +VOID strcpyw_(wchar_t*,wchar_t*); +#ifdef __cplusplus + } +#endif diff --git a/rosapps/tests/consume/.cvsignore b/rosapps/tests/consume/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/consume/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/consume/Makefile b/rosapps/tests/consume/Makefile new file mode 100644 index 00000000000..ee4ff8ca555 --- /dev/null +++ b/rosapps/tests/consume/Makefile @@ -0,0 +1,21 @@ +# $Id: Makefile,v 1.1 2004/10/21 05:11:59 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = consume + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/consume/consume.c b/rosapps/tests/consume/consume.c new file mode 100644 index 00000000000..81a52cab071 --- /dev/null +++ b/rosapps/tests/consume/consume.c @@ -0,0 +1,31 @@ +#include +#include +#include + +#define SIZE (65*1024*1024) + +ULONG x[SIZE / 4096]; + +int main() +{ + int i; + PUCHAR BaseAddress; + + BaseAddress = VirtualAlloc(NULL, + SIZE, + MEM_COMMIT, + PAGE_READONLY); + if (BaseAddress == NULL) + { + printf("Failed to allocate virtual memory"); + return(1); + } + printf("BaseAddress %p\n", BaseAddress); + for (i = 0; i < (SIZE / 4096); i++) + { + printf("%.8x ", i*4096); + x[i] = BaseAddress[i*4096]; + } + + return(0); +} diff --git a/rosapps/tests/copymove/.cvsignore b/rosapps/tests/copymove/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/copymove/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/copymove/Makefile b/rosapps/tests/copymove/Makefile new file mode 100644 index 00000000000..d42613deb7d --- /dev/null +++ b/rosapps/tests/copymove/Makefile @@ -0,0 +1,21 @@ +# $Id: Makefile,v 1.1 2004/10/21 05:12:00 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = copymove + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/copymove/copymove.c b/rosapps/tests/copymove/copymove.c new file mode 100644 index 00000000000..f938368b8bc --- /dev/null +++ b/rosapps/tests/copymove/copymove.c @@ -0,0 +1,303 @@ +/* + * CopyFile, MoveFile and related routines test + */ + +#include +#include +#include +#include +#include + +static TCHAR +FindOtherDrive() +{ + DWORD drives = GetLogicalDrives(); + BOOL found = FALSE; + TCHAR drive; + TCHAR rootdir[] = _T( "?:\\" ); + TCHAR currentdir[MAX_PATH + 1]; + + if (0 != GetCurrentDirectory(MAX_PATH + 1, currentdir)) { + for (drive = _T('A'); ! found && drive <= _T('Z'); drive++) { + if (0 != (drives & (1 << (drive - _T('A'))))&& + drive != _totupper(currentdir[0])) { + rootdir[0] = drive; + found = (DRIVE_FIXED == GetDriveType(rootdir)); + } + } + } + + return found ? drive - 1 : _T( ' ' ); +} + +static void +DeleteTestFile(LPCTSTR filename) +{ + SetFileAttributes(filename, FILE_ATTRIBUTE_NORMAL); + DeleteFile(filename); +} + +static void +CreateTestFile(LPCTSTR filename, DWORD attributes) +{ + HANDLE file; + char buffer[4096]; + DWORD wrote; + int c; + + DeleteTestFile(filename); + file = CreateFile(filename, + GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + 0, + 0); + + if (INVALID_HANDLE_VALUE == file) { + fprintf(stderr, "CreateFile failed with code %lu\n", GetLastError()); + exit(1); + } + for(c = 0; c < sizeof(buffer); c++) { + buffer[c] = (char) c; + } + if (! WriteFile(file, buffer, sizeof(buffer), &wrote, NULL)) { + fprintf(stderr, "WriteFile failed with code %lu\n", GetLastError()); + exit(1); + } + CloseHandle(file); + + if (! SetFileAttributes(filename, attributes)) { + fprintf(stderr, "SetFileAttributes failed with code %lu\n", GetLastError()); + exit(1); + } +} + +static void +DeleteTestDir(LPCTSTR dirname) +{ + RemoveDirectory(dirname); +} + +static void +CreateTestDir(LPCTSTR dirname) +{ + if (! CreateDirectory(dirname, NULL)) { + fprintf(stderr, "CreateDirectory failed with code %lu\n", GetLastError()); + exit(1); + } +} + +static void +CheckTestFile(LPCTSTR filename, DWORD attributes) +{ + HANDLE file; + char buffer[4096]; + DWORD read; + int c; + DWORD diskattr; + + file = CreateFile(filename, + GENERIC_READ, + 0, + NULL, + OPEN_EXISTING, + 0, + 0); + + if (INVALID_HANDLE_VALUE == file) { + fprintf(stderr, "CreateFile failed with code %lu\n", GetLastError()); + exit(1); + } + + if (! ReadFile(file, buffer, sizeof(buffer), &read, NULL)) { + fprintf(stderr, "ReadFile failed with code %lu\n", GetLastError()); + exit(1); + } + if (read != sizeof(buffer)) { + fprintf(stderr, "Trying to read %u bytes but got %lu bytes\n", sizeof(buffer), read); + exit(1); + } + for(c = 0; c < sizeof(buffer); c++) { + if (buffer[c] != (char) c) { + fprintf(stderr, "File contents changed at position %u\n", c); + exit(1); + } + } + + CloseHandle(file); + + diskattr = GetFileAttributes(filename); + if (INVALID_FILE_ATTRIBUTES == diskattr) { + fprintf(stderr, "GetFileAttributes failed with code %lu\n", GetLastError()); + exit(1); + } + if (diskattr != attributes) { + fprintf(stderr, "Attribute mismatch, expected 0x%08lx found 0x%08lx\n", attributes, diskattr); + exit(1); + } +} + +int +main(int argc, char *argv[]) +{ + TCHAR otherdrive; + TCHAR otherfile[ ] = _T("?:\\other.dat"); + + otherdrive = FindOtherDrive(); + + printf("Testing simple move\n"); + CreateTestFile(_T("begin.dat"), FILE_ATTRIBUTE_ARCHIVE); + DeleteTestFile(_T("end.dat")); + if (! MoveFile(_T("begin.dat"), _T("end.dat"))) { + fprintf(stderr, "MoveFile failed with code %lu\n", GetLastError()); + exit(1); + } + CheckTestFile(_T("end.dat"), FILE_ATTRIBUTE_ARCHIVE); + DeleteTestFile(_T("end.dat")); + + printf("Testing move of non-existing file\n"); + DeleteTestFile(_T("begin.dat")); + DeleteTestFile(_T("end.dat")); + if (MoveFile(_T("begin.dat"), _T("end.dat"))) { + fprintf(stderr, "MoveFile succeeded but shouldn't have\n"); + exit(1); + } else if (ERROR_FILE_NOT_FOUND != GetLastError()) { + fprintf(stderr, "MoveFile failed with unexpected code %lu\n", GetLastError()); + exit(1); + } + DeleteTestFile(_T("end.dat")); + +/* Not correctly implemented in ros, destination file is kept open after this */ +#if 0 + printf("Testing move to existing file\n"); + CreateTestFile(_T("begin.dat"), FILE_ATTRIBUTE_ARCHIVE); + CreateTestFile(_T("end.dat"), FILE_ATTRIBUTE_ARCHIVE); + if (MoveFile(_T("begin.dat"), _T("end.dat"))) { + fprintf(stderr, "MoveFile succeeded but shouldn't have\n"); + exit(1); + } else if (ERROR_ALREADY_EXISTS != GetLastError()) { + fprintf(stderr, "MoveFile failed with unexpected code %lu\n", GetLastError()); + exit(1); + } + DeleteTestFile(_T("begin.dat")); + DeleteTestFile(_T("end.dat")); +#endif + +/* Not implemented yet in ros */ +#if 0 + printf("Testing directory move\n"); + CreateTestDir(_T("begin")); + CreateTestFile(_T("begin\\file.dat"), FILE_ATTRIBUTE_NORMAL); + DeleteTestDir(_T("end")); + if (! MoveFile(_T("begin"), _T("end"))) { + fprintf(stderr, "MoveFile failed with code %lu\n", GetLastError()); + exit(1); + } + CheckTestFile(_T("end\\file.dat"), FILE_ATTRIBUTE_NORMAL); + DeleteTestFile(_T("end\\file.dat")); + DeleteTestDir(_T("end")); +#endif + + printf("Testing file move to different directory\n"); + CreateTestFile(_T("file.dat"), FILE_ATTRIBUTE_NORMAL); + CreateTestDir(_T("end")); + if (! MoveFile(_T("file.dat"), _T("end\\file.dat"))) { + fprintf(stderr, "MoveFile failed with code %lu\n", GetLastError()); + exit(1); + } + CheckTestFile(_T("end\\file.dat"), FILE_ATTRIBUTE_ARCHIVE); + DeleteTestFile(_T("end\\file.dat")); + DeleteTestDir(_T("end")); + + printf("Testing move of read-only file\n"); + CreateTestFile(_T("begin.dat"), FILE_ATTRIBUTE_READONLY); + DeleteTestFile(_T("end.dat")); + if (! MoveFile(_T("begin.dat"), _T("end.dat"))) { + fprintf(stderr, "MoveFile failed with code %lu\n", GetLastError()); + exit(1); + } + CheckTestFile(_T("end.dat"), FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_READONLY); + DeleteTestFile(_T("end.dat")); + + printf("Testing move to different drive\n"); + if (_T(' ') != otherdrive) { + otherfile[0] = otherdrive; + CreateTestFile(_T("begin.dat"), FILE_ATTRIBUTE_ARCHIVE); + DeleteTestFile(otherfile); + if (! MoveFile(_T("begin.dat"), otherfile)) { + fprintf(stderr, "MoveFile failed with code %lu\n", GetLastError()); + exit(1); + } + CheckTestFile(otherfile, FILE_ATTRIBUTE_ARCHIVE); + DeleteTestFile(otherfile); + } else { + printf(" Test skipped, no other drive available\n"); + } + + printf("Testing move/overwrite of existing file\n"); + CreateTestFile(_T("begin.dat"), FILE_ATTRIBUTE_ARCHIVE); + CreateTestFile(_T("end.dat"), FILE_ATTRIBUTE_ARCHIVE); + if (! MoveFileEx(_T("begin.dat"), _T("end.dat"), MOVEFILE_REPLACE_EXISTING)) { + fprintf(stderr, "MoveFileEx failed with code %lu\n", GetLastError()); + exit(1); + } + DeleteTestFile(_T("begin.dat")); + DeleteTestFile(_T("end.dat")); + +/* Not (correctly) implemented in ros yet */ +#if 0 + printf("Testing move/overwrite of existing readonly file\n"); + CreateTestFile(_T("begin.dat"), FILE_ATTRIBUTE_ARCHIVE); + CreateTestFile(_T("end.dat"), FILE_ATTRIBUTE_READONLY); + if (MoveFileEx(_T("begin.dat"), _T("end.dat"), MOVEFILE_REPLACE_EXISTING)) { + fprintf(stderr, "MoveFileEx succeeded but shouldn't have\n"); + exit(1); + } else if (ERROR_ALREADY_EXISTS != GetLastError() && + ERROR_ACCESS_DENIED != GetLastError()) { + fprintf(stderr, "MoveFileEx failed with unexpected code %lu\n", GetLastError()); + exit(1); + } + DeleteTestFile(_T("begin.dat")); + DeleteTestFile(_T("end.dat")); +#endif + +/* Not implemented in ros yet */ +#if 0 + printf("Testing move to different drive without COPY_ALLOWED\n"); + if (_T(' ') != otherdrive) { + otherfile[0] = otherdrive; + CreateTestFile(_T("begin.dat"), FILE_ATTRIBUTE_ARCHIVE); + DeleteTestFile(otherfile); + if (MoveFileEx(_T("begin.dat"), otherfile, 0)) { + fprintf(stderr, "MoveFileEx succeeded but shouldn't have\n"); + exit(1); + } else if (ERROR_NOT_SAME_DEVICE != GetLastError()) { + fprintf(stderr, "MoveFileEx failed with unexpected code %lu\n", GetLastError()); + exit(1); + } + DeleteTestFile(otherfile); + } else { + printf(" Test skipped, no other drive available\n"); + } +#endif + + printf("Testing move to different drive with COPY_ALLOWED\n"); + if (_T(' ') != otherdrive) { + otherfile[0] = otherdrive; + CreateTestFile(_T("begin.dat"), FILE_ATTRIBUTE_ARCHIVE); + DeleteTestFile(otherfile); + if (! MoveFileEx(_T("begin.dat"), otherfile, MOVEFILE_COPY_ALLOWED)) { + fprintf(stderr, "MoveFileEx failed with code %lu\n", GetLastError()); + exit(1); + } + CheckTestFile(otherfile, FILE_ATTRIBUTE_ARCHIVE); + DeleteTestFile(otherfile); + } else { + printf(" Test skipped, no other drive available\n"); + } + + printf("All tests successfully completed\n"); + + return 0; +} diff --git a/rosapps/tests/count/.cvsignore b/rosapps/tests/count/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/count/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/count/Makefile b/rosapps/tests/count/Makefile new file mode 100644 index 00000000000..e486cc0c2f5 --- /dev/null +++ b/rosapps/tests/count/Makefile @@ -0,0 +1,23 @@ +# $Id: Makefile,v 1.1 2004/10/21 05:12:00 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = count + +TARGET_SDKLIBS = kernel32.a user32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/count/count.c b/rosapps/tests/count/count.c new file mode 100644 index 00000000000..5d3ebb2dc67 --- /dev/null +++ b/rosapps/tests/count/count.c @@ -0,0 +1,15 @@ +/* $Id: count.c,v 1.1 2004/10/21 05:12:00 sedwards Exp $ + * + */ +#include + +int n = 0; + +int +main (int argc, char * argv []) +{ + while (1) printf ("%d ", n ++ ); + return (0); +} + +/* EOF */ diff --git a/rosapps/tests/create-links/.cvsignore b/rosapps/tests/create-links/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/create-links/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/create-links/Makefile b/rosapps/tests/create-links/Makefile new file mode 100644 index 00000000000..6dba618b3c3 --- /dev/null +++ b/rosapps/tests/create-links/Makefile @@ -0,0 +1,25 @@ +# $Id: Makefile,v 1.1 2004/10/21 05:12:00 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = create-links + +TARGET_SDKLIBS = kernel32.a gdi32.a ole32.a shell32.a shlwapi.a + +TARGET_GCCLIBS = uuid + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror -D__USE_W32API -D_WIN32_IE=0x0400 + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/create-links/create-links.c b/rosapps/tests/create-links/create-links.c new file mode 100644 index 00000000000..a2b4ce0523a --- /dev/null +++ b/rosapps/tests/create-links/create-links.c @@ -0,0 +1,97 @@ +/* + + compile via: + gcc -o create-links -D_WIN32_IE=0x400 create-links.c -lole32 -luuid -lshell32 -lshlwapi + + Martin Fuchs, 27.12.2003 + +*/ + +#define WIN32_LEAN_AND_MEAN +#include + +#include +#include +#include + +#include + +HRESULT CreateShellLink(LPCSTR linkPath, LPCSTR cmd, LPCSTR arg, LPCSTR dir, LPCSTR iconPath, int icon_nr, LPCSTR comment) +{ + IShellLinkA* psl; + IPersistFile* ppf; + WCHAR buffer[MAX_PATH]; + + HRESULT hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID*)&psl); + + printf("creating shortcut file '%s' to %s...\n", linkPath, cmd); + + if (SUCCEEDED(hr)) { + hr = psl->lpVtbl->SetPath(psl, cmd); + + if (arg) + hr = psl->lpVtbl->SetArguments(psl, arg); + + if (dir) + hr = psl->lpVtbl->SetWorkingDirectory(psl, dir); + + if (iconPath) + hr = psl->lpVtbl->SetIconLocation(psl, iconPath, icon_nr); + + if (comment) + hr = psl->lpVtbl->SetDescription(psl, comment); + + hr = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf); + + if (SUCCEEDED(hr)) { + MultiByteToWideChar(CP_ACP, 0, linkPath, -1, buffer, MAX_PATH); + + hr = ppf->lpVtbl->Save(ppf, buffer, TRUE); + + ppf->lpVtbl->Release(ppf); + } + + psl->lpVtbl->Release(psl); + } + + if (SUCCEEDED(hr)) + printf("OK\n\n"); + else + printf("error %08x\n\n", (int) hr); + + return hr; +} + + +int main() +{ + char path[MAX_PATH]; + LPSTR p; + + CoInitialize(NULL); + + /* create some shortcuts in the start menu "programs" folder */ + SHGetSpecialFolderPathA(0, path, CSIDL_PROGRAMS, TRUE); + p = PathAddBackslash(path); + + strcpy(p, "start-cmd.lnk"); + CreateShellLink(path, "cmd.exe", "", NULL, NULL, 0, "open console window"); + + strcpy(p, "start-winhello.lnk"); + CreateShellLink(path, "winhello.exe", "", NULL, NULL, 0, "launch winhello"); + + + /* create some shortcuts on the desktop */ + SHGetSpecialFolderPathA(0, path, CSIDL_DESKTOP, TRUE); + p = PathAddBackslash(path); + + strcpy(p, "start-wcmd.lnk"); + CreateShellLink(path, "cmd.exe", "", NULL, NULL, 0, "open console window"); + + strcpy(p, "start-winemine.lnk"); + CreateShellLink(path, "winemine.exe", "", NULL, NULL, 0, "launch winemine"); + + CoUninitialize(); + + return 0; +} diff --git a/rosapps/tests/dibtest/.cvsignore b/rosapps/tests/dibtest/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/dibtest/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/dibtest/dibtest.c b/rosapps/tests/dibtest/dibtest.c new file mode 100644 index 00000000000..27ce8091614 --- /dev/null +++ b/rosapps/tests/dibtest/dibtest.c @@ -0,0 +1,196 @@ +#include +#include +#include + +#define CELL_SIZE 10 + +static RGBQUAD Colors[] = +{ + { 0x00, 0x00, 0x00, 0x00 }, // black + { 0x00, 0x00, 0x80, 0x00 }, // red + { 0x00, 0x80, 0x00, 0x00 }, // green + { 0x00, 0x80, 0x80, 0x00 }, // brown + { 0x80, 0x00, 0x00, 0x00 }, // blue + { 0x80, 0x00, 0x80, 0x00 }, // magenta + { 0x80, 0x80, 0x00, 0x00 }, // cyan + { 0x80, 0x80, 0x80, 0x00 }, // dark gray + { 0xc0, 0xc0, 0xc0, 0x00 }, // light gray + { 0x00, 0x00, 0xFF, 0x00 }, // bright red + { 0x00, 0xFF, 0x00, 0x00 }, // bright green + { 0x00, 0xFF, 0xFF, 0x00 }, // bright yellow + { 0xFF, 0x00, 0x00, 0x00 }, // bright blue + { 0xFF, 0x00, 0xFF, 0x00 }, // bright magenta + { 0xFF, 0xFF, 0x00, 0x00 }, // bright cyan + { 0xFF, 0xFF, 0xFF, 0x00 } // bright white +}; + +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 = "DibTestClass"; + 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("DibTestClass", + "DIB Test", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + 25 * CELL_SIZE + 5, + 25 * CELL_SIZE + 20, + NULL, + NULL, + hInstance, + NULL); + if (hWnd == NULL) + { + fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n", + GetLastError()); + return(1); + } + + ShowWindow(hWnd, nCmdShow); + + while(GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return msg.wParam; +} + +static void PaintCells(HDC WindowDC, WORD BitCount1, WORD BitCount2, + int XDest, int YDest) +{ + HBRUSH Brush; + RECT Rect; + UINT row, col; + BITMAPINFO *BitmapInfo; + HBITMAP DIB1, DIB2; + HDC DC1, DC2; + + BitmapInfo = malloc(sizeof(BITMAPINFO) + 15 * sizeof(RGBQUAD)); + BitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + BitmapInfo->bmiHeader.biWidth = 4 * CELL_SIZE + 9; + BitmapInfo->bmiHeader.biHeight = -(4 * CELL_SIZE + 9); // it's top down (since BI_RGB is used, the sign is operative of direction) + BitmapInfo->bmiHeader.biPlanes = 1; + BitmapInfo->bmiHeader.biBitCount = BitCount1; + BitmapInfo->bmiHeader.biCompression = BI_RGB; + BitmapInfo->bmiHeader.biSizeImage = 0; + BitmapInfo->bmiHeader.biXPelsPerMeter = 0; + BitmapInfo->bmiHeader.biYPelsPerMeter = 0; + BitmapInfo->bmiHeader.biClrUsed = 16; + BitmapInfo->bmiHeader.biClrImportant = 16; + for (col = 0; col < 16; col++) { + BitmapInfo->bmiColors[col] = Colors[col]; + } + DIB1 = CreateDIBSection(NULL, BitmapInfo, DIB_RGB_COLORS, NULL, NULL, 0); + DC1 = CreateCompatibleDC(NULL); + SelectObject(DC1, DIB1); + + BitmapInfo->bmiHeader.biBitCount = BitCount2; + DIB2 = CreateDIBSection(NULL, BitmapInfo, DIB_RGB_COLORS, NULL, NULL, 0); + DC2 = CreateCompatibleDC(NULL); + SelectObject(DC2, DIB2); + free(BitmapInfo); + + /* Now paint on the first bitmap */ + for (row = 0; row < 4; row++) + { + for (col = 0; col < 4; col++) + { + Brush = CreateSolidBrush(RGB(Colors[4 * row + col].rgbRed, + Colors[4 * row + col].rgbGreen, + Colors[4 * row + col].rgbBlue)); + Rect.left = CELL_SIZE * col + 5; + Rect.top = CELL_SIZE * row + 5; + Rect.right = Rect.left + CELL_SIZE; + Rect.bottom = Rect.top + CELL_SIZE; + FillRect(DC1, &Rect, Brush); + DeleteObject(Brush); + } + } + + /* Copy the first bitmap to the second */ + BitBlt(DC2, 4, 4, 4 * CELL_SIZE, 4 * CELL_SIZE, DC1, 5, 5, SRCCOPY); + + /* Show results on screen */ + BitBlt(WindowDC, XDest, YDest, 4 * CELL_SIZE, 4 * CELL_SIZE, DC2, 4, 4, SRCCOPY); +} + +LRESULT CALLBACK MainWndProc(HWND Wnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PAINTSTRUCT ps; + HDC WindowDC; + + switch(msg) + { + case WM_PAINT: + WindowDC = BeginPaint(Wnd, &ps); + + PaintCells(WindowDC, 4, 4, 0, 0); + PaintCells(WindowDC, 4, 8, 5 * CELL_SIZE, 0); + PaintCells(WindowDC, 4, 16, 10 * CELL_SIZE, 0); + PaintCells(WindowDC, 4, 24, 15 * CELL_SIZE, 0); + PaintCells(WindowDC, 4, 32, 20 * CELL_SIZE, 0); + + PaintCells(WindowDC, 8, 4, 0, 5 * CELL_SIZE); + PaintCells(WindowDC, 8, 8, 5 * CELL_SIZE, 5 * CELL_SIZE); + PaintCells(WindowDC, 8, 16, 10 * CELL_SIZE, 5 * CELL_SIZE); + PaintCells(WindowDC, 8, 24, 15 * CELL_SIZE, 5 * CELL_SIZE); + PaintCells(WindowDC, 8, 32, 20 * CELL_SIZE, 5 * CELL_SIZE); + + PaintCells(WindowDC, 16, 4, 0, 10 * CELL_SIZE); + PaintCells(WindowDC, 16, 8, 5 * CELL_SIZE, 10 * CELL_SIZE); + PaintCells(WindowDC, 16, 16, 10 * CELL_SIZE, 10 * CELL_SIZE); + PaintCells(WindowDC, 16, 24, 15 * CELL_SIZE, 10 * CELL_SIZE); + PaintCells(WindowDC, 16, 32, 20 * CELL_SIZE, 10 * CELL_SIZE); + + PaintCells(WindowDC, 24, 4, 0, 15 * CELL_SIZE); + PaintCells(WindowDC, 24, 8, 5 * CELL_SIZE, 15 * CELL_SIZE); + PaintCells(WindowDC, 24, 16, 10 * CELL_SIZE, 15 * CELL_SIZE); + PaintCells(WindowDC, 24, 24, 15 * CELL_SIZE, 15 * CELL_SIZE); + PaintCells(WindowDC, 24, 32, 20 * CELL_SIZE, 15 * CELL_SIZE); + + PaintCells(WindowDC, 32, 4, 0, 20 * CELL_SIZE); + PaintCells(WindowDC, 32, 8, 5 * CELL_SIZE, 20 * CELL_SIZE); + PaintCells(WindowDC, 32, 16, 10 * CELL_SIZE, 20 * CELL_SIZE); + PaintCells(WindowDC, 32, 24, 15 * CELL_SIZE, 20 * CELL_SIZE); + PaintCells(WindowDC, 32, 32, 20 * CELL_SIZE, 20 * CELL_SIZE); + + EndPaint(Wnd, &ps); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProc(Wnd, msg, wParam, lParam); + } + + return 0; +} diff --git a/rosapps/tests/dibtest/makefile b/rosapps/tests/dibtest/makefile new file mode 100644 index 00000000000..94851812179 --- /dev/null +++ b/rosapps/tests/dibtest/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:00 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = dibtest + +TARGET_SDKLIBS = kernel32.a gdi32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/dirdlg/.cvsignore b/rosapps/tests/dirdlg/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/dirdlg/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/dirdlg/dirdlg.c b/rosapps/tests/dirdlg/dirdlg.c new file mode 100644 index 00000000000..fdcb074dd78 --- /dev/null +++ b/rosapps/tests/dirdlg/dirdlg.c @@ -0,0 +1,115 @@ +#include +#include +#include +#include +#include "resource.h" + +static char selected[MAX_PATH + 1]; + +INT_PTR +CALLBACK +DlgMainProc( + HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam +) +{ + char dir[MAX_PATH + 1]; + + switch(uMsg) + { + case WM_COMMAND: + { + switch(HIWORD(wParam)) + { + case LBN_DBLCLK: + { + switch(LOWORD(wParam)) + { + case IDC_DIRS: + { + if(DlgDirSelectEx(hwndDlg, dir, MAX_PATH, IDC_DIRS)) + { + chdir(dir); + GetCurrentDirectory(MAX_PATH, dir); + DlgDirList(hwndDlg, dir, IDC_DIRS, IDC_DIREDIT, DDL_DIRECTORY | DDL_DRIVES); + } + else + { + SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_OK, 0), 0); + } + break; + } + } + break; + } + default: + { + switch(LOWORD(wParam)) + { + case IDC_OK: + { + char file[MAX_PATH + 1]; + int len; + + if(!DlgDirSelectEx(hwndDlg, file, MAX_PATH, IDC_DIRS)) + { + GetCurrentDirectory(MAX_PATH, selected); + len = strlen(selected); + if(strlen(file)) + { + if(selected[len - 1] != '\\') + { + lstrcat(selected, "\\"); + } + lstrcat(selected, file); + EndDialog(hwndDlg, IDC_OK); + } + } + break; + } + case IDC_CANCEL: + { + EndDialog(hwndDlg, IDC_CANCEL); + break; + } + } + break; + } + } + break; + } + case WM_INITDIALOG: + { + SendDlgItemMessage(hwndDlg, IDC_DIRS, LB_SETCOLUMNWIDTH, 150, 0); + GetCurrentDirectory(MAX_PATH, dir); + DlgDirList(hwndDlg, dir, IDC_DIRS, IDC_DIREDIT, DDL_DIRECTORY | DDL_DRIVES); + SetFocus(GetDlgItem(hwndDlg, IDC_DIRS)); + break; + } + case WM_CLOSE: + { + EndDialog(hwndDlg, IDC_CANCEL); + return TRUE; + } + } + return FALSE; +} + +int WINAPI +WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) +{ + char str[MAX_PATH + 32]; + if(DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), 0, DlgMainProc) == IDC_OK) + { + sprintf(str, "You selected \"%s\"", selected); + MessageBox(0, str, "Selected file", MB_ICONINFORMATION); + } + return 0; +} + diff --git a/rosapps/tests/dirdlg/dirdlg.rc b/rosapps/tests/dirdlg/dirdlg.rc new file mode 100644 index 00000000000..72385411b88 --- /dev/null +++ b/rosapps/tests/dirdlg/dirdlg.rc @@ -0,0 +1,14 @@ +#include +#include +#include "resource.h" + +IDD_MAIN DIALOG DISCARDABLE 20, 20, 220, 140 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +FONT 8, "MS Sans Serif" +CAPTION "Select a file" +BEGIN + EDITTEXT IDC_DIREDIT, 5, 5, 210, 13, ES_READONLY | ES_LEFT | WS_CHILD | WS_VISIBLE | WS_TABSTOP + LISTBOX IDC_DIRS, 5, 23, 210, 92, LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | LBS_MULTICOLUMN | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL + PUSHBUTTON "&OK", IDC_OK, 60, 120, 40, 15, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "&Cancel", IDC_CANCEL, 120, 120, 40, 15, WS_CHILD | WS_VISIBLE | WS_TABSTOP +END diff --git a/rosapps/tests/dirdlg/makefile b/rosapps/tests/dirdlg/makefile new file mode 100644 index 00000000000..69d454e5abe --- /dev/null +++ b/rosapps/tests/dirdlg/makefile @@ -0,0 +1,21 @@ +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = no + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = dirdlg + +TARGET_SDKLIBS = ntdll.a kernel32.a gdi32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/dirdlg/resource.h b/rosapps/tests/dirdlg/resource.h new file mode 100644 index 00000000000..7a1063b932e --- /dev/null +++ b/rosapps/tests/dirdlg/resource.h @@ -0,0 +1,6 @@ +#define IDD_MAIN 101 + +#define IDC_OK 1 +#define IDC_CANCEL 2 +#define IDC_DIRS 100 +#define IDC_DIREDIT 101 diff --git a/rosapps/tests/diskspeed/.cvsignore b/rosapps/tests/diskspeed/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/diskspeed/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/diskspeed/diskspeed.c b/rosapps/tests/diskspeed/diskspeed.c new file mode 100644 index 00000000000..d19f8c0f344 --- /dev/null +++ b/rosapps/tests/diskspeed/diskspeed.c @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2004 ReactOS Team + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS diskspeed.exe + * FILE: apps/tests/diskspeed/diskspeed.c + * PURPOSE: Determines disk transfer rates + * PROGRAMMER: Hartmut Birr + */ + +#include +#include +#include +#include +#include +#include + +BOOL GetInquiryData(HANDLE hDevice, PINQUIRYDATA InquiryData) +{ + BOOL Result; + DWORD dwReturned; + SCSI_ADDRESS ScsiAddress; + PSCSI_ADAPTER_BUS_INFO AdapterInfo; + PSCSI_INQUIRY_DATA InquiryBuffer; + BYTE Buffer[4096]; + int i; + + Result = DeviceIoControl(hDevice, + IOCTL_SCSI_GET_ADDRESS, + NULL, + 0, + &ScsiAddress, + sizeof(ScsiAddress), + &dwReturned, + FALSE); + if (Result == FALSE) + { + return FALSE; + } + Result = DeviceIoControl(hDevice, + IOCTL_SCSI_GET_INQUIRY_DATA, + NULL, + 0, + Buffer, + sizeof(Buffer), + &dwReturned, + FALSE); + if (Result) + { + AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)Buffer; + for (i = 0; i < AdapterInfo->NumberOfBuses; i++) + { + InquiryBuffer = (PSCSI_INQUIRY_DATA) (Buffer + AdapterInfo->BusData[i].InquiryDataOffset); + if (AdapterInfo->BusData[i].InquiryDataOffset) + { + while (1) + { + if (InquiryBuffer->PathId == ScsiAddress.PathId && + InquiryBuffer->TargetId == ScsiAddress.TargetId && + InquiryBuffer->Lun == ScsiAddress.Lun) + { + memcpy(InquiryData, InquiryBuffer->InquiryData, sizeof(INQUIRYDATA)); + return TRUE; + } + if (InquiryBuffer->NextInquiryDataOffset == 0) + { + break; + } + InquiryBuffer = (PSCSI_INQUIRY_DATA) (Buffer + InquiryBuffer->NextInquiryDataOffset); + } + } + } + } + return FALSE; +} + + + +int main(void) +{ + HANDLE hDevice; + OVERLAPPED ov; + + PBYTE Buffer; + DWORD Start; + DWORD dwReturned; + DWORD dwReadTotal; + DWORD Size; + BOOL Result; + ULONG Drive; + CHAR Name[20]; + + INQUIRYDATA InquiryData; + + + Drive = 0; + while (1) + { + sprintf(Name, "\\\\.\\PHYSICALDRIVE%ld", Drive); + hDevice = CreateFile(Name, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + 0, + NULL); + if (hDevice == INVALID_HANDLE_VALUE) + { + if (Drive > 0) + { + VirtualFree(Buffer, 512 * 1024, MEM_RELEASE); + } + else + { + printf("Cannot open '%s'\n", Name); + } + break; + } + if (Drive == 0) + { + printf("Transfer Size (kB) 1 2 4 8 16 32 64 128 256\n"); + printf("Transfer Rate (MB/s)\n"); + printf("-------------------------------------------------------------------------------\n"); + + Buffer = VirtualAlloc(NULL, 512 * 1024, MEM_COMMIT, PAGE_READWRITE); + } + Result = GetInquiryData(hDevice, &InquiryData); + if (Result) + { + printf("%.24s ", InquiryData.VendorId); + } + else + { + printf("Disk %ld ", Drive + 1); + } + Size = 1024; + memset(&ov, 0, sizeof(OVERLAPPED)); + while (Size <= 256 * 1024) + { + memset(Buffer, 0, Size); + dwReadTotal = 0; + + Start = GetTickCount() + 2000; + while (Start > GetTickCount()) + { + Result = ReadFile(hDevice, Buffer, Size, &dwReturned, &ov); + if (Result) + { + dwReadTotal += dwReturned; + ov.Offset += dwReturned; + } + } + dwReadTotal /= 2048; + printf("%3ld.%ld ", dwReadTotal / 1024, (dwReadTotal % 1024) * 10 / 1024); + Size *= 2; + } + printf("\n"); + CloseHandle(hDevice); + Drive++; + } + printf("\n"); + + + return 0; +} diff --git a/rosapps/tests/diskspeed/makefile b/rosapps/tests/diskspeed/makefile new file mode 100644 index 00000000000..d2ec7a2e9a9 --- /dev/null +++ b/rosapps/tests/diskspeed/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:00 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = diskspeed + +TARGET_SDKLIBS = kernel32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/dnsapi/.cvsignore b/rosapps/tests/dnsapi/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/dnsapi/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/dnsapi/dnsapi.c b/rosapps/tests/dnsapi/dnsapi.c new file mode 100644 index 00000000000..b85a1f20d8c --- /dev/null +++ b/rosapps/tests/dnsapi/dnsapi.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include +#include + +int main( int argc, char **argv ) { + PDNS_RECORD QueryReply, AddrResponse; + DWORD Addr; + + assert (DnsValidateName( "||||", DnsNameDomain ) == DNS_ERROR_INVALID_NAME_CHAR); + assert (DnsValidateName( "a.b.c", DnsNameDomainLabel ) == DNS_ERROR_INVALID_NAME); + assert (DnsValidateName( "1234", DnsNameDomainLabel ) == ERROR_SUCCESS); + assert (DnsValidateName( "fubar", DnsNameDomain ) == ERROR_SUCCESS); + assert (DnsQuery ("www.reactos.com", DNS_TYPE_A, DNS_QUERY_STANDARD, + NULL, &QueryReply, NULL) == ERROR_SUCCESS); + AddrResponse = QueryReply; + while( AddrResponse ) { + if( AddrResponse->wType == DNS_TYPE_A ) { + Addr = ntohl( AddrResponse->Data.A.IpAddress ); + printf( "www.reactos.com == %d.%d.%d.%d\n", + (int)(Addr >> 24) & 0xff, + (int)(Addr >> 16) & 0xff, + (int)(Addr >> 8) & 0xff, + (int)Addr & 0xff ); + } + AddrResponse = AddrResponse->pNext; + } + DnsRecordListFree( QueryReply, DnsFreeRecordList ); + + return 0; +} diff --git a/rosapps/tests/dnsapi/makefile b/rosapps/tests/dnsapi/makefile new file mode 100644 index 00000000000..ee9431e5689 --- /dev/null +++ b/rosapps/tests/dnsapi/makefile @@ -0,0 +1,22 @@ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = dnsapi + +TARGET_SDKLIBS = dnsapi.a ws2_32.a kernel32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -D__USE_W32API -Wall -Werror -g + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/dnsquery/.cvsignore b/rosapps/tests/dnsquery/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/dnsquery/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/dnsquery/dnsquery.c b/rosapps/tests/dnsquery/dnsquery.c new file mode 100644 index 00000000000..45780207eae --- /dev/null +++ b/rosapps/tests/dnsquery/dnsquery.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include + +int main( int argc, char **argv ) { + PDNS_RECORD QueryReply, AddrResponse; + DWORD Addr; + + assert (DnsQuery ("www.reactos.com", DNS_TYPE_A, DNS_QUERY_STANDARD, + NULL, &QueryReply, NULL) == ERROR_SUCCESS); + AddrResponse = QueryReply; + while( AddrResponse ) { + if( AddrResponse->wType == DNS_TYPE_A ) { + Addr = ntohl( AddrResponse->Data.A.IpAddress ); + printf( "www.reactos.com == %d.%d.%d.%d\n", + (int)(Addr >> 24) & 0xff, + (int)(Addr >> 16) & 0xff, + (int)(Addr >> 8) & 0xff, + (int)Addr & 0xff ); + } + AddrResponse = AddrResponse->pNext; + } + DnsRecordListFree( QueryReply, DnsFreeRecordList ); + + return 0; +} diff --git a/rosapps/tests/dnsquery/makefile b/rosapps/tests/dnsquery/makefile new file mode 100644 index 00000000000..55c9ad94b2f --- /dev/null +++ b/rosapps/tests/dnsquery/makefile @@ -0,0 +1,22 @@ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = dnsquery + +TARGET_SDKLIBS = dnsapi.a ws2_32.a kernel32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -D__USE_W32API -Wall -Werror -g + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/dump_shared_data/.cvsignore b/rosapps/tests/dump_shared_data/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/dump_shared_data/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/dump_shared_data/dump_shared_data.c b/rosapps/tests/dump_shared_data/dump_shared_data.c new file mode 100644 index 00000000000..6ae2aeb0d9e --- /dev/null +++ b/rosapps/tests/dump_shared_data/dump_shared_data.c @@ -0,0 +1,52 @@ +#include +#include + +int main() +{ + int i; + + printf("TickCountLow: %lx\n", + SharedUserData->TickCountLow); + printf("Drives: "); + for (i = 0; i < 26; i++) + { + printf("%c", (SharedUserData->DosDeviceMap & (1 << i))?'1':'0'); + } + printf("\n"); + for (i = 0; i < 26; i++) + { + if (SharedUserData->DosDeviceMap & (1 << i)) + { + printf("%c: ", 'A'+i); + switch(SharedUserData->DosDeviceDriveType[i]) + { + case DOSDEVICE_DRIVE_UNKNOWN: + printf("Unknown\n"); + break; + case DOSDEVICE_DRIVE_CALCULATE: + printf("No root\n"); + break; + case DOSDEVICE_DRIVE_REMOVABLE: + printf("Removable\n"); + break; + case DOSDEVICE_DRIVE_FIXED: + printf("Fixed\n"); + break; + case DOSDEVICE_DRIVE_REMOTE: + printf("Remote\n"); + break; + case DOSDEVICE_DRIVE_CDROM: + printf("CD-ROM\n"); + break; + case DOSDEVICE_DRIVE_RAMDISK: + printf("Ram disk\n"); + break; + default: + printf("undefined type\n"); + break; + } + } + } + printf("\n\n"); + return 0; +} diff --git a/rosapps/tests/dump_shared_data/makefile b/rosapps/tests/dump_shared_data/makefile new file mode 100644 index 00000000000..48722fa7989 --- /dev/null +++ b/rosapps/tests/dump_shared_data/makefile @@ -0,0 +1,22 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:01 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = dump_shared_data + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF + diff --git a/rosapps/tests/edit/.cvsignore b/rosapps/tests/edit/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/edit/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/edit/edittest.c b/rosapps/tests/edit/edittest.c new file mode 100644 index 00000000000..723464651c8 --- /dev/null +++ b/rosapps/tests/edit/edittest.c @@ -0,0 +1,649 @@ +/* Edit Control Test for ReactOS, quick n' dirty. Very rigid too. + * There you go, is only a test program. Not made to be fast, small + * easy to mantain, or portable. Lots of duplicated code too. + + * I'm not erasing text because I don't want to use other functions from th API + * or make this more complex. + + * This source code is in the PUBLIC DOMAIN and has NO WARRANTY. + * by Waldo Alvarez Caņizares , June 22, 2003. */ + +//#define WIN32_LEAN_AND_MEAN +#include +#include "utils.h" + +#define CREATEWINDOW 106 +#define CREATEWINDOWEX 107 +#define CREATEWINDOWW 108 + +#define ResultX 0 +#define ResultY 305 + +#define NOTIFYX 350 +#define NOTIFYY 285 + +#define BUFFERLEN 80 /* Size of buffer to hold result strings */ + +/* Edit is created with this text */ +#define TestStr "The quick brown fox jumps over the lazy dog" + +#define TestStrW L"This is a WCHAR string" /* Wide to support unicode edits */ + +#define MAXMESSAGEBUTTONS 42 + +HWND g_hwnd = NULL; +HINSTANCE g_hInst = NULL; + +int pos = 10; +int n = 0; +int yButPos = 10; +int xButPos = 10; + +DWORD EditStyle = 0; +DWORD EditWidth = 240; +DWORD EditHeight = 250; + +BOOL UnicodeUsed = FALSE; + +HWND hwndEdit = NULL; + +POINTL point={10,3}; +RECT rect = {0,0,20,20},rect2; +DWORD StartP,EndP; + +#define ReplaceTextStr "->> Replaced!! <<-" + +char* AllocatedText; /* Buffer in the heap to feed it to the edit control */ +char* NewText = "New text for the edit control"; +wchar_t* NewTextW = L"New text for the edit control in UNICODE"; // Wide + +char TextBuffer[BUFFERLEN]={'R','e','s','u','l','t',':',' '}; + +typedef void FunctionHandler(HWND,DWORD,WPARAM,LPARAM); +typedef FunctionHandler* LPFUNCTIONHANDLER; + +VOID +PrintTextXY(char* Text,int x,int y,int len) +{ + HDC hdc; + hdc = GetDC (g_hwnd); + SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)); + + TextOut (hdc, x,y,Text,len); + ReleaseDC (g_hwnd, hdc); + ValidateRect (g_hwnd, &rect); +} + +static +VOID +HandlePrintReturnHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam) + { + int ret; + ret = SendMessage(handle,Msg,wParam,lParam); + htoa(ret,&TextBuffer[8]); + PrintTextXY(TextBuffer,ResultX,ResultY,16); + } + +static +VOID +HandleSetHandlePrintHex(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam) + { + LPVOID pMem; + HANDLE hNewBuffer; + int ret; + + LocalFree((HLOCAL)SendMessage(handle, EM_GETHANDLE, 0, 0L)); + if (UnicodeUsed) + { + hNewBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, 100); + pMem = LocalLock(hNewBuffer); + strcpyw_((wchar_t*)pMem,NewTextW); + } + else + { + hNewBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT,50); + pMem = LocalLock(hNewBuffer); + strcpy_((char*)pMem,NewText); + } + + LocalUnlock(pMem); + hNewBuffer = LocalHandle(pMem); + + /* Updates the buffer and displays new buffer */ + ret = SendMessage(handle, EM_SETHANDLE, (WPARAM)hNewBuffer, 0L); + + htoa(ret,&TextBuffer[8]); + PrintTextXY(TextBuffer,ResultX,ResultY,16); + } + +static +VOID +HandlePrintReturnStr(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam) + { + int ret; + TextBuffer[8] = (char)(BUFFERLEN - 8); /* Setting the max size to put chars in first byte */ + ret = SendMessage(handle,Msg,wParam,lParam); + PrintTextXY(TextBuffer,ResultX,ResultY,8+ret); + } + +static +VOID +HandlePrintRect(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam) + { + TextBuffer[8] = (char)(BUFFERLEN - 8); /* Setting the max size to put chars in first byte */ + SendMessage(handle,Msg,wParam,lParam); + + htoa(rect.top,&TextBuffer[8]); + TextBuffer[8+8] = ' '; + htoa(rect.bottom,&TextBuffer[8+8+1]); + TextBuffer[8+8+8+1] = ' '; + htoa(rect.left,&TextBuffer[8+8+8+1+1]); + TextBuffer[8+8+8+8+1+1] = ' '; + htoa(rect.right,&TextBuffer[8+8+8+8+1+1+1]); + + PrintTextXY(TextBuffer,ResultX,ResultY,8+4*9-1); + } + +static +VOID +HandlePrintPasswdChar(HWND handle,DWORD Msg,WPARAM wParam,LPARAM lParam) + { + HDC hdc; + int ret = SendMessage(handle,Msg,wParam,lParam); + + int s; + + if (ret) + { + s = 1; + TextBuffer[8] = (char)(ret); + } + else + { + TextBuffer[8] = 'N'; + TextBuffer[9] = 'U'; + TextBuffer[10] = 'L'; + TextBuffer[11] = 'L'; + s = 4; + } + + hdc = GetDC (g_hwnd); + SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)); + + TextOut (hdc,ResultX ,ResultY,TextBuffer,8+s); + ReleaseDC (g_hwnd, hdc); + ValidateRect (g_hwnd, &rect); + } + + +struct +{ + char* Text; /* Text for the button */ + DWORD MsgCode; /* Message Code */ + WPARAM wParam; /* Well hope you can understand this */ + LPARAM lParam; /* ditto */ + LPFUNCTIONHANDLER Handler; /* Funtion called to handle the result of each message */ +} +Msg[] = +{ + {"EM_CANUNDO",EM_CANUNDO,0,0,&HandlePrintReturnHex}, + {"EM_CHARFROMPOS",EM_CHARFROMPOS,(WPARAM)&point,0,&HandlePrintReturnHex}, + {"EM_EMPTYUNDOBUFFER",EM_EMPTYUNDOBUFFER,0,0,&HandlePrintReturnHex}, + {"EM_FMTLINES",EM_FMTLINES,TRUE,0,&HandlePrintReturnHex}, + {"EM_GETFIRSTVISIBLELINE",EM_GETFIRSTVISIBLELINE,0,0,&HandlePrintReturnHex}, + + {"EM_GETLIMITTEXT",EM_GETLIMITTEXT,0,0,&HandlePrintReturnHex}, + {"EM_GETLINE",EM_GETLINE,2,(WPARAM)&TextBuffer[8],&HandlePrintReturnStr}, + {"EM_GETLINECOUNT",EM_GETLINECOUNT,0,0,&HandlePrintReturnHex}, + {"EM_GETMARGINS",EM_GETMARGINS,0,0,&HandlePrintReturnHex}, + {"EM_SETMARGINS",EM_SETMARGINS,EC_LEFTMARGIN,10,&HandlePrintReturnHex}, + + {"EM_GETMODIFY",EM_GETMODIFY,0,0,&HandlePrintReturnHex}, + {"EM_SETMODIFY",EM_SETMODIFY,TRUE,0,&HandlePrintReturnHex}, + + {"EM_GETSEL",EM_GETSEL,(WPARAM)&StartP,(LPARAM)&EndP,&HandlePrintReturnHex}, + + {"EM_GETTHUMB",EM_GETTHUMB,0,0,&HandlePrintReturnHex}, + + {"EM_LIMITTEXT",EM_LIMITTEXT,10,0,&HandlePrintReturnHex}, + {"EM_LINEFROMCHAR",EM_LINEFROMCHAR,-1,0,&HandlePrintReturnHex}, + {"EM_POSFROMCHAR",EM_POSFROMCHAR,10,0,&HandlePrintReturnHex}, + {"EM_LINEINDEX",EM_LINEINDEX,2,0,&HandlePrintReturnHex}, + {"EM_LINELENGTH",EM_LINELENGTH,-1,0,&HandlePrintReturnHex}, + + {"EM_GETWORDBREAKPROC",EM_GETWORDBREAKPROC,0,0,&HandlePrintReturnHex}, + {"EM_REPLACESEL",EM_REPLACESEL,TRUE,(LPARAM)&ReplaceTextStr,&HandlePrintReturnHex}, + + {"EM_LINESCROLL",EM_LINESCROLL,5,1,&HandlePrintReturnHex}, + {"EM_SCROLL",EM_SCROLL,SB_LINEDOWN,0,&HandlePrintReturnHex}, + {"EM_SCROLLCARET",EM_SCROLLCARET,0,0,&HandlePrintReturnHex}, + + {"EM_SETHANDLE",EM_SETHANDLE,0,0,&HandleSetHandlePrintHex}, + {"EM_GETHANDLE",EM_GETHANDLE,0,0,&HandlePrintReturnHex}, + {"EM_GETPASSWORDCHAR",EM_GETPASSWORDCHAR,0,0,&HandlePrintPasswdChar}, + {"EM_SETPASSWORDCHAR - clear",EM_SETPASSWORDCHAR,0,0,&HandlePrintReturnHex}, + {"EM_SETPASSWORDCHAR - x",EM_SETPASSWORDCHAR,'x',0,&HandlePrintReturnHex}, + + {"EM_SETREADONLY - set",EM_SETREADONLY,TRUE,0,&HandlePrintReturnHex}, + {"EM_SETREADONLY - clear",EM_SETREADONLY,FALSE,0,&HandlePrintReturnHex}, + + {"EM_GETRECT",EM_GETRECT,0,(LPARAM)&rect2,&HandlePrintRect}, + {"EM_SETRECT",EM_SETRECT,0,(LPARAM)&rect,&HandlePrintReturnHex}, + {"EM_SETRECTNP",EM_SETRECTNP,0,(LPARAM)&rect,&HandlePrintReturnHex}, + {"EM_SETSEL",EM_SETSEL,1,3,&HandlePrintReturnHex}, + + {"EM_SETSEL - all",EM_SETSEL,0,-1,&HandlePrintReturnHex}, + {"EM_SETSEL - remove",EM_SETSEL,-1,0,&HandlePrintReturnHex}, + {"EM_UNDO",EM_UNDO,0,0,&HandlePrintReturnHex}, + {"WM_UNDO",WM_UNDO,0,0,&HandlePrintReturnHex}, + {"WM_PASTE",WM_PASTE,0,0,&HandlePrintReturnHex}, + + {"WM_CUT",WM_CUT,0,0,&HandlePrintReturnHex}, + {"WM_COPY",WM_COPY,0,0,&HandlePrintReturnHex} + +}; + +DWORD EditStyles[] = { + WS_THICKFRAME,WS_DISABLED,WS_BORDER,ES_LOWERCASE,ES_UPPERCASE,ES_NUMBER,ES_AUTOVSCROLL, + ES_AUTOHSCROLL,ES_LEFT,ES_CENTER,ES_RIGHT,ES_MULTILINE, + ES_NOHIDESEL,ES_OEMCONVERT,ES_PASSWORD,ES_READONLY,ES_WANTRETURN, + WS_HSCROLL,WS_VSCROLL + }; + +char* StyleNames[] = { + "WS_THICKFRAME","WS_DISABLED","WS_BORDER","ES_LOWERCASE","ES_UPPERCASE","ES_NUMBER","ES_AUTOVSCROLL", + "ES_AUTOHSCROLL","ES_LEFT","ES_CENTER","ES_RIGHT","ES_MULTILINE", + "ES_NOHIDESEL","ES_OEMCONVERT","ES_PASSWORD","ES_READONLY","ES_WANTRETURN", + "WS_HSCROLL","WS_VSCROLL" + }; + +#define NUMBERBUTTONS 26 +HWND Buttons[NUMBERBUTTONS]; +HWND MessageButtons[MAXMESSAGEBUTTONS]; +HWND Back1But,Back2But; +HWND NextBut; + + +HWND +CreateCheckButton(const char* lpWindowName, DWORD xSize, DWORD id) + { + HWND h; + h = CreateWindowEx(0, + "BUTTON", + lpWindowName, + WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, + xButPos, /* x */ + yButPos, /* y */ + xSize, /* nWidth */ + 20, /* nHeight */ + g_hwnd, + (HMENU) id, + g_hInst, + NULL + ); + yButPos += 21; + return h; + } + +HWND +CreatePushButton(const char* lpWindowName, DWORD xSize, DWORD id,DWORD Style) + { + + HWND h = CreateWindow("BUTTON", + lpWindowName, + WS_CHILD | BS_PUSHBUTTON | Style, + xButPos, // x + yButPos, // y + xSize, // nWidth + 20, // nHeight + g_hwnd, + (HMENU) id, + g_hInst, + NULL + ); + + yButPos += 21; + return h; + } + +VOID +ReadNHide() + { + int i; + EditStyle = 0; + for (i=0 ; i< 19 ; i++) + { + if(BST_CHECKED == SendMessage(Buttons[i],BM_GETCHECK,0,0)) + EditStyle |= EditStyles[i]; + ShowWindow(Buttons[i],SW_HIDE); + } + + for (; i< NUMBERBUTTONS ; i++)ShowWindow(Buttons[i],SW_HIDE); + for (i=0 ; i< 26 ; i++) ShowWindow(MessageButtons[i],SW_SHOW); + + ShowWindow(Back1But,SW_SHOW); + ShowWindow(NextBut,SW_SHOW); + } + +VOID +ForwardToSecondPage() + { + int i; + for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_HIDE); + for(;i= 600) + { + Msg[LOWORD(wParam)-600].Handler(hwndEdit, + Msg[LOWORD(wParam)-600].MsgCode, + Msg[LOWORD(wParam)-600].wParam, + Msg[LOWORD(wParam)-600].lParam); + break; + } + + switch(LOWORD(wParam)){ + + case 100: + EditWidth += 10; + break; + + case 101: + EditWidth -= 10; + break; + + case 102: + EditHeight += 10; + break; + + case 103: + EditHeight -= 10; + break; + + case 400: + BackToInitialPage(); + break; + + case 401: + ForwardToSecondPage(); + break; + + case 402: + BackToFirstPage(); + break; + + case CREATEWINDOW: + UnicodeUsed = FALSE; + ReadNHide(); + hwndEdit = CreateWindow("EDIT", + TestStr, + EditStyle | WS_CHILD | WS_VISIBLE, + 350, + 10, + EditWidth, + EditHeight, + g_hwnd, + NULL, + g_hInst, + NULL); + break; + + case CREATEWINDOWEX: + UnicodeUsed = FALSE; + ReadNHide(); + hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, + "EDIT", + TestStr, + EditStyle | WS_CHILD | WS_VISIBLE , + 350, + 10, + EditWidth, + EditHeight, + g_hwnd, + NULL, + g_hInst, + NULL); + break; + + case CREATEWINDOWW: + UnicodeUsed = TRUE; + ReadNHide(); + hwndEdit = CreateWindowExW(WS_EX_CLIENTEDGE, + L"EDIT", + TestStrW, + EditStyle | WS_CHILD | WS_VISIBLE , + 350, + 10, + EditWidth, + EditHeight, + g_hwnd, + NULL, + g_hInst, + NULL); + break; + } + + if (lParam == (LPARAM)hwndEdit) + switch(HIWORD(wParam)) + { + case EN_CHANGE: + PrintTextXY("EN_CHANGE notification",NOTIFYX,NOTIFYY,22); + break; + + case EN_ERRSPACE: + PrintTextXY("EN_ERRSPACE notification",NOTIFYX,NOTIFYY,24); + break; + + /* --- FIXME not defined in w32api-2.3 headers + case H_SCROLL: + PrintTextXY("H_SCROLL notification",NOTIFYX,NOTIFYY,21); + break; */ + + /* --- FIXME not defined in w32api-2.3 headers + case KILL_FOCUS: + PrintTextXY("KILL_FOCUS notification",NOTIFYX,NOTIFYY,23); + break; */ + + /* --- FIXME not defined in w32api-2.3 headers + case EN_MAXTEST: + PrintTextXY("EN_MAXTEXT notification",NOTIFYX,NOTIFYY,23); + break; */ + + case EN_SETFOCUS: + PrintTextXY("EN_SETFOCUS notification",NOTIFYX,NOTIFYY,24); + break; + + case EN_UPDATE: + PrintTextXY("EN_UPDATE notification",NOTIFYX,NOTIFYY + 20,22); + break; + + case EN_VSCROLL: + PrintTextXY("EN_VSCROLL notification",NOTIFYX,NOTIFYY,23); + break; + + } + + break; + + case WM_SIZE : + return 0; + + case WM_CLOSE: + DestroyWindow (g_hwnd); + return 0; + + case WM_QUERYENDSESSION: + return 0; + + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + return DefWindowProc ( hwnd, msg, wParam, lParam ); +} + +HWND +RegisterAndCreateWindow (HINSTANCE hInst, + const char* className, + const char* title) +{ + WNDCLASSEX wc; + HWND hwnd; + + g_hInst = hInst; + + wc.cbSize = sizeof (WNDCLASSEX); + + wc.lpfnWndProc = WndProc; /* window procedure */ + wc.hInstance = hInst; /* owner of the class */ + + wc.lpszClassName = className; + wc.hCursor = LoadCursor ( 0, (LPCTSTR)IDC_ARROW ); + wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hIcon = 0; + wc.hIconSm = 0; + wc.lpszMenuName = 0; + + if ( !RegisterClassEx ( &wc ) ) + return NULL; + + hwnd = CreateWindowEx ( + 0, /* dwStyleEx */ + className, /* class name */ + title, /* window title */ + + WS_OVERLAPPEDWINDOW, /* dwStyle */ + + 1, /* x */ + 1, /* y */ + 560, /* width */ + 350, /* height */ + NULL, /* hwndParent */ + NULL, /* hMenu */ + hInst, + 0 + ); + + if (!hwnd) return NULL; + + ShowWindow (hwnd, SW_SHOW); + UpdateWindow (hwnd); + + return hwnd; +} + +int +WINAPI +WinMain ( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdParam, int cmdShow ) +{ + char className [] = "Edit Control Test"; + MSG msg; + + RegisterAndCreateWindow ( hInst, className, "Edit Control Styles Test" ); + + // Message loop + while (GetMessage (&msg, NULL, 0, 0)) + { + TranslateMessage (&msg); + DispatchMessage (&msg); + } + return msg.wParam; + +} diff --git a/rosapps/tests/edit/makefile b/rosapps/tests/edit/makefile new file mode 100644 index 00000000000..bdc75204962 --- /dev/null +++ b/rosapps/tests/edit/makefile @@ -0,0 +1,24 @@ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = edittest + +TARGET_SDKLIBS = kernel32.a gdi32.a + +TARGET_OBJECTS = \ + edittest.o \ + utils.o + +TARGET_CFLAGS = -Wall -Werror -D__USE_W32API + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/edit/utils.c b/rosapps/tests/edit/utils.c new file mode 100644 index 00000000000..f1eff54609f --- /dev/null +++ b/rosapps/tests/edit/utils.c @@ -0,0 +1,33 @@ +/* + * Edit Control Test for ReactOS, quick n' dirty. There you go + * This source code is in the PUBLIC DOMAIN and has NO WARRANTY. + * by Waldo Alvarez Caņizares , June 22, 2003. + */ + +#include + +static const char hexvals[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; +VOID htoa (unsigned int val, char *buf) +{ + int i; + buf += 7; + + for (i=0;i<8;i++) + { + *buf-- = hexvals[val & 0x0000000F]; + val = val >> 4; + } +} + + +VOID strcpy_(char *dst, const char *src) +{ + const char* p = src; + while ((*dst++ = *p++)) {} +} + +VOID strcpyw_(wchar_t* dst,wchar_t* src) +{ + const wchar_t* p = src; + while ((*dst++ = *p++)) {} +} diff --git a/rosapps/tests/edit/utils.h b/rosapps/tests/edit/utils.h new file mode 100644 index 00000000000..f6a12649c1e --- /dev/null +++ b/rosapps/tests/edit/utils.h @@ -0,0 +1,9 @@ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +VOID htoa (unsigned int, char *); +VOID strcpy_(char *, const char *); +VOID strcpyw_(wchar_t*,wchar_t*); +#ifdef __cplusplus + } +#endif diff --git a/rosapps/tests/enhmetafile/.cvsignore b/rosapps/tests/enhmetafile/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/enhmetafile/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/enhmetafile/enhmetafile.c b/rosapps/tests/enhmetafile/enhmetafile.c new file mode 100644 index 00000000000..cd90e6e42f7 --- /dev/null +++ b/rosapps/tests/enhmetafile/enhmetafile.c @@ -0,0 +1,123 @@ +#include +#include +#include + +//HFONT tf; +HENHMETAFILE EnhMetafile; +SIZE EnhMetafileSize; +LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM); + +int WINAPI +WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) +{ + WNDCLASS wc; + MSG msg; + HWND hWnd; + ENHMETAHEADER emh; + + EnhMetafile = GetEnhMetaFile("test.emf"); + if(!EnhMetafile) + { + fprintf(stderr, "GetEnhMetaFile failed (last error 0x%lX)\n", + GetLastError()); + return(1); + } + GetEnhMetaFileHeader(EnhMetafile, sizeof(ENHMETAHEADER), &emh); + EnhMetafileSize.cx = emh.rclBounds.right - emh.rclBounds.left; + EnhMetafileSize.cy = emh.rclBounds.bottom - emh.rclBounds.top; + + wc.lpszClassName = "EnhMetaFileClass"; + 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_BTNFACE + 1); + wc.lpszMenuName = NULL; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + if (RegisterClass(&wc) == 0) + { + DeleteEnhMetaFile(EnhMetafile); + fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n", + GetLastError()); + return(1); + } + + hWnd = CreateWindow("EnhMetaFileClass", + "Enhanced Metafile test", + WS_OVERLAPPEDWINDOW, + 0, + 0, + EnhMetafileSize.cx + (2 * GetSystemMetrics(SM_CXSIZEFRAME)) + 2, + EnhMetafileSize.cy + (2 * GetSystemMetrics(SM_CYSIZEFRAME)) + GetSystemMetrics(SM_CYCAPTION) + 2, + NULL, + NULL, + hInstance, + NULL); + if (hWnd == NULL) + { + DeleteEnhMetaFile(EnhMetafile); + 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"); + + ShowWindow(hWnd, nCmdShow); + + while(GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + DeleteEnhMetaFile(EnhMetafile); + + //DeleteObject(tf); + UnregisterClass("EnhMetaFileClass", hInstance); + + return msg.wParam; +} + +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + + case WM_PAINT: + { + PAINTSTRUCT ps; + RECT rc; + HDC hDC; + int bk; + + GetClientRect(hWnd, &rc); + hDC = BeginPaint(hWnd, &ps); + rc.left = (rc.right / 2) - (EnhMetafileSize.cx / 2); + rc.top = (rc.bottom / 2) - (EnhMetafileSize.cy / 2); + rc.right = rc.left + EnhMetafileSize.cx; + rc.bottom = rc.top + EnhMetafileSize.cy; + bk = SetBkMode(hDC, TRANSPARENT); + Rectangle(hDC, rc.left - 1, rc.top - 1, rc.right + 1, rc.bottom + 1); + SetBkMode(hDC, bk); + PlayEnhMetaFile(hDC, EnhMetafile, &rc); + EndPaint(hWnd, &ps); + break; + } + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hWnd, msg, wParam, lParam); + } + return 0; +} diff --git a/rosapps/tests/enhmetafile/makefile b/rosapps/tests/enhmetafile/makefile new file mode 100644 index 00000000000..5b152fb2309 --- /dev/null +++ b/rosapps/tests/enhmetafile/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:01 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = enhmetafile + +TARGET_SDKLIBS = kernel32.a gdi32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/enhmetafile/test.emf b/rosapps/tests/enhmetafile/test.emf new file mode 100644 index 00000000000..d056e2070df Binary files /dev/null and b/rosapps/tests/enhmetafile/test.emf differ diff --git a/rosapps/tests/enumfonts/.cvsignore b/rosapps/tests/enumfonts/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/enumfonts/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/enumfonts/enumfonts.cpp b/rosapps/tests/enumfonts/enumfonts.cpp new file mode 100644 index 00000000000..ae55f091651 --- /dev/null +++ b/rosapps/tests/enumfonts/enumfonts.cpp @@ -0,0 +1,271 @@ + +// ------------------------------------------------------------------ +// Windows 2000 Graphics API Black Book +// Chapter 4 - Listing 4.2 (Font Enumeration Demo) +// +// Created by Damon Chandler +// Updates can be downloaded at: +// +// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu +// if you have any questions about this code. +// ------------------------------------------------------------------ + + +//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +#include +#include + + +#ifndef SNDMSG +#define SNDMSG ::SendMessage +#endif /* ifndef SNDMSG */ + + +//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + +HWND hListBox = NULL; +const int ID_LISTBOX = 101; + +HINSTANCE hInst; +const char* WndClassName = "GMainWnd"; +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, + LPARAM lParam); + + +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR, + int nCmdShow) +{ + hInst = hInstance; + + WNDCLASS wc; + memset(&wc, 0, sizeof(WNDCLASS)); + + wc.style = CS_VREDRAW | CS_HREDRAW; + wc.lpszClassName = WndClassName; + wc.lpfnWndProc = MainWndProc; + wc.hInstance = hInstance; + wc.hCursor = NULL; //LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = reinterpret_cast( + COLOR_BTNFACE + 1 + ); + + if (RegisterClass(&wc)) + { + HWND hWnd = + CreateWindow( + WndClassName, TEXT("Font Enumeration Demo"), + WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | + WS_VISIBLE | WS_CLIPCHILDREN, + CW_USEDEFAULT, CW_USEDEFAULT, 295, 285, + NULL, NULL, hInst, NULL + ); + + if (hWnd) + { + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + MSG msg; + while (GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + } + return 0; +} +//------------------------------------------------------------------------- + + +int CALLBACK MyEnumFontFamExProc(ENUMLOGFONTEX *lpelfe, + NEWTEXTMETRICEX* lpntme, int FontType, LPARAM lParam) +{ + if (FontType == TRUETYPE_FONTTYPE) + { + // if the typeface name is not already in the list + LPARAM name = reinterpret_cast(lpelfe->elfFullName); + if (SNDMSG(hListBox, LB_FINDSTRINGEXACT, (ULONG)-1, name) == LB_ERR) + { + // add each font to the list box + int index = SNDMSG(hListBox, LB_ADDSTRING, 0, name); + + // fix the size of the font + lpelfe->elfLogFont.lfHeight = -20; + lpelfe->elfLogFont.lfWidth = 0; + + // create a new font and store its handle + // as the data of the newly added item + HFONT hFont = CreateFontIndirect(&lpelfe->elfLogFont); + SNDMSG(hListBox, LB_SETITEMDATA, index, + reinterpret_cast(hFont)); + } + } + return TRUE; +} +//------------------------------------------------------------------------- + + +void AddScreenFonts() +{ + // grab a handle to the screen's DC + HDC hScreenDC = GetDC(NULL); + try + { + // + // NOTE: Windows 95, 98 and Me requires that the lpLogfont + // (second) parameter of the EnumFontFamiliesEx function is + // non-NULL. This parameter can be NULL on Windows NT/2000. + // + LOGFONT lf = {0}; + lf.lfCharSet = DEFAULT_CHARSET; + + // enumerate the current screen fonts + EnumFontFamiliesEx( + hScreenDC, &lf, + (FONTENUMPROC)MyEnumFontFamExProc, + 0, 0 + ); + } + catch (...) + { + // release the screen's DC + ReleaseDC(NULL, hScreenDC); + } + // release the screen's DC + ReleaseDC(NULL, hScreenDC); +} +//------------------------------------------------------------------------- + + +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, + LPARAM lParam) +{ + switch (msg) + { + case WM_CREATE: + { + hListBox = + CreateWindowEx( + WS_EX_CLIENTEDGE, TEXT("LISTBOX"), TEXT(""), + WS_CHILD | WS_VISIBLE | LBS_STANDARD | + LBS_HASSTRINGS | LBS_OWNERDRAWFIXED, + 20, 10, 250, 250, + hWnd, reinterpret_cast(ID_LISTBOX), + hInst, NULL + ); + if (hListBox) + { + AddScreenFonts(); + } + } + case WM_MEASUREITEM: + { + // grab a pointer to the MEASUREITEMSTRUCT structure + LPMEASUREITEMSTRUCT lpmis = + reinterpret_cast(lParam); + + // test the identifier of the control that + // the message is meant for + if ((int)lpmis->CtlID == ID_LISTBOX) + { + // adjust the height + lpmis->itemHeight = 25; + + return TRUE; + } + break; + } + case WM_DRAWITEM: + { + // grab a pointer to the DRAWITEMSTRUCT structure + LPDRAWITEMSTRUCT lpdis = + reinterpret_cast(lParam); + + // test the identifier of the control that + // the message is meant for + if ((int)lpdis->CtlID == ID_LISTBOX) + { + COLORREF OldColor = GetTextColor(lpdis->hDC); + int stock = WHITE_BRUSH; + + // if the item is currently selected + if (lpdis->itemState & ODS_SELECTED) + { + // set the text color to white and + // the background color to black + COLORREF clrWhite = PALETTERGB(255, 255, 255); + OldColor = SetTextColor(lpdis->hDC, clrWhite); + stock = BLACK_BRUSH; + } + FillRect( + lpdis->hDC, &lpdis->rcItem, + static_cast(GetStockObject(stock)) + ); + + if ((int)lpdis->itemID != -1) + { + // extract the item's text + char text[MAX_PATH]; + SNDMSG(hListBox, LB_GETTEXT, lpdis->itemID, + reinterpret_cast(text)); + + // extract the corresponding font handle + DWORD value = + SNDMSG(hListBox, LB_GETITEMDATA, lpdis->itemID, 0); + HFONT hFont = reinterpret_cast(value); + + // select the corresponding font + // into the device context + HFONT HOldFont = static_cast( + SelectObject(lpdis->hDC, hFont) + ); + + // render the text transparently + SetBkMode(lpdis->hDC, TRANSPARENT); + + // render the text + RECT RText = lpdis->rcItem; + InflateRect(&RText, -2, -2); + DrawText(lpdis->hDC, text, strlen(text), &RText, + DT_LEFT | DT_VCENTER | DT_SINGLELINE); + + // restore the previous font + SelectObject(lpdis->hDC, HOldFont); + } + + // render the focus rectangle + if (lpdis->itemState & ODS_FOCUS) + { + DrawFocusRect(lpdis->hDC, &lpdis->rcItem); + } + + // restore the previous color/mode + SetTextColor(lpdis->hDC, OldColor); + SetBkMode(lpdis->hDC, OPAQUE); + + return TRUE; + } + break; + } + case WM_DESTROY: + { + // delete each created font object + int count = SNDMSG(hListBox, LB_GETCOUNT, 0, 0); + for (int index = 0; index < count; ++index) + { + DWORD value = SNDMSG(hListBox, LB_GETITEMDATA, index, 0); + DeleteObject(reinterpret_cast(value)); + } + + PostQuitMessage(0); + break; + } + } + return DefWindowProc(hWnd, msg, wParam, lParam); +} +//------------------------------------------------------------------------- + + + diff --git a/rosapps/tests/enumfonts/makefile b/rosapps/tests/enumfonts/makefile new file mode 100644 index 00000000000..2d8115c83e3 --- /dev/null +++ b/rosapps/tests/enumfonts/makefile @@ -0,0 +1,24 @@ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = enumfonts + +TARGET_SDKLIBS = kernel32.a gdi32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_GCCLIBS = stdc++ + +TARGET_CPPFLAGS = -Wall -Werror -D__USE_W32API -DWIN32 -D_WIN32_IE=0x0600 -D_WIN32_WINNT=0x0501 -fexceptions -Wall -I. + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/enumwnd/.cvsignore b/rosapps/tests/enumwnd/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/enumwnd/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/enumwnd/enumwnd.c b/rosapps/tests/enumwnd/enumwnd.c new file mode 100644 index 00000000000..c5b60ef6a03 --- /dev/null +++ b/rosapps/tests/enumwnd/enumwnd.c @@ -0,0 +1,187 @@ +/* + * enumwnd.c + * + * application to test the various Window Enumeration functions + */ + +//#define WIN32_LEAN_AND_MEAN +#include +#include +#include + +HBRUSH hbrBackground; +HFONT tf; +int test = 0; +const TCHAR* APP_NAME = "EnumWnd Test"; +const TCHAR* CLASS_NAME = "EnumWndTestClass"; + +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 = CLASS_NAME; + 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) + { + _ftprintf ( stderr, _T("RegisterClass failed (last error 0x%lX)\n"), + GetLastError()); + return(1); + } + + hWnd = CreateWindow(CLASS_NAME, + APP_NAME, + WS_OVERLAPPEDWINDOW, + 0, + 0, + CW_USEDEFAULT, + CW_USEDEFAULT, + NULL, + NULL, + hInstance, + NULL); + if (hWnd == NULL) + { + _ftprintf ( stderr, _T("CreateWindow failed (last error 0x%lX)\n"), + GetLastError()); + return(1); + } + + tf = CreateFont (14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE, + ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, _T("Timmons")); + + hbrBackground = CreateSolidBrush ( RGB(192,192,192) ); + + ShowWindow ( hWnd, nCmdShow ); + + while(GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + DeleteObject(hbrBackground); + + DeleteObject(tf); + + return msg.wParam; +} + +void MyTextOut ( HDC hdc, int x, int y, const TCHAR* text ) +{ + TextOut ( hdc, x, y, text, _tcslen(text) ); +} + +typedef struct _EnumData +{ + HDC hdc; + int x; + int y; +} EnumData; + +BOOL CALLBACK MyWindowEnumProc ( HWND hwnd, LPARAM lParam ) +{ + TCHAR wndcaption[1024], buf[1024]; + EnumData* ped = (EnumData*)lParam; + GetWindowText ( hwnd, wndcaption, sizeof(wndcaption)/sizeof(*wndcaption) ); + _sntprintf ( buf, sizeof(buf)/sizeof(*buf), _T("%x - %s"), hwnd, wndcaption ); + MyTextOut ( ped->hdc, ped->x, ped->y, buf ); + ped->y += 13; + return TRUE; +} + +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PAINTSTRUCT ps; + HDC hDC; + RECT rect; + TCHAR buf[100]; + EnumData ed; + + switch(msg) + { + case WM_PAINT: + hDC = BeginPaint(hWnd, &ps); + SelectObject(hDC, tf); + + GetClientRect ( hWnd, &rect ); + FillRect ( hDC, &rect, hbrBackground ); + + MyTextOut ( hDC, 10, 10, "EnumWnd Test" ); + + _sntprintf ( buf, sizeof(buf)/sizeof(*buf), _T("My HWND: %x"), hWnd ); + MyTextOut ( hDC, 10, 30, buf ); + + ed.hdc = hDC; + ed.x = 10; + ed.y = 70; + + switch ( test ) + { + case 1: + MyTextOut ( hDC, 10, 50, _T("Test #1: EnumWindows()") ); + EnumWindows ( MyWindowEnumProc, (LPARAM)&ed ); + break; + case 2: + MyTextOut ( hDC, 10, 50, _T("Test #2: EnumChildWindows()") ); + EnumChildWindows ( hWnd, MyWindowEnumProc, (LPARAM)&ed ); + break; + case 3: + MyTextOut ( hDC, 10, 50, _T("Test #3: EnumDesktopWindows") ); + EnumDesktopWindows ( NULL, MyWindowEnumProc, (LPARAM)&ed ); + break; + case 4: + MyTextOut ( hDC, 10, 50, _T("Test #4: EnumThreadWindows") ); + EnumThreadWindows ( GetCurrentThreadId(), MyWindowEnumProc, (LPARAM)&ed ); + break; + default: + MyTextOut ( hDC, 10, 50, _T("Press any of the number keys from 1 to 4 to run a test") ); + MyTextOut ( hDC, 10, 70, _T("Press the left and right mouse buttons to cycle through the tests") ); + break; + } + + EndPaint(hWnd, &ps); + break; + + case WM_CHAR: + test = (TCHAR)wParam - '1' + 1; + RedrawWindow ( hWnd, NULL, NULL, RDW_INVALIDATE ); + break; + + case WM_LBUTTONDOWN: + if ( ++test > 4 ) + test = 1; + RedrawWindow ( hWnd, NULL, NULL, RDW_INVALIDATE ); + break; + + case WM_RBUTTONDOWN: + if ( !--test ) + test = 4; + RedrawWindow ( hWnd, NULL, NULL, RDW_INVALIDATE ); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hWnd, msg, wParam, lParam); + } + return 0; +} diff --git a/rosapps/tests/enumwnd/enumwnd.dsp b/rosapps/tests/enumwnd/enumwnd.dsp new file mode 100644 index 00000000000..b18de899a0c --- /dev/null +++ b/rosapps/tests/enumwnd/enumwnd.dsp @@ -0,0 +1,90 @@ +# Microsoft Developer Studio Project File - Name="enumwnd" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=enumwnd - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "enumwnd.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "enumwnd.mak" CFG="enumwnd - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "enumwnd - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "enumwnd - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "enumwnd - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "enumwnd - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /debug /machine:I386 /pdbtype:sept +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "enumwnd - Win32 Release" +# Name "enumwnd - Win32 Debug" +# Begin Source File + +SOURCE=.\enumwnd.c +# End Source File +# End Target +# End Project diff --git a/rosapps/tests/enumwnd/makefile b/rosapps/tests/enumwnd/makefile new file mode 100644 index 00000000000..549eeea4bbf --- /dev/null +++ b/rosapps/tests/enumwnd/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:01 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = enumwnd + +TARGET_SDKLIBS = kernel32.a gdi32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/enumws/.cvsignore b/rosapps/tests/enumws/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/enumws/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/enumws/enumws.c b/rosapps/tests/enumws/enumws.c new file mode 100644 index 00000000000..93d5a216bb2 --- /dev/null +++ b/rosapps/tests/enumws/enumws.c @@ -0,0 +1,35 @@ +#include +#include + +BOOL CALLBACK +EnumDesktopProc(LPWSTR lpszWindowStation, LPARAM lParam) +{ + printf("\t%S\n", lpszWindowStation); + + return TRUE; +} + +BOOL CALLBACK +EnumWindowStationProc(LPWSTR lpszWindowStation, LPARAM lParam) +{ + HWINSTA hWinSta; + + printf("%S\n", lpszWindowStation); + hWinSta = OpenWindowStationW(lpszWindowStation, FALSE, + WINSTA_ENUMDESKTOPS); + if (hWinSta == NULL) + { + printf("\tCan't open window station.\n"); + return TRUE; + } + EnumDesktopsW(hWinSta, EnumDesktopProc, 0xdede); + + return TRUE; +} + +int main() +{ + EnumWindowStationsW(EnumWindowStationProc, 0xbadbed); + + return 0; +} diff --git a/rosapps/tests/enumws/makefile b/rosapps/tests/enumws/makefile new file mode 100644 index 00000000000..782f6639808 --- /dev/null +++ b/rosapps/tests/enumws/makefile @@ -0,0 +1,21 @@ +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = enumws + +TARGET_SDKLIBS = user32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/event/.cvsignore b/rosapps/tests/event/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/event/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/event/event.c b/rosapps/tests/event/event.c new file mode 100644 index 00000000000..9942bea0745 --- /dev/null +++ b/rosapps/tests/event/event.c @@ -0,0 +1,33 @@ +#include +#include + +HANDLE events[2]; + +DWORD WINAPI thread( LPVOID crap ) +{ + SetEvent( events[0] ); + if( crap ) + SetEvent( events[1] ); + return 1; +} + +int main( void ) +{ + DWORD id, Status; + printf( "Creating events\n" ); + events[0] = CreateEvent( 0, TRUE, FALSE, 0 ); + events[1] = CreateEvent( 0, TRUE, FALSE, 0 ); + printf( "Created events\n" ); + CreateThread( 0, 0, thread, 0, 0, &id ); + printf( "WaitForSingleObject %s\n", ( WaitForSingleObject( events[0], INFINITE ) == WAIT_OBJECT_0 ? "worked" : "failed" ) ); + ResetEvent( events[0] ); + CreateThread( 0, 0, thread, 0, 0, &id ); + printf( "WaitForMultipleObjects with waitall = FALSE %s\n", ( WaitForMultipleObjects( 2, events, FALSE, INFINITE ) == WAIT_OBJECT_0 ? "worked" : "failed" ) ); + ResetEvent( events[0] ); + CreateThread( 0, 0, thread, (void *)1, 0, &id ); + Status = WaitForMultipleObjects( 2, events, TRUE, INFINITE ); + printf( "WaitForMultipleObjects with waitall = TRUE %s\n", ( Status == WAIT_OBJECT_0 || Status == WAIT_OBJECT_0 + 1 ? "worked" : "failed" ) ); + ResetEvent( events[0] ); + printf( "WaitForSingleObject with timeout %s\n", ( WaitForSingleObject( events[0], 100 ) == WAIT_TIMEOUT ? "worked" : "failed" ) ); + return 0; +} diff --git a/rosapps/tests/event/makefile b/rosapps/tests/event/makefile new file mode 100644 index 00000000000..b587ac1705c --- /dev/null +++ b/rosapps/tests/event/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:01 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = event + +TARGET_SDKLIBS = kernel32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/eventpair/.cvsignore b/rosapps/tests/eventpair/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/eventpair/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/eventpair/eventpair.c b/rosapps/tests/eventpair/eventpair.c new file mode 100644 index 00000000000..f20a725a7f9 --- /dev/null +++ b/rosapps/tests/eventpair/eventpair.c @@ -0,0 +1,65 @@ +/* + * Author: Skywing (skywing@valhallalegends.com) + * Date: 09/09/2003 + * Purpose: Test Thread-EventPair functionality. + */ + +#include +#include +#include + +#ifndef NTAPI +#define NTAPI WINAPI +#endif + +HANDLE MakeEventPair() +{ + NTSTATUS Status; + HANDLE EventPair; + OBJECT_ATTRIBUTES Attributes; + + InitializeObjectAttributes(&Attributes, NULL, 0, NULL, NULL); + Status = NtCreateEventPair(&EventPair, STANDARD_RIGHTS_ALL, &Attributes); + printf("Status %08lx creating eventpair\n", Status); + return EventPair; +} + +DWORD __stdcall threadfunc(void* eventpair) +{ + printf("Thread: Set eventpair status %08lx\n", NtSetInformationThread(NtCurrentThread(), ThreadEventPair, &eventpair, sizeof(HANDLE))); + Sleep(2500); + + printf("Thread: Setting low and waiting high...\n"); + printf("Thread: status = %08lx\n", NtSetLowWaitHighThread()); + printf("Thread: status = %08lx\n", NtSetHighWaitLowThread()); + printf("Thread: Terminating...\n"); + return 0; +} + +int main(int ac, char **av) +{ + DWORD id; + HANDLE EventPair, Thread; + + printf("Main: NtSetLowWaitHighThread is at %08lx\n", NtSetLowWaitHighThread()); + + EventPair = MakeEventPair(); + + if(!EventPair) { + printf("Main: Could not create event pair.\n"); + return 0; + } + + printf("Main: EventPair = %08lx\n", (DWORD)EventPair); + Thread = CreateThread(0, 0, threadfunc, EventPair, 0, &id); + printf("Main: ThreadId for new thread is %08lx\n", id); + printf("Main: Setting high and waiting low\n"); + printf("Main: status = %08lx\n", NtSetHighWaitLowEventPair(EventPair)); + Sleep(2500); + printf("Main: status = %08lx\n", NtSetLowWaitHighEventPair(EventPair)); + NtClose(EventPair); + /* WaitForSingleObject(Thread, INFINITE); FIXME: Waiting on thread handle causes double spinlock acquisition (and subsequent crash) in PsUnblockThread - ntoskrnl/ps/thread.c */ + NtClose(Thread); + printf("Main: Terminating...\n"); + return 0; +} diff --git a/rosapps/tests/eventpair/makefile b/rosapps/tests/eventpair/makefile new file mode 100644 index 00000000000..8962a901c1d --- /dev/null +++ b/rosapps/tests/eventpair/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:01 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = eventpair + +TARGET_SDKLIBS = ntdll.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/fiber/.cvsignore b/rosapps/tests/fiber/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/fiber/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/fiber/Makefile b/rosapps/tests/fiber/Makefile new file mode 100644 index 00000000000..18482b5e31e --- /dev/null +++ b/rosapps/tests/fiber/Makefile @@ -0,0 +1,21 @@ +# $Id: Makefile,v 1.1 2004/10/21 05:12:02 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = fiber + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror -D__USE_W32API + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/fiber/fiber.c b/rosapps/tests/fiber/fiber.c new file mode 100644 index 00000000000..2c0aefc1772 --- /dev/null +++ b/rosapps/tests/fiber/fiber.c @@ -0,0 +1,446 @@ +/* $Id: fiber.c,v 1.1 2004/10/21 05:12:02 sedwards Exp $ +*/ + +#include +#include +#include +#include +#include + +#include +#include + +#ifndef InitializeListHead +#define InitializeListHead(PLH__) ((PLH__)->Flink = (PLH__)->Blink = (PLH__)) +#endif + +#ifndef IsListEmpty +#define IsListEmpty(PLH__) ((PLH__)->Flink == (PVOID)(PLH__)) +#endif + +#ifndef RemoveEntryList + +#define RemoveEntryList(PLE__) \ +{ \ + PLIST_ENTRY pleBack__ = (PLIST_ENTRY)((PLE__)->Blink); \ + PLIST_ENTRY pleForward__ = (PLIST_ENTRY)((PLE__)->Flink); \ + \ + pleBack__->Flink = pleForward__; \ + pleForward__->Blink = pleBack__; \ +} + +#endif + +#ifndef InsertTailList + +#define InsertTailList(PLH__, PLE__) \ +{ \ + PLIST_ENTRY pleListHead__ = (PLH__); \ + PLIST_ENTRY pleBlink__ = (PLIST_ENTRY)((PLH__)->Blink); \ + \ + (PLE__)->Flink = pleListHead__; \ + (PLE__)->Blink = pleBlink__; \ + pleBlink__->Flink = (PLE__); \ + pleListHead__->Blink = (PLE__); \ +} + +#endif + +#ifndef RemoveHeadList + +#define RemoveHeadList(PLH__) \ + (PLIST_ENTRY)((PLH__)->Flink); \ + RemoveEntryList((PLIST_ENTRY)((PLH__)->Flink)); + +#endif + +#define FIBERTEST_COUNT 500 + +struct FiberData +{ + unsigned nMagic; + unsigned nId; + unsigned nPrio; + unsigned nRealPrio; + PVOID pFiber; + LIST_ENTRY leQueue; + int nQuantumQueued; + int nBoost; + struct FiberData * pfdPrev; + int bExitPrev; +}; + +static LIST_ENTRY a_leQueues[32]; +static unsigned nQuantum = 0; +static struct FiberData * pfdLastStarveScan = NULL; + +void Fbt_Create(int); +void Fbt_Exit(void); +void Fbt_Yield(void); + +struct FiberData * Fbt_GetCurrent(void); +unsigned Fbt_GetCurrentId(void); +VOID CALLBACK Fbt_Startup(PVOID); +void Fbt_Dispatch(struct FiberData *, int); +void Fbt_AfterSwitch(struct FiberData *); + +void DoStuff(void); + +struct FiberData * Fbt_GetCurrent(VOID) +{ + return GetFiberData(); +} + +unsigned Fbt_GetCurrentId(VOID) +{ + return Fbt_GetCurrent()->nId; +} + +void Fbt_Yield(VOID) +{ + struct FiberData * pfdCur; + + pfdCur = Fbt_GetCurrent(); + + if(pfdCur->nBoost) + { + -- pfdCur->nBoost; + + if(!pfdCur->nBoost) + pfdCur->nPrio = pfdCur->nRealPrio; + } + else if((rand() % 100) > 50 - (45 * pfdCur->nPrio) / 32) + Fbt_Dispatch(pfdCur, 0); +} + +void Fbt_AfterSwitch(struct FiberData * pfdCur) +{ + struct FiberData * pfdPrev; + + pfdPrev = pfdCur->pfdPrev; + + /* The previous fiber left some homework for us */ + if(pfdPrev) + { + /* Kill the predecessor */ + if(pfdCur->bExitPrev) + { + if(pfdLastStarveScan == pfdPrev) + pfdLastStarveScan = 0; + + DeleteFiber(pfdPrev->pFiber); + free(pfdPrev); + } + /* Enqueue the previous fiber in the correct ready queue */ + else + { + /* Remember the quantum in which the previous fiber was queued */ + pfdPrev->nQuantumQueued = nQuantum; + + /* Disable the anti-starvation boost */ + if(pfdPrev->nBoost) + { + pfdPrev->nBoost = 0; + pfdPrev->nPrio = pfdPrev->nRealPrio; + } + + /* Enqueue the previous fiber */ + InsertTailList + ( + &a_leQueues[pfdPrev->nPrio], + &pfdPrev->leQueue + ); + } + } +} + +VOID CALLBACK Fbt_Startup(PVOID pParam) +{ + assert(pParam == GetFiberData()); + Fbt_AfterSwitch(pParam); + DoStuff(); + Fbt_Exit(); +} + +void Fbt_Dispatch(struct FiberData * pfdCur, int bExit) +{ + UCHAR i; + UCHAR n; + struct FiberData * pfdNext; + + assert(pfdCur == GetFiberData()); + + ++ nQuantum; + + /* Every ten quantums check for starving threads */ + /* FIXME: this implementation of starvation prevention isn't that great */ + if(nQuantum % 10 == 0) + { + int j; + int k; + int b; + int bResume; + PLIST_ENTRY ple = NULL; + + bResume = 0; + i = 0; + + /* Pick up from where we left last time */ + if(pfdLastStarveScan) + { + unsigned nPrio; + + nPrio = pfdLastStarveScan->nPrio; + + /* The last fiber we scanned for starvation isn't queued anymore */ + if(IsListEmpty(&pfdLastStarveScan->leQueue)) + /* Scan the ready queue for its priority */ + i = nPrio; + /* Last fiber for its priority level */ + else if(pfdLastStarveScan->leQueue.Flink == &a_leQueues[nPrio]) + /* Scan the ready queue for the next priority level */ + i = nPrio + 1; + /* Scan the next fiber in the ready queue */ + else + { + i = nPrio; + ple = pfdLastStarveScan->leQueue.Flink; + bResume = 1; + } + + /* Priority levels 15-31 are never checked for starvation */ + if(i >= 15) + { + if(bResume) + bResume = 0; + + i = 0; + } + } + + /* + Scan at most 16 threads, in the priority range 0-14, applying in total at + most 10 boosts. This loop scales O(1) + */ + for(j = 0, k = 0, b = 0; j < 16 && k < 15 && b < 10; ++ j) + { + unsigned nDiff; + + /* No previous state to resume from */ + if(!bResume) + { + int nQueue; + + /* Get the first element in the current queue */ + nQueue = (k + i) % 15; + + if(IsListEmpty(&a_leQueues[nQueue])) + { + ++ k; + continue; + } + + ple = (PLIST_ENTRY)a_leQueues[nQueue].Flink; + } + else + bResume = 0; + + /* Get the current fiber */ + pfdLastStarveScan = CONTAINING_RECORD(ple, struct FiberData, leQueue); + assert(pfdLastStarveScan->nMagic == 0x12345678); + assert(pfdLastStarveScan != pfdCur); + + /* Calculate the number of quantums the fiber has been in the queue */ + if(nQuantum > pfdLastStarveScan->nQuantumQueued) + nDiff = nQuantum - pfdLastStarveScan->nQuantumQueued; + else + nDiff = UINT_MAX - pfdLastStarveScan->nQuantumQueued + nQuantum; + + /* The fiber has been ready for more than 30 quantums: it's starving */ + if(nDiff > 30) + { + /* Plus one boost applied */ + ++ b; + + /* Apply the boost */ + pfdLastStarveScan->nBoost = 1; + pfdLastStarveScan->nRealPrio = pfdLastStarveScan->nPrio; + pfdLastStarveScan->nPrio = 15; + + /* Re-enqueue the fiber in the correct priority queue */ + RemoveEntryList(&pfdLastStarveScan->leQueue); + InsertTailList(&a_leQueues[15], &pfdLastStarveScan->leQueue); + } + } + } + + pfdNext = NULL; + + /* This fiber is going to die: scan all ready queues */ + if(bExit) + n = 1; + /* + Scan only ready queues for priorities greater than or equal to the priority of + the current thread (round-robin) + */ + else + n = pfdCur->nPrio + 1; + + /* This loop scales O(1) */ + for(i = 32; i >= n; -- i) + { + PLIST_ENTRY pleNext; + + /* No fiber ready for this priority level */ + if(IsListEmpty(&a_leQueues[i - 1])) + continue; + + /* Get the next ready fiber */ + pleNext = RemoveHeadList(&a_leQueues[i - 1]); + InitializeListHead(pleNext); + pfdNext = CONTAINING_RECORD(pleNext, struct FiberData, leQueue); + assert(pfdNext->pFiber != GetCurrentFiber()); + assert(pfdNext->nMagic == 0x12345678); + break; + } + + /* Next fiber chosen */ + if(pfdNext) + { + /* Give some homework to the next fiber */ + pfdNext->pfdPrev = pfdCur; + pfdNext->bExitPrev = bExit; + + /* Switch to the next fiber */ + SwitchToFiber(pfdNext->pFiber); + + /* Complete the switch back to this fiber */ + Fbt_AfterSwitch(pfdCur); + } + /* No next fiber, and current fiber exiting */ + else if(bExit) + { + PVOID pCurFiber; + + /* Delete the current fiber. This kills the thread and stops the simulation */ + if(pfdLastStarveScan == pfdCur) + pfdLastStarveScan = NULL; + + pCurFiber = pfdCur->pFiber; + free(pfdCur); + DeleteFiber(pCurFiber); + } + /* No next fiber: continue running the current one */ +} + +void Fbt_Exit(VOID) +{ + Fbt_Dispatch(GetFiberData(), 1); +} + +void Fbt_CreateFiber(int bInitial) +{ + PVOID pFiber; + struct FiberData * pData; + static int s_bFiberPrioSeeded = 0; + static LONG s_nFiberIdSeed = 0; + + pData = malloc(sizeof(struct FiberData)); + + assert(pData); + + if(bInitial) + pFiber = ConvertThreadToFiber(pData); + else + pFiber = CreateFiber(0, Fbt_Startup, pData); + + if(!s_bFiberPrioSeeded) + { + unsigned nFiberPrioSeed; + time_t tCurTime; + + tCurTime = time(NULL); + memcpy(&nFiberPrioSeed, &tCurTime, sizeof(nFiberPrioSeed)); + srand(nFiberPrioSeed); + s_bFiberPrioSeeded = 1; + } + + assert(pFiber); + + pData->nMagic = 0x12345678; + pData->nId = InterlockedIncrement(&s_nFiberIdSeed); + pData->nPrio = rand() % 32; + pData->pFiber = pFiber; + pData->nQuantumQueued = 0; + pData->nBoost = 0; + pData->nRealPrio = pData->nPrio; + pData->pfdPrev = NULL; + pData->bExitPrev = 0; + + if(bInitial) + { + InitializeListHead(&pData->leQueue); + } + else + { + InsertTailList + ( + &a_leQueues[pData->nPrio], + &pData->leQueue + ); + } +} + +void DoStuff(void) +{ + unsigned i; + unsigned n; + unsigned nId; + + n = rand() % 1000; + nId = Fbt_GetCurrentId(); + + _ftprintf(stderr, _T("[%u] BEGIN\n"), nId); + + for(i = 0; i < n; ++ i) + { + unsigned j; + unsigned m; + + _ftprintf(stderr, _T("[%u] [%u/%u]\n"), nId, i + 1, n); + + m = rand() % 1000; + + for(j = 0; j < m; ++ j) + Sleep(0); + + Fbt_Yield(); + } + + _ftprintf(stderr, _T("[%u] END\n"), nId); +} + +int _tmain(int argc, _TCHAR const * const * argv) +{ + unsigned i; + unsigned nFibers; + + if(argc > 1) + nFibers = _tcstoul(argv[1], NULL, 0); + else + nFibers = FIBERTEST_COUNT; + + for(i = 0; i < 32; ++ i) + { + InitializeListHead(&a_leQueues[i]); + } + + for(i = 0; i < nFibers; ++ i) + Fbt_CreateFiber(i == 0); + + Fbt_Startup(GetFiberData()); + + return 0; +} + +/* EOF */ diff --git a/rosapps/tests/global_mem/.cvsignore b/rosapps/tests/global_mem/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/global_mem/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/global_mem/Makefile b/rosapps/tests/global_mem/Makefile new file mode 100644 index 00000000000..09e3d081cbc --- /dev/null +++ b/rosapps/tests/global_mem/Makefile @@ -0,0 +1,21 @@ +# $Id: Makefile,v 1.1 2004/10/21 05:12:02 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = global_mem + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/global_mem/global_mem.c b/rosapps/tests/global_mem/global_mem.c new file mode 100644 index 00000000000..b9cb7149871 --- /dev/null +++ b/rosapps/tests/global_mem/global_mem.c @@ -0,0 +1,1062 @@ +/* File: global_mem.c +** +** This program is a test application used for testing correctness of the +** GlobalXXX memory API implementation. +** +** Programmer: Mark Tempel +*/ +#include +#include +#include + +/* +** All output is line wrapped to fit a 80 column screen. +** these defines control that formatting. To shrink the +** screen columns, just change the DISPLAY_COMUMNS macro. +*/ +#define DISPLAY_COLUMNS 78 +#define LINE_BUFFER_SIZE DISPLAY_COLUMNS + 2 + +/* +** This define controls the size of a memory allocation request. +** For this test suite to really be comprehensive, we should +** probably be testing many different block sizes. +*/ +#define MEM_BLOCK_SIZE 0x80000 + +/* +** This enumeration is really the return value for the program. +** All test return a TestStatus and test statuses can be combined +** with the relation TEST_CombineStatus. +*/ +typedef enum TestStatus +{ + FAILED = 0, + PASSED = 1, + SKIPPED = -1 +} TEST_STATUS; + +/*--------------------------------------------------------------------------- +** This is a relation used to combine two test statuses. +** The combine rules are as follows: +** FAIL & Anything == FAIL +** SKIPPED & Anything == Anything +** +*/ +TEST_STATUS TEST_CombineStatus(TEST_STATUS a, TEST_STATUS b) +{ + TEST_STATUS result = a; + + switch (a) + { + case PASSED: result = (PASSED == b || SKIPPED == b) ? (PASSED) : (FAILED); break; + case FAILED: result = FAILED; break; + case SKIPPED: result = b; break; + } + + return result; +} + +/*--------------------------------------------------------------------------- +** This outputs the banner border lines. +*/ +void OUTPUT_BannerLine() +{ + int c = 0; + printf("+"); + for (c = 1; c < DISPLAY_COLUMNS; c++) + { + printf("-"); + } + printf("\n"); +} + + +/*--------------------------------------------------------------------------- +** This method prints a line that has a | on the left, and is line wrapped +** to be no more that DISPLAY_COLUMNS +2 wide. +*/ +void OUTPUT_Line(const char *szLine) +{ + int spaceIndex = 0; + char output[LINE_BUFFER_SIZE]; + + memset(output, 0, DISPLAY_COLUMNS + 2); + + /*If this line is longer than DISPLAY_COLUMNS, + * break it at the first space. + */ + if (DISPLAY_COLUMNS - 2 < strlen(szLine)) + { + for (spaceIndex = DISPLAY_COLUMNS / 2; spaceIndex < DISPLAY_COLUMNS - 2; spaceIndex++) + { + if (' ' == szLine[spaceIndex]) + { + break; + } + } + + memcpy(output + 2, szLine, spaceIndex + 1); + output[0] = '|'; + output[1] = ' '; + output[strlen(output)] = '\n'; + printf(output); + + OUTPUT_Line(szLine + spaceIndex + 1); + } + else + { + sprintf(output,"| %s\n", szLine); + printf(output); + } + +} + +/*--------------------------------------------------------------------------- +** +*/ +void OUTPUT_Banner(const char *szBanner) +{ + OUTPUT_BannerLine(); + OUTPUT_Line(szBanner); + OUTPUT_BannerLine(); +} + +/*--------------------------------------------------------------------------- +** +*/ +void OUTPUT_Result(TEST_STATUS status) +{ + switch (status) + { + case PASSED: OUTPUT_Line("==> PASSED"); break; + case FAILED: OUTPUT_Line("*** FAILED"); break; + case SKIPPED: OUTPUT_Line("==> SKIPPED"); break; + } + OUTPUT_Line(""); +} + +/*--------------------------------------------------------------------------- +** +*/ +void OUTPUT_HexDword(DWORD dw) +{ + char buffer[32]; + sprintf(buffer, "0x%lX",dw); + OUTPUT_Line(buffer); +} + +/*--------------------------------------------------------------------------- +** +*/ +void OutputAllocFlags(UINT pFlags) +{ + if (pFlags & GMEM_MOVEABLE) + { + OUTPUT_Line("Movable Memory"); + } + else + { + OUTPUT_Line("Fixed Memory"); + } + + if (pFlags & GMEM_ZEROINIT) + { + OUTPUT_Line("Zero Initialized Memory"); + } +} + +/*--------------------------------------------------------------------------- +** +*/ +void OutputErrorCode() +{ + char buffer[256]; + + sprintf(buffer,"GetLastError() returned %lu", GetLastError()); + + OUTPUT_Line(buffer); +} +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TEST_MemoryWrite(LPVOID mem, DWORD cbSize) +{ + TEST_STATUS result = FAILED; + + if (0 == IsBadWritePtr(mem, cbSize)) + { + result = PASSED; + } + return result; +} + +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TEST_MemoryRead(LPVOID mem, DWORD cbSize) +{ + TEST_STATUS result = FAILED; + + if (0 == IsBadReadPtr(mem, cbSize)) + { + result = PASSED; + } + return result; +} + +/*--------------------------------------------------------------------------- +** This method tests to see if a block of global memory is movable +** by seeing if the value returned from GlobalLock is different from +** the passed in value. +*/ +int IsMovable(HGLOBAL hMem) +{ + LPVOID pMem = 0; + int rc = 0; + + pMem = GlobalLock(hMem); + if (pMem != hMem) + { + rc = 1; + } + GlobalUnlock(hMem); + + return rc; +} + +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalAllocNFree(UINT allocFlags) +{ + TEST_STATUS status = SKIPPED; + HGLOBAL hTest = 0; + OUTPUT_Banner("Testing the GlobalAlloc and GlobalFree calls"); + OUTPUT_Line("Allocate a buffer"); + + OutputAllocFlags(allocFlags); + + status = FAILED; + hTest = GlobalAlloc(allocFlags, MEM_BLOCK_SIZE); + if (0 != hTest) + { + if (0 == GlobalFree(hTest)); + { + status = PASSED; + } + } + + OUTPUT_Line("Result for this run:"); + OUTPUT_Result(status); + OUTPUT_Line(""); + + return status; +} + +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalLockNUnlock(UINT allocFlags) +{ + HGLOBAL hMem = 0; + LPVOID pMem = 0; + TEST_STATUS subtest = SKIPPED; + TEST_STATUS result = FAILED; + + OUTPUT_Banner("Testing the GlobalLock/Unlock functions."); + OutputAllocFlags(allocFlags); + OUTPUT_Line(""); + + hMem = GlobalAlloc(allocFlags, MEM_BLOCK_SIZE); + if (0 != hMem) + { + OUTPUT_Line("Allocated a memory block"); + + OUTPUT_Line("Testing Lock"); + pMem = GlobalLock(hMem); + if (0 != pMem) + { + OUTPUT_Result(PASSED); + + OUTPUT_Line("Testing memory for read."); + subtest = TEST_MemoryRead(pMem, MEM_BLOCK_SIZE); + OUTPUT_Result(subtest); + result = TEST_CombineStatus(PASSED, subtest); + + + OUTPUT_Line("Testing memory for write."); + subtest = TEST_MemoryRead(pMem, MEM_BLOCK_SIZE); + OUTPUT_Result(subtest); + result = TEST_CombineStatus(result, subtest); + + + OUTPUT_Line("Unlocking memory"); + if (GlobalUnlock(hMem)) + { + OUTPUT_Result(PASSED); + result = TEST_CombineStatus(result, PASSED); + } + else + { + if (NO_ERROR == GetLastError()) + { + OUTPUT_Result(PASSED); + result = TEST_CombineStatus(result, PASSED); + } + else + { + OutputErrorCode(); + OUTPUT_Result(FAILED); + result = TEST_CombineStatus(result, FAILED); + } + } + } + + OUTPUT_Line("Freeing memory"); + if (0 == GlobalFree(hMem)) + { + OUTPUT_Result(PASSED); + result = TEST_CombineStatus(result, PASSED); + } + else + { + OutputErrorCode(); + OUTPUT_Result(FAILED); + result = TEST_CombineStatus(result, FAILED); + } + } + return result; +} + +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalReAllocFixed() +{ + HGLOBAL hMem = 0; + HGLOBAL hReAlloced = 0; + LPVOID pMem = 0; + TEST_STATUS subtest = SKIPPED; + TEST_STATUS result = SKIPPED; + + OUTPUT_Line("Testing GlobalReAlloc() on memory allocated as GMEM_FIXED"); + + /* Case 1: convert a fixed block to a movable block. */ + OUTPUT_Line("Allocating buffer"); + hMem = GlobalAlloc(GMEM_FIXED, MEM_BLOCK_SIZE); + if (0 != hMem) + { + OUTPUT_Line("Testing to see if this is converted into a movable block"); + hReAlloced = GlobalReAlloc(hMem, MEM_BLOCK_SIZE + 100, GMEM_MOVEABLE | GMEM_MODIFY); + if (0 == hReAlloced) + { + OUTPUT_Line("GlobalReAlloc failed-- returned NULL"); + subtest = TEST_CombineStatus(subtest, FAILED); + OUTPUT_Result(subtest); + } + else + { + hMem = hReAlloced; + if (0 == IsMovable(hMem)) + { + OUTPUT_Line("GlobalReAlloc returned a fixed pointer."); + subtest = TEST_CombineStatus(subtest, FAILED); + OUTPUT_Result(subtest); + } + else + { + pMem = GlobalLock(hMem); + subtest = TEST_CombineStatus(subtest, PASSED); + subtest = TEST_CombineStatus(subtest, TEST_MemoryRead(pMem, MEM_BLOCK_SIZE + 100)); + if (FAILED == subtest) + { + OUTPUT_Line("Memory Read failed."); + } + subtest = TEST_CombineStatus(subtest, TEST_MemoryWrite(pMem, MEM_BLOCK_SIZE + 100)); + if (FAILED == subtest) + { + OUTPUT_Line("Memory Write failed."); + } + GlobalUnlock(hMem); + } + } + + GlobalFree(hMem); + } + else + { + OUTPUT_Line("Global Alloc Failed."); + subtest = TEST_CombineStatus(subtest, FAILED); + } + OUTPUT_Line("Subtest result:"); + OUTPUT_Result(subtest); + OUTPUT_Line(""); + + result = TEST_CombineStatus(result, subtest); + subtest = SKIPPED; + + /* case 2 only move a fixed block */ + OUTPUT_Line("Allocating buffer"); + hMem = GlobalAlloc(GMEM_FIXED, MEM_BLOCK_SIZE); + if (0 != hMem) + { + OUTPUT_Line("Testing to see if a new fixed block is returned."); + hReAlloced = GlobalReAlloc(hMem, MEM_BLOCK_SIZE - 100, GMEM_MOVEABLE); + if (0 == hReAlloced) + { + OUTPUT_Line("GlobalReAlloc failed-- returned NULL"); + subtest = TEST_CombineStatus(subtest, FAILED); + OUTPUT_Result(subtest); + } + else + { + OUTPUT_Line("Alloced Handle: "); + OUTPUT_HexDword((DWORD)hMem); + OUTPUT_Line("ReAlloced Handle: "); + OUTPUT_HexDword((DWORD)hReAlloced); + if (hMem == hReAlloced) + { + OUTPUT_Line("GlobalReAlloc returned the same pointer. The documentation states that this is wrong, but Windows NT works this way."); + } + + hMem = hReAlloced; + subtest = TEST_CombineStatus(subtest, PASSED); + subtest = TEST_CombineStatus(subtest, TEST_MemoryRead((LPVOID)hMem, MEM_BLOCK_SIZE - 100)); + subtest = TEST_CombineStatus(subtest, TEST_MemoryWrite((LPVOID)hMem, MEM_BLOCK_SIZE - 100)); + } + + GlobalFree(hMem); + } + else + { + subtest = TEST_CombineStatus(subtest, FAILED); + } + OUTPUT_Line("Subtest result:"); + OUTPUT_Result(subtest); + OUTPUT_Line(""); + + result = TEST_CombineStatus(result, subtest); + subtest = SKIPPED; + + /* Case 3: re-allocate a fixed block in place */ + OUTPUT_Line("Allocating buffer"); + hMem = GlobalAlloc(GMEM_FIXED, MEM_BLOCK_SIZE); + if (0 != hMem) + { + OUTPUT_Line("Testing to see if a fixed pointer is reallocated in place."); + hReAlloced = GlobalReAlloc(hMem, MEM_BLOCK_SIZE - 100, 0); + if (0 == hReAlloced) + { + OUTPUT_Line("GlobalReAlloc failed-- returned NULL"); + subtest = TEST_CombineStatus(subtest, FAILED); + OUTPUT_Result(subtest); + } + else + { + OUTPUT_Line("Alloced Handle: "); + OUTPUT_HexDword((DWORD)hMem); + OUTPUT_Line("ReAlloced Handle: "); + OUTPUT_HexDword((DWORD)hReAlloced); + if (hMem != hReAlloced) + { + OUTPUT_Line("GlobalReAlloc returned a different."); + subtest = TEST_CombineStatus(subtest, FAILED); + OUTPUT_Result(subtest); + } + else + { + subtest = TEST_CombineStatus(subtest, PASSED); + subtest = TEST_CombineStatus(subtest, TEST_MemoryRead((LPVOID)hMem, MEM_BLOCK_SIZE - 100)); + subtest = TEST_CombineStatus(subtest, TEST_MemoryWrite((LPVOID)hMem, MEM_BLOCK_SIZE - 100)); + } + } + + GlobalFree(hMem); + } + else + { + subtest = TEST_CombineStatus(subtest, FAILED); + } + OUTPUT_Line("Subtest result:"); + OUTPUT_Result(subtest); + OUTPUT_Line(""); + + result = TEST_CombineStatus(result, subtest); + + OUTPUT_Line(""); + return result; +} +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalReAllocMovable() +{ + HGLOBAL hMem = 0; + HGLOBAL hReAlloced = 0; + LPVOID pMem = 0; + TEST_STATUS subtest = SKIPPED; + TEST_STATUS result = SKIPPED; + + OUTPUT_Line("Testing GlobalReAlloc() on memory allocated as GMGM_MOVEABLE"); + + /* case 1 test reallocing a movable block that is unlocked. */ + OUTPUT_Line("Allocating buffer"); + hMem = GlobalAlloc(GMEM_MOVEABLE, MEM_BLOCK_SIZE); + if (0 != hMem) + { + OUTPUT_Line("Testing GlobalReAlloc on a unlocked block."); + hReAlloced = GlobalReAlloc(hMem, MEM_BLOCK_SIZE - 100, 0); + if (0 == hReAlloced) + { + OUTPUT_Line("GlobalReAlloc failed-- returned NULL"); + subtest = TEST_CombineStatus(subtest, FAILED); + OUTPUT_Result(subtest); + } + else + { + OUTPUT_Line("Alloced Handle: "); + OUTPUT_HexDword((DWORD)hMem); + OUTPUT_Line("ReAlloced Handle: "); + OUTPUT_HexDword((DWORD)hReAlloced); + + pMem = GlobalLock(hReAlloced); + hMem = hReAlloced; + subtest = TEST_CombineStatus(subtest, PASSED); + subtest = TEST_CombineStatus(subtest, TEST_MemoryRead(pMem, MEM_BLOCK_SIZE - 100)); + subtest = TEST_CombineStatus(subtest, TEST_MemoryWrite(pMem, MEM_BLOCK_SIZE - 100)); + GlobalUnlock(hReAlloced); + } + + GlobalFree(hMem); + } + else + { + subtest = TEST_CombineStatus(subtest, FAILED); + } + OUTPUT_Line("Subtest result:"); + OUTPUT_Result(subtest); + OUTPUT_Line(""); + + result = TEST_CombineStatus(result, subtest); + subtest = SKIPPED; + + /* Case 2: re-allocate a moveable block that is locked */ + OUTPUT_Line("Allocating buffer"); + hMem = GlobalAlloc(GMEM_MOVEABLE, MEM_BLOCK_SIZE); + if (0 != hMem) + { + + OUTPUT_Line("Testing GlobalReAlloc on a locked block."); + pMem = GlobalLock(hMem); + hReAlloced = GlobalReAlloc(hMem, MEM_BLOCK_SIZE - 100, 0); + if (0 == hReAlloced) + { + OUTPUT_Line("GlobalReAlloc failed-- returned NULL"); + subtest = TEST_CombineStatus(subtest, FAILED); + OUTPUT_Result(subtest); + } + else + { + OUTPUT_Line("Alloced Handle: "); + OUTPUT_HexDword((DWORD)hMem); + OUTPUT_Line("ReAlloced Handle: "); + OUTPUT_HexDword((DWORD)hReAlloced); + if (hMem != hReAlloced) + { + OUTPUT_Line("GlobalReAlloc returned a different block."); + } + pMem = GlobalLock(hReAlloced); + subtest = TEST_CombineStatus(subtest, PASSED); + subtest = TEST_CombineStatus(subtest, TEST_MemoryRead(pMem, MEM_BLOCK_SIZE - 100)); + subtest = TEST_CombineStatus(subtest, TEST_MemoryWrite(pMem , MEM_BLOCK_SIZE - 100)); + GlobalUnlock(hReAlloced); + + } + + GlobalUnlock(hMem); + + GlobalFree(hMem); + } + else + { + subtest = TEST_CombineStatus(subtest, FAILED); + } + OUTPUT_Line("Subtest result:"); + OUTPUT_Result(subtest); + OUTPUT_Line(""); + + result = TEST_CombineStatus(result, subtest); + + OUTPUT_Line(""); + return result; +} + +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalReAlloc() +{ + OUTPUT_Banner("Testing GlobalReAlloc()"); + TEST_STATUS result = SKIPPED; + + result = TEST_CombineStatus(result, TestGlobalReAllocFixed()); + result = TEST_CombineStatus(result, TestGlobalReAllocMovable()); + + OUTPUT_Line("GlobalReAlloc test result:"); + OUTPUT_Result(result); + return result; +} + +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalFlagsMoveable() +{ + HGLOBAL hMem = 0; + UINT uFlags = 0; + TEST_STATUS result = SKIPPED; + + OUTPUT_Line("Test for the proper lock count"); + + hMem = GlobalAlloc(GMEM_MOVEABLE, MEM_BLOCK_SIZE); + if (0 != hMem) + { + + OUTPUT_Line("Testing initial allocation"); + + OUTPUT_Line("Testing for a lock of 0"); + uFlags = GlobalFlags(hMem); + if (((GMEM_LOCKCOUNT & uFlags) == 0)) /*no locks*/ + { + result = TEST_CombineStatus(result, PASSED); + } + else + { + result = TEST_CombineStatus(result, FAILED); + } + OUTPUT_Result(result); + + OUTPUT_Line("Pointer from handle: "); + OUTPUT_HexDword((DWORD)GlobalLock(hMem)); + + OUTPUT_Line("Testing after a lock"); + OUTPUT_Line("Testing for a lock of 1"); + uFlags = GlobalFlags(hMem); + if (((GMEM_LOCKCOUNT & uFlags) == 1)) /*no locks*/ + { + result = TEST_CombineStatus(result, PASSED); + } + else + { + result = TEST_CombineStatus(result, FAILED); + } + OUTPUT_Result(result); + + GlobalUnlock(hMem); + OUTPUT_Line("Testing after an unlock"); + OUTPUT_Line("Testing for a lock of 0"); + uFlags = GlobalFlags(hMem); + if (((GMEM_LOCKCOUNT & uFlags) == 0)) /*no locks*/ + { + result = TEST_CombineStatus(result, PASSED); + } + else + { + result = TEST_CombineStatus(result, FAILED); + } + OUTPUT_Result(result); + } + else + { + OUTPUT_Line("GlobalAlloc failed!"); + result = TEST_CombineStatus(result, FAILED); + } + + OUTPUT_Line("Test for discarded memory"); + OUTPUT_Line("Allocating an empty moveable block---automatically marked as discarded"); + hMem = GlobalAlloc(GMEM_MOVEABLE, 0); /*allocate a discarded block*/ + if (0 != hMem) + { + OUTPUT_Line("Allocation handle: "); + OUTPUT_HexDword((DWORD)hMem); + OUTPUT_Line("Testing for a discarded flag"); + uFlags = GlobalFlags(hMem); + if (0 != (uFlags & GMEM_DISCARDED)) /*discarded*/ + { + result = TEST_CombineStatus(result, PASSED); + } + else + { + result = TEST_CombineStatus(result, FAILED); + } + OUTPUT_Line("Flags:"); + OUTPUT_HexDword(uFlags); + OUTPUT_Result(result); + + GlobalFree(hMem); + } + else + { + OUTPUT_Line("GlobalAlloc failed!"); + result = TEST_CombineStatus(result, FAILED); + } + return result; +} + + +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalFlagsFixed() +{ + HGLOBAL hMem = 0; + UINT uFlags = 0; + TEST_STATUS result = SKIPPED; + + OUTPUT_Line("Testing for correct handling of GMEM_FIXED memory"); + hMem = GlobalAlloc(GMEM_FIXED, MEM_BLOCK_SIZE); + if (0 != hMem) + { + + OUTPUT_Line("Allocation handle: "); + OUTPUT_HexDword((DWORD)hMem); + + OUTPUT_Line("Testing initial allocation"); + OUTPUT_Line("Testing for non-discarded and lock of 0"); + uFlags = GlobalFlags(hMem); + if (((GMEM_LOCKCOUNT & uFlags) == 0) && /*no locks*/ + (((uFlags >> 8) & 0xff) == 0 )) /*not discarded*/ + { + result = TEST_CombineStatus(result, PASSED); + } + else + { + result = TEST_CombineStatus(result, FAILED); + } + OUTPUT_Result(result); + + OUTPUT_Line("Pointer from handle: "); + OUTPUT_HexDword((DWORD)GlobalLock(hMem)); + OUTPUT_Line("Testing after a lock"); + OUTPUT_Line("Testing for non-discarded and lock of 0"); + uFlags = GlobalFlags(hMem); + if (((GMEM_LOCKCOUNT & uFlags) == 0) && /*no locks*/ + (((uFlags >> 8) & 0xff) == 0 )) /*not discarded*/ + { + result = TEST_CombineStatus(result, PASSED); + } + else + { + result = TEST_CombineStatus(result, FAILED); + } + OUTPUT_Result(result); + + GlobalFree(hMem); + } + else + { + OUTPUT_Line("GlobalAlloc failed!"); + result = TEST_CombineStatus(result, FAILED); + } + + return result; +} +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalFlags() +{ + OUTPUT_Banner("Testing GlobalFlags()"); + TEST_STATUS result = SKIPPED; + + result = TEST_CombineStatus(result, TestGlobalFlagsFixed()); + result = TEST_CombineStatus(result, TestGlobalFlagsMoveable()); + + OUTPUT_Line("GlobalFlags result:"); + OUTPUT_Result(result); + return result; +} +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalHandle() +{ + HGLOBAL hMem = 0; + HGLOBAL hTest = 0; + PVOID pMem = 0; + TEST_STATUS subtest = SKIPPED; + TEST_STATUS result = SKIPPED; + + OUTPUT_Banner("Testing GlobalHandle()"); + + OUTPUT_Line("Testing GlobalHandle with a block of GMEM_FIXED memory"); + hMem = GlobalAlloc(GMEM_FIXED, MEM_BLOCK_SIZE); + if (0 != hMem) + { + + OUTPUT_Line("Allocation handle: "); + OUTPUT_HexDword((DWORD)hMem); + + hTest = GlobalHandle(hMem); + if (hMem == hTest) + { + subtest = TEST_CombineStatus(subtest, PASSED); + } + else + { + OUTPUT_Line("GlobalHandle returned:"); + OUTPUT_HexDword((DWORD)hTest); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + GlobalFree(hMem); + } + else + { + OUTPUT_Line("GlobalAlloc failed!"); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + OUTPUT_Line("Result from subtest:"); + OUTPUT_Result(subtest); + result = TEST_CombineStatus(result, subtest); + + + subtest = SKIPPED; + OUTPUT_Line("Testing GlobalHandle with a block of GMEM_MOVEABLE memory"); + hMem = GlobalAlloc(GMEM_MOVEABLE, MEM_BLOCK_SIZE); + if (0 != hMem) + { + + OUTPUT_Line("Allocation handle: "); + OUTPUT_HexDword((DWORD)hMem); + pMem = GlobalLock(hMem); + hTest = GlobalHandle(pMem); + if (hMem == hTest) + { + subtest = TEST_CombineStatus(subtest, PASSED); + } + else + { + OUTPUT_Line("GlobalHandle returned:"); + OUTPUT_HexDword((DWORD)hTest); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + GlobalUnlock(hMem); + GlobalFree(hMem); + } + else + { + OUTPUT_Line("GlobalAlloc failed!"); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + OUTPUT_Line("Result from subtest:"); + OUTPUT_Result(subtest); + result = TEST_CombineStatus(result, subtest); + + + OUTPUT_Line("Global Handle test results:"); + OUTPUT_Result(result); + return result; +} + +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalSize() +{ + HGLOBAL hMem = 0; + SIZE_T size = 0; + TEST_STATUS subtest = SKIPPED; + TEST_STATUS result = SKIPPED; + OUTPUT_Banner("Testing GlobalSize()"); + + OUTPUT_Line("Testing GlobalSize with a block of GMEM_FIXED memory"); + hMem = GlobalAlloc(GMEM_FIXED, MEM_BLOCK_SIZE); + if (0 != hMem) + { + size = GlobalSize(hMem); + if (MEM_BLOCK_SIZE <= size) + { + subtest = TEST_CombineStatus(subtest, PASSED); + } + else + { + OUTPUT_Line("GlobalSize returned:"); + OUTPUT_HexDword(size); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + GlobalFree(hMem); + } + else + { + OUTPUT_Line("GlobalAlloc failed!"); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + OUTPUT_Line("Result from subtest:"); + OUTPUT_Result(subtest); + result = TEST_CombineStatus(result, subtest); + + OUTPUT_Line("Testing GlobalSize with a block of GMEM_MOVEABLE memory"); + hMem = GlobalAlloc(GMEM_MOVEABLE, MEM_BLOCK_SIZE); + if (0 != hMem) + { + size = GlobalSize(hMem); + if (MEM_BLOCK_SIZE <= size) + { + subtest = TEST_CombineStatus(subtest, PASSED); + } + else + { + OUTPUT_Line("GlobalSize returned:"); + OUTPUT_HexDword(size); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + GlobalFree(hMem); + } + else + { + OUTPUT_Line("GlobalAlloc failed!"); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + OUTPUT_Line("Result from subtest:"); + OUTPUT_Result(subtest); + result = TEST_CombineStatus(result, subtest); + + OUTPUT_Line("Testing GlobalSize with discarded memory"); + hMem = GlobalAlloc(GMEM_MOVEABLE, 0); + if (0 != hMem) + { + size = GlobalSize(hMem); + if (0 == size) + { + subtest = TEST_CombineStatus(subtest, PASSED); + } + else + { + OUTPUT_Line("GlobalSize returned:"); + OUTPUT_HexDword(size); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + GlobalFree(hMem); + } + else + { + OUTPUT_Line("GlobalAlloc failed!"); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + OUTPUT_Line("Result from subtest:"); + OUTPUT_Result(subtest); + result = TEST_CombineStatus(result, subtest); + + OUTPUT_Line("Test result:"); + OUTPUT_Result(result); + return result; +} + +/*--------------------------------------------------------------------------- +** +*/ +TEST_STATUS TestGlobalDiscard() +{ + HGLOBAL hMem = 0; + HGLOBAL hTest = 0; + DWORD uFlags = 0; + TEST_STATUS subtest = SKIPPED; + TEST_STATUS result = SKIPPED; + + OUTPUT_Banner("Testing GlobalDiscard()"); + hMem = GlobalAlloc(GMEM_MOVEABLE, MEM_BLOCK_SIZE); + if (0 != hMem) + { + OUTPUT_Line("Allocation handle: "); + OUTPUT_HexDword((DWORD)hMem); + + hTest = GlobalDiscard(hMem); + if (0 == hTest) + { + OUTPUT_Line("GlobalDiscard returned NULL"); + subtest = TEST_CombineStatus(subtest, FAILED); + } + else + { + uFlags = GlobalFlags(hTest); + OUTPUT_Line("Flags from the new memory block."); + OUTPUT_HexDword(uFlags); + if (0 != (uFlags & GMEM_DISCARDED)) + { + subtest = TEST_CombineStatus(subtest, PASSED); + } + else + { + OUTPUT_Line("Block is not marked as discardable."); + subtest = TEST_CombineStatus(subtest, FAILED); + } + } + + GlobalFree(hTest); + } + else + { + OUTPUT_Line("GlobalAlloc failed!"); + subtest = TEST_CombineStatus(subtest, FAILED); + } + + OUTPUT_Line("Result from subtest:"); + OUTPUT_Result(subtest); + + result = TEST_CombineStatus(result, subtest); + + OUTPUT_Result(result); + return result; +} + +/*--------------------------------------------------------------------------- +** +*/ +int main(int argc, char ** argv) +{ + TEST_STATUS test_set = SKIPPED; + OUTPUT_Banner("Testing GlobalXXX memory management functions."); + + test_set = TEST_CombineStatus(test_set, TestGlobalAllocNFree(GPTR)); + test_set = TEST_CombineStatus(test_set, TestGlobalAllocNFree(GHND)); + test_set = TEST_CombineStatus(test_set, TestGlobalAllocNFree(GMEM_FIXED)); + test_set = TEST_CombineStatus(test_set, TestGlobalAllocNFree(GMEM_MOVEABLE)); + + if (FAILED == test_set) + { + OUTPUT_Line("Skipping any further tests. GlobalAlloc/Free fails."); + OUTPUT_Result(test_set); + return test_set; + } + + test_set = TEST_CombineStatus(test_set, TestGlobalLockNUnlock(GPTR)); + test_set = TEST_CombineStatus(test_set, TestGlobalLockNUnlock(GHND)); + test_set = TEST_CombineStatus(test_set, TestGlobalLockNUnlock(GMEM_FIXED)); + test_set = TEST_CombineStatus(test_set, TestGlobalLockNUnlock(GMEM_MOVEABLE)); + + test_set = TEST_CombineStatus(test_set, TestGlobalReAlloc()); + + test_set = TEST_CombineStatus(test_set, TestGlobalFlags()); + + test_set = TEST_CombineStatus(test_set, TestGlobalHandle()); + + test_set = TEST_CombineStatus(test_set, TestGlobalSize()); + + test_set = TEST_CombineStatus(test_set, TestGlobalDiscard()); + + /* output the result for the entire set of tests*/ + OUTPUT_Banner("Test suite result"); + OUTPUT_Result(test_set); + return test_set; +} diff --git a/rosapps/tests/gradient/.cvsignore b/rosapps/tests/gradient/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/gradient/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/gradient/gradient.c b/rosapps/tests/gradient/gradient.c new file mode 100644 index 00000000000..e291b2101ec --- /dev/null +++ b/rosapps/tests/gradient/gradient.c @@ -0,0 +1,181 @@ +#include +#include +#include + +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 = "GradientClass"; + 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("GradientClass", + "GradientFill Test", + WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL, + 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"); + + ShowWindow(hWnd, nCmdShow); + + while(GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + //DeleteObject(tf); + + return msg.wParam; +} +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + HDC hDC; + + switch(msg) + { + case WM_PAINT: + { + PAINTSTRUCT ps; + TRIVERTEX vert [5] ; + GRADIENT_TRIANGLE gTRi[3]; + GRADIENT_RECT gRect[2]; + hDC = BeginPaint(hWnd, &ps); + + vert [0] .x = 0; + vert [0] .y = 0; + vert [0] .Red = 0xff00; + vert [0] .Green = 0xff00; + vert [0] .Blue = 0xff00; + vert [0] .Alpha = 0x0000; + + vert [1] .x = 300; + vert [1] .y = 20; + vert [1] .Red = 0x0000; + vert [1] .Green = 0x0000; + vert [1] .Blue = 0xff00; + vert [1] .Alpha = 0x0000; + + vert [2] .x = 100; + vert [2] .y = 200; + vert [2] .Red = 0xff00; + vert [2] .Green = 0x0000; + vert [2] .Blue = 0x0000; + vert [2] .Alpha = 0x0000; + + vert [3] .x = 250; + vert [3] .y = 300; + vert [3] .Red = 0x8000; + vert [3] .Green = 0x8000; + vert [3] .Blue = 0x0000; + vert [3] .Alpha = 0x0000; + + vert [4] .x = 325; + vert [4] .y = 300; + vert [4] .Red = 0x0000; + vert [4] .Green = 0xff00; + vert [4] .Blue = 0x0000; + vert [4] .Alpha = 0x0000; + + gTRi[0].Vertex1 = 0; + gTRi[0].Vertex2 = 1; + gTRi[0].Vertex3 = 2; + + gTRi[1].Vertex1 = 1; + gTRi[1].Vertex2 = 2; + gTRi[1].Vertex3 = 3; + + gTRi[2].Vertex1 = 1; + gTRi[2].Vertex2 = 3; + gTRi[2].Vertex3 = 4; + + GdiGradientFill(hDC,vert,5,&gTRi,3,GRADIENT_FILL_TRIANGLE); + + + vert [0] .x = 5; + vert [0] .y = 200; + vert [0] .Red = 0x0000; + vert [0] .Green = 0x0000; + vert [0] .Blue = 0x0000; + vert [0] .Alpha = 0x0000; + + vert [1] .x = 90; + vert [1] .y = 240; + vert [1] .Red = 0x0000; + vert [1] .Green = 0x0000; + vert [1] .Blue = 0xff00; + vert [1] .Alpha = 0x0000; + + vert [2] .x = 5; + vert [2] .y = 245; + vert [2] .Red = 0x0000; + vert [2] .Green = 0x0000; + vert [2] .Blue = 0x0000; + vert [2] .Alpha = 0x0000; + + vert [3] .x = 90; + vert [3] .y = 300; + vert [3] .Red = 0x0000; + vert [3] .Green = 0x0000; + vert [3] .Blue = 0xff00; + vert [3] .Alpha = 0x0000; + + gRect[0].UpperLeft = 0; + gRect[0].LowerRight = 1; + + gRect[1].UpperLeft = 2; + gRect[1].LowerRight = 3; + + GdiGradientFill(hDC,vert,4,&gRect[0],1,GRADIENT_FILL_RECT_H); + GdiGradientFill(hDC,vert,4,&gRect[1],1,GRADIENT_FILL_RECT_V); + + EndPaint(hWnd, &ps); + break; + } + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hWnd, msg, wParam, lParam); + } + return 0; +} diff --git a/rosapps/tests/gradient/makefile b/rosapps/tests/gradient/makefile new file mode 100644 index 00000000000..9e11021c010 --- /dev/null +++ b/rosapps/tests/gradient/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:02 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = gradient + +TARGET_SDKLIBS = gdi32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/guithreadinfo/.cvsignore b/rosapps/tests/guithreadinfo/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/guithreadinfo/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/guithreadinfo/guithreadinfo.c b/rosapps/tests/guithreadinfo/guithreadinfo.c new file mode 100644 index 00000000000..8e8da78b0cf --- /dev/null +++ b/rosapps/tests/guithreadinfo/guithreadinfo.c @@ -0,0 +1,132 @@ +#include +#include +#include + +static GUITHREADINFO gti; +//HFONT tf; +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 = "GuiThreadInfoClass"; + 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("GuiThreadInfoClass", + "GetGUIThreadInfo", + WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL, + 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"); + + gti.cbSize = sizeof(GUITHREADINFO); + GetGUIThreadInfo(0, >i); + + SetTimer(hWnd, 1, 1000, NULL); + ShowWindow(hWnd, nCmdShow); + + while(GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + //DeleteObject(tf); + + return msg.wParam; +} + +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PAINTSTRUCT ps; + HDC hDC; + char str[255]; + + switch(msg) + { + + case WM_PAINT: + hDC = BeginPaint(hWnd, &ps); + wsprintf(str, "flags: "); + if(gti.flags & GUI_16BITTASK) lstrcat(str, "GUI_16BITTASK "); + if(gti.flags & GUI_CARETBLINKING) lstrcat(str, "GUI_CARETBLINKING "); + if(gti.flags & GUI_INMENUMODE) lstrcat(str, "GUI_INMENUMODE "); + if(gti.flags & GUI_INMOVESIZE) lstrcat(str, "GUI_INMOVESIZE "); + if(gti.flags & GUI_POPUPMENUMODE) lstrcat(str, "GUI_POPUPMENUMODE "); + if(gti.flags & GUI_SYSTEMMENUMODE) lstrcat(str, "GUI_SYSTEMMENUMODE "); + TextOut(hDC, 10, 10, str, strlen(str)); + + wsprintf(str, "hwndActive == %08X", gti.hwndActive); + TextOut(hDC, 10, 30, str, strlen(str)); + wsprintf(str, "hwndFocus == %08X", gti.hwndFocus); + TextOut(hDC, 10, 50, str, strlen(str)); + wsprintf(str, "hwndCapture == %08X", gti.hwndCapture); + TextOut(hDC, 10, 70, str, strlen(str)); + wsprintf(str, "hwndMenuOwner == %08X", gti.hwndMenuOwner); + TextOut(hDC, 10, 90, str, strlen(str)); + wsprintf(str, "hwndMoveSize == %08X", gti.hwndMoveSize); + TextOut(hDC, 10, 110, str, strlen(str)); + wsprintf(str, "hwndCaret == %08X", gti.hwndCaret); + TextOut(hDC, 10, 130, str, strlen(str)); + wsprintf(str, "rcCaret == (%lu, %lu, %lu, %lu)", gti.rcCaret.left, gti.rcCaret.top, gti.rcCaret.right, gti.rcCaret.bottom); + TextOut(hDC, 10, 150, str, strlen(str)); + + wsprintf(str, "GetGuiResources for the current process: %08X", GetCurrentProcess()); + TextOut(hDC, 10, 180, str, strlen(str)); + wsprintf(str, "GetGuiResources: GR_GDIOBJECTS == %04X", GetGuiResources(GetCurrentProcess(), GR_GDIOBJECTS)); + TextOut(hDC, 10, 200, str, strlen(str)); + wsprintf(str, "GetGuiResources: GR_USEROBJECTS == %04x", GetGuiResources(GetCurrentProcess(), GR_USEROBJECTS)); + TextOut(hDC, 10, 220, str, strlen(str)); + EndPaint(hWnd, &ps); + break; + + case WM_TIMER: + GetGUIThreadInfo(0, >i); + InvalidateRect(hWnd, NULL, TRUE); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hWnd, msg, wParam, lParam); + } + return 0; +} diff --git a/rosapps/tests/guithreadinfo/makefile b/rosapps/tests/guithreadinfo/makefile new file mode 100644 index 00000000000..6f91fa38c8b --- /dev/null +++ b/rosapps/tests/guithreadinfo/makefile @@ -0,0 +1,23 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:02 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = guithreadinfo + +TARGET_SDKLIBS = kernel32.a gdi32.a user32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/hello/.cvsignore b/rosapps/tests/hello/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/hello/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/hello/hello.c b/rosapps/tests/hello/hello.c new file mode 100644 index 00000000000..9e793383d21 --- /dev/null +++ b/rosapps/tests/hello/hello.c @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char* argv[]) +{ + printf("Hello world\n"); + return(0); +} diff --git a/rosapps/tests/hello/makefile b/rosapps/tests/hello/makefile new file mode 100644 index 00000000000..2f5b3b73b76 --- /dev/null +++ b/rosapps/tests/hello/makefile @@ -0,0 +1,21 @@ +# $Id: makefile,v 1.1 2004/10/21 05:12:02 sedwards Exp $ + +PATH_TO_TOP = ../../../reactos + +TARGET_NORC = yes + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = hello + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/tests/hivetest/.cvsignore b/rosapps/tests/hivetest/.cvsignore new file mode 100644 index 00000000000..060f7fa87a2 --- /dev/null +++ b/rosapps/tests/hivetest/.cvsignore @@ -0,0 +1,7 @@ +*.o +*.d +*.a +*.exe +*.coff +*.sym +*.map \ No newline at end of file diff --git a/rosapps/tests/hivetest/hivetest.c b/rosapps/tests/hivetest/hivetest.c new file mode 100644 index 00000000000..2dc2fa31f54 --- /dev/null +++ b/rosapps/tests/hivetest/hivetest.c @@ -0,0 +1,1196 @@ +#include +#include +#include +#include +#include +#include + +HANDLE OutputHandle; +HANDLE InputHandle; + +void dprintf(char* fmt, ...) +{ + va_list args; + char buffer[255]; + + va_start(args,fmt); + vsprintf(buffer,fmt,args); + WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL); + va_end(args); +} + +void do_enumeratekey(PWSTR Name) +{ + ULONG Index,Length,i; + KEY_BASIC_INFORMATION KeyInformation[5]; + NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE hKey1; + UNICODE_STRING KeyName; + + RtlInitUnicodeString(&KeyName, Name); + InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE + , NULL, NULL); + Status=NtOpenKey( &hKey1, MAXIMUM_ALLOWED, &ObjectAttributes); + dprintf("NtEnumerateKey : \n"); + Index=0; + while(Status == STATUS_SUCCESS) + { + Status=NtEnumerateKey(hKey1,Index++,KeyBasicInformation + ,&KeyInformation[0], sizeof(KeyInformation) + ,&Length); + if(Status== STATUS_SUCCESS) + { + dprintf("\tSubKey Name = "); + for (i=0;i +#include + +struct tm time_str; + +char daybuf[20]; + +int main(void) +{ + printf("Testing mktime() by asking\n"); + printf("What day of the week is July 4, 2001?\n"); + + time_str.tm_year = 2001 - 1900; + time_str.tm_mon = 7 - 1; + time_str.tm_mday = 4; + time_str.tm_hour = 0; + time_str.tm_min = 0; + time_str.tm_sec = 1; + time_str.tm_isdst = -1; + if (mktime(&time_str) == -1) + (void)puts("-unknown-"); + else { + (void)strftime(daybuf, sizeof(daybuf), "%A", &time_str); + (void)puts(daybuf); + } + return 0; +} +