mirror of
https://github.com/reactos/reactos.git
synced 2024-07-02 02:34:53 +00:00
Moving tests....Almost done.
svn path=/trunk/; revision=11364
This commit is contained in:
parent
4ed7672428
commit
10a923d083
7
rosapps/tests/bench/.cvsignore
Normal file
7
rosapps/tests/bench/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
8
rosapps/tests/bench/bench-syscall.c
Normal file
8
rosapps/tests/bench/bench-syscall.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
}
|
81
rosapps/tests/bench/bench-thread.c
Normal file
81
rosapps/tests/bench/bench-thread.c
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
#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<NR_THREADS;i++)
|
||||
{
|
||||
CreateThread(NULL,
|
||||
0,
|
||||
thread_main1,
|
||||
(LPVOID)i,
|
||||
0,
|
||||
&id);
|
||||
|
||||
/* CreateThread(NULL,
|
||||
0,
|
||||
thread_main2,
|
||||
(LPVOID)i,
|
||||
0,
|
||||
&id);*/
|
||||
}
|
||||
|
||||
printf("All threads created...\n");
|
||||
|
||||
/*
|
||||
* Waiting for threads is not implemented yet.
|
||||
* If you want to see all threads running, uncomment the
|
||||
* call to SuspendThread(). The test application will
|
||||
* freeze after all threads are created.
|
||||
*/
|
||||
/* SuspendThread (GetCurrentThread()); */
|
||||
|
||||
#else
|
||||
|
||||
printf("Creating thread...\n");
|
||||
|
||||
hThread = CreateThread(NULL,
|
||||
0,
|
||||
thread_main1,
|
||||
(LPVOID)i,
|
||||
0,
|
||||
&id);
|
||||
|
||||
printf("Thread created. Waiting for termination...\n");
|
||||
|
||||
WaitForSingleObject (hThread,
|
||||
-1);
|
||||
|
||||
CloseHandle (hThread);
|
||||
|
||||
printf("Thread terminated...\n");
|
||||
#endif
|
||||
printf("Exiting\n");
|
||||
return 0;
|
||||
}
|
23
rosapps/tests/bench/makefile
Normal file
23
rosapps/tests/bench/makefile
Normal file
|
@ -0,0 +1,23 @@
|
|||
# $Id: makefile,v 1.1 2004/10/21 05:11:58 sedwards Exp $
|
||||
|
||||
PATH_TO_TOP = ../../../reactos
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = bench-thread
|
||||
|
||||
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
|
7
rosapps/tests/bitblt/.cvsignore
Normal file
7
rosapps/tests/bitblt/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
139
rosapps/tests/bitblt/bitblt.c
Normal file
139
rosapps/tests/bitblt/bitblt.c
Normal file
|
@ -0,0 +1,139 @@
|
|||
|
||||
/*
|
||||
* Windows 2000 Graphics API Black Book
|
||||
* (BitBlt Bitmap Rendering Demo)
|
||||
*
|
||||
* Created by Damon Chandler <dmc27@ee.cornell.edu>
|
||||
* Updates can be downloaded at: <www.coriolis.com>
|
||||
*
|
||||
* Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
|
||||
* if you have any questions about this code.
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
|
||||
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<HBRUSH>(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<HBITMAP> */(
|
||||
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<HBITMAP> */
|
||||
(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);
|
||||
}
|
BIN
rosapps/tests/bitblt/lena.bmp
Normal file
BIN
rosapps/tests/bitblt/lena.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 87 KiB |
22
rosapps/tests/bitblt/makefile
Normal file
22
rosapps/tests/bitblt/makefile
Normal file
|
@ -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
|
7
rosapps/tests/button/.cvsignore
Normal file
7
rosapps/tests/button/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
22
rosapps/tests/button/Makefile
Normal file
22
rosapps/tests/button/Makefile
Normal file
|
@ -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
|
107
rosapps/tests/button/buttontst.c
Normal file
107
rosapps/tests/button/buttontst.c
Normal file
|
@ -0,0 +1,107 @@
|
|||
/* Based on Radoslaw Sokol's static control test. */
|
||||
#include <windows.h>
|
||||
|
||||
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;
|
||||
}
|
7
rosapps/tests/button2/.cvsignore
Normal file
7
rosapps/tests/button2/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
22
rosapps/tests/button2/Makefile
Normal file
22
rosapps/tests/button2/Makefile
Normal file
|
@ -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
|
219
rosapps/tests/button2/buttontst2.c
Normal file
219
rosapps/tests/button2/buttontst2.c
Normal file
|
@ -0,0 +1,219 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
7
rosapps/tests/capclock/.cvsignore
Normal file
7
rosapps/tests/capclock/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
20
rosapps/tests/capclock/Makefile
Normal file
20
rosapps/tests/capclock/Makefile
Normal file
|
@ -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
|
70
rosapps/tests/capclock/capclock.c
Normal file
70
rosapps/tests/capclock/capclock.c
Normal file
|
@ -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 <windows.h>
|
||||
#include <string.h>
|
||||
|
||||
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 */
|
BIN
rosapps/tests/capclock/capclock.ico
Normal file
BIN
rosapps/tests/capclock/capclock.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
20
rosapps/tests/capclock/capclock.rc
Normal file
20
rosapps/tests/capclock/capclock.rc
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* $Id: capclock.rc,v 1.1 2004/10/21 05:11:59 sedwards Exp $ */
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#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 <reactos/version.rc>
|
||||
|
||||
/* 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
|
7
rosapps/tests/carets/.cvsignore
Normal file
7
rosapps/tests/carets/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
BIN
rosapps/tests/carets/caret.bmp
Normal file
BIN
rosapps/tests/carets/caret.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 B |
150
rosapps/tests/carets/carets.c
Normal file
150
rosapps/tests/carets/carets.c
Normal file
|
@ -0,0 +1,150 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#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;
|
||||
}
|
5
rosapps/tests/carets/carets.rc
Normal file
5
rosapps/tests/carets/carets.rc
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include <defines.h>
|
||||
#include <reactos/resource.h>
|
||||
#include "resource.h"
|
||||
|
||||
IDB_CARET BITMAP DISCARDABLE "caret.bmp"
|
23
rosapps/tests/carets/makefile
Normal file
23
rosapps/tests/carets/makefile
Normal file
|
@ -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
|
1
rosapps/tests/carets/resource.h
Normal file
1
rosapps/tests/carets/resource.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define IDB_CARET 101
|
7
rosapps/tests/combo/.cvsignore
Normal file
7
rosapps/tests/combo/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
687
rosapps/tests/combo/combotst.c
Normal file
687
rosapps/tests/combo/combotst.c
Normal file
|
@ -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 <wac at ghost.matcom.uh.cu>, started July 11, 2003. */
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#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<MAXMESSAGEBUTTONS;i++)ShowWindow(MessageButtons[i],SW_SHOW);
|
||||
ShowWindow(Back2But,SW_SHOW);
|
||||
|
||||
ShowWindow(Back1But,SW_HIDE);
|
||||
ShowWindow(NextBut,SW_HIDE);
|
||||
}
|
||||
|
||||
VOID
|
||||
BackToFirstPage()
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_SHOW);
|
||||
for(;i<MAXMESSAGEBUTTONS;i++)ShowWindow(MessageButtons[i],SW_HIDE);
|
||||
ShowWindow(Back2But,SW_HIDE);
|
||||
ShowWindow(Back1But,SW_SHOW);
|
||||
ShowWindow(NextBut,SW_SHOW);
|
||||
}
|
||||
|
||||
VOID
|
||||
BackToInitialPage()
|
||||
{
|
||||
int i;
|
||||
DestroyWindow(hwndEdit);
|
||||
for (i=0 ; i< NUMBERBUTTONS ; i++) {ShowWindow(Buttons[i],SW_SHOW);}
|
||||
for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_HIDE);
|
||||
ShowWindow(Back1But,SW_HIDE);
|
||||
ShowWindow(NextBut,SW_HIDE);
|
||||
}
|
||||
|
||||
LRESULT
|
||||
CALLBACK
|
||||
WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
int i;
|
||||
switch ( msg )
|
||||
{
|
||||
case WM_CREATE:
|
||||
g_hwnd = hwnd;
|
||||
|
||||
/* ---- Initial page ---- */
|
||||
|
||||
for (i = 0 ; i < 14 ; i++)
|
||||
Buttons[i] = CreateCheckButton(Styles[i].Name,CHECKBUTWIDTH,500+i);
|
||||
|
||||
xButPos += CHECKBUTWIDTH + 10;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i < NUMBERCHECKS ; i++)
|
||||
Buttons[i] = CreateCheckButton(Styles[i].Name,CHECKBUTWIDTH,500+i);
|
||||
|
||||
Buttons[i++] = CreatePushButton("Width +",70,100,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("Width -",70,101,WS_VISIBLE);
|
||||
|
||||
Buttons[i++] = CreatePushButton("Heigth +",70,102,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("Heigth -",70,103,WS_VISIBLE);
|
||||
|
||||
Buttons[i++] = CreatePushButton("CreateWindowA",CHECKBUTWIDTH,CREATEWINDOW_ID,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("CreateWindowExA",CHECKBUTWIDTH,CREATEWINDOWEX_ID,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("CreateWindowExW",CHECKBUTWIDTH,CREATEWINDOWW_ID,WS_VISIBLE);
|
||||
|
||||
|
||||
/* ---- The 1st page of buttons ---- */
|
||||
|
||||
xButPos = 0;
|
||||
yButPos = 10;
|
||||
|
||||
for (i = 0 ; i < 14 ; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,CHECKBUTWIDTH,600+i,0);
|
||||
|
||||
xButPos += CHECKBUTWIDTH + 10;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i < 26 ; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,CHECKBUTWIDTH,600+i,0);
|
||||
|
||||
Back1But = CreatePushButton("Back - destroys ComboBox",CHECKBUTWIDTH,INITPAGE_ID,0);
|
||||
NextBut = CreatePushButton("Next",CHECKBUTWIDTH,SECONDPAGE_ID,0);
|
||||
|
||||
/* ---- The 2nd page of buttons ------*/
|
||||
|
||||
xButPos = 0;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i<40; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,CHECKBUTWIDTH,600+i,0);
|
||||
|
||||
xButPos += CHECKBUTWIDTH + 10;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i < MAXMESSAGEBUTTONS ; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,CHECKBUTWIDTH,600+i,0);
|
||||
|
||||
Back2But = CreatePushButton("Back",CHECKBUTWIDTH,BACKFIRSTPAGE_ID,0);
|
||||
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) >= 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;
|
||||
}
|
25
rosapps/tests/combo/makefile
Normal file
25
rosapps/tests/combo/makefile
Normal file
|
@ -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
|
33
rosapps/tests/combo/utils.c
Normal file
33
rosapps/tests/combo/utils.c
Normal file
|
@ -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 <wac at ghost.matcom.uh.cu>, June 22, 2003.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
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++)) {}
|
||||
}
|
9
rosapps/tests/combo/utils.h
Normal file
9
rosapps/tests/combo/utils.h
Normal file
|
@ -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
|
7
rosapps/tests/consume/.cvsignore
Normal file
7
rosapps/tests/consume/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
21
rosapps/tests/consume/Makefile
Normal file
21
rosapps/tests/consume/Makefile
Normal file
|
@ -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
|
31
rosapps/tests/consume/consume.c
Normal file
31
rosapps/tests/consume/consume.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
#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);
|
||||
}
|
7
rosapps/tests/copymove/.cvsignore
Normal file
7
rosapps/tests/copymove/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
21
rosapps/tests/copymove/Makefile
Normal file
21
rosapps/tests/copymove/Makefile
Normal file
|
@ -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
|
303
rosapps/tests/copymove/copymove.c
Normal file
303
rosapps/tests/copymove/copymove.c
Normal file
|
@ -0,0 +1,303 @@
|
|||
/*
|
||||
* CopyFile, MoveFile and related routines test
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
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;
|
||||
}
|
7
rosapps/tests/count/.cvsignore
Normal file
7
rosapps/tests/count/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
23
rosapps/tests/count/Makefile
Normal file
23
rosapps/tests/count/Makefile
Normal file
|
@ -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
|
15
rosapps/tests/count/count.c
Normal file
15
rosapps/tests/count/count.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* $Id: count.c,v 1.1 2004/10/21 05:12:00 sedwards Exp $
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
int n = 0;
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{
|
||||
while (1) printf ("%d ", n ++ );
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* EOF */
|
7
rosapps/tests/create-links/.cvsignore
Normal file
7
rosapps/tests/create-links/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
25
rosapps/tests/create-links/Makefile
Normal file
25
rosapps/tests/create-links/Makefile
Normal file
|
@ -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
|
97
rosapps/tests/create-links/create-links.c
Normal file
97
rosapps/tests/create-links/create-links.c
Normal file
|
@ -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 <windows.h>
|
||||
|
||||
#include <shlobj.h>
|
||||
#include <objidl.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
7
rosapps/tests/dibtest/.cvsignore
Normal file
7
rosapps/tests/dibtest/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
196
rosapps/tests/dibtest/dibtest.c
Normal file
196
rosapps/tests/dibtest/dibtest.c
Normal file
|
@ -0,0 +1,196 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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;
|
||||
}
|
23
rosapps/tests/dibtest/makefile
Normal file
23
rosapps/tests/dibtest/makefile
Normal file
|
@ -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
|
7
rosapps/tests/dirdlg/.cvsignore
Normal file
7
rosapps/tests/dirdlg/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
115
rosapps/tests/dirdlg/dirdlg.c
Normal file
115
rosapps/tests/dirdlg/dirdlg.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#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;
|
||||
}
|
||||
|
14
rosapps/tests/dirdlg/dirdlg.rc
Normal file
14
rosapps/tests/dirdlg/dirdlg.rc
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <defines.h>
|
||||
#include <reactos/resource.h>
|
||||
#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
|
21
rosapps/tests/dirdlg/makefile
Normal file
21
rosapps/tests/dirdlg/makefile
Normal file
|
@ -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
|
6
rosapps/tests/dirdlg/resource.h
Normal file
6
rosapps/tests/dirdlg/resource.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#define IDD_MAIN 101
|
||||
|
||||
#define IDC_OK 1
|
||||
#define IDC_CANCEL 2
|
||||
#define IDC_DIRS 100
|
||||
#define IDC_DIREDIT 101
|
7
rosapps/tests/diskspeed/.cvsignore
Normal file
7
rosapps/tests/diskspeed/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
165
rosapps/tests/diskspeed/diskspeed.c
Normal file
165
rosapps/tests/diskspeed/diskspeed.c
Normal file
|
@ -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 <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <ddk/ntddscsi.h>
|
||||
#include <ddk/scsi.h>
|
||||
|
||||
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;
|
||||
}
|
23
rosapps/tests/diskspeed/makefile
Normal file
23
rosapps/tests/diskspeed/makefile
Normal file
|
@ -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
|
7
rosapps/tests/dnsapi/.cvsignore
Normal file
7
rosapps/tests/dnsapi/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
33
rosapps/tests/dnsapi/dnsapi.c
Normal file
33
rosapps/tests/dnsapi/dnsapi.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <WinError.h>
|
||||
#include <WinDNS.h>
|
||||
#include <winsock2.h>
|
||||
#include <assert.h>
|
||||
|
||||
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;
|
||||
}
|
22
rosapps/tests/dnsapi/makefile
Normal file
22
rosapps/tests/dnsapi/makefile
Normal file
|
@ -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
|
7
rosapps/tests/dnsquery/.cvsignore
Normal file
7
rosapps/tests/dnsquery/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
28
rosapps/tests/dnsquery/dnsquery.c
Normal file
28
rosapps/tests/dnsquery/dnsquery.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <WinError.h>
|
||||
#include <WinDNS.h>
|
||||
#include <assert.h>
|
||||
|
||||
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;
|
||||
}
|
22
rosapps/tests/dnsquery/makefile
Normal file
22
rosapps/tests/dnsquery/makefile
Normal file
|
@ -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
|
7
rosapps/tests/dump_shared_data/.cvsignore
Normal file
7
rosapps/tests/dump_shared_data/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
52
rosapps/tests/dump_shared_data/dump_shared_data.c
Normal file
52
rosapps/tests/dump_shared_data/dump_shared_data.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
#include <stdio.h>
|
||||
#include <ntddk.h>
|
||||
|
||||
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;
|
||||
}
|
22
rosapps/tests/dump_shared_data/makefile
Normal file
22
rosapps/tests/dump_shared_data/makefile
Normal file
|
@ -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
|
||||
|
7
rosapps/tests/edit/.cvsignore
Normal file
7
rosapps/tests/edit/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
649
rosapps/tests/edit/edittest.c
Normal file
649
rosapps/tests/edit/edittest.c
Normal file
|
@ -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 <wac at ghost.matcom.uh.cu>, June 22, 2003. */
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#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<MAXMESSAGEBUTTONS;i++)ShowWindow(MessageButtons[i],SW_SHOW);
|
||||
ShowWindow(Back2But,SW_SHOW);
|
||||
|
||||
ShowWindow(Back1But,SW_HIDE);
|
||||
ShowWindow(NextBut,SW_HIDE);
|
||||
}
|
||||
|
||||
VOID
|
||||
BackToFirstPage()
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_SHOW);
|
||||
for(;i<MAXMESSAGEBUTTONS;i++)ShowWindow(MessageButtons[i],SW_HIDE);
|
||||
ShowWindow(Back2But,SW_HIDE);
|
||||
ShowWindow(Back1But,SW_SHOW);
|
||||
ShowWindow(NextBut,SW_SHOW);
|
||||
}
|
||||
|
||||
VOID
|
||||
BackToInitialPage()
|
||||
{
|
||||
int i;
|
||||
DestroyWindow(hwndEdit);
|
||||
for (i=0 ; i< NUMBERBUTTONS ; i++) {ShowWindow(Buttons[i],SW_SHOW);}
|
||||
for (i=0;i<26;i++)ShowWindow(MessageButtons[i],SW_HIDE);
|
||||
ShowWindow(Back1But,SW_HIDE);
|
||||
ShowWindow(NextBut,SW_HIDE);
|
||||
}
|
||||
|
||||
LRESULT
|
||||
CALLBACK
|
||||
WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
int i;
|
||||
switch ( msg )
|
||||
{
|
||||
case WM_CREATE:
|
||||
g_hwnd = hwnd;
|
||||
|
||||
/* ---- Initial page ---- */
|
||||
|
||||
for (i = 0 ; i < 14 ; i++)
|
||||
Buttons[i] = CreateCheckButton(StyleNames[i],150,500+i);
|
||||
|
||||
xButPos += 160;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i < 19 ; i++)
|
||||
Buttons[i] = CreateCheckButton(StyleNames[i],140,500+i);
|
||||
|
||||
Buttons[i++] = CreatePushButton("Width +",70,100,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("Width -",70,101,WS_VISIBLE);
|
||||
|
||||
Buttons[i++] = CreatePushButton("Heigth +",70,102,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("Heigth -",70,103,WS_VISIBLE);
|
||||
|
||||
Buttons[i++] = CreatePushButton("CreateWindowA",140,CREATEWINDOW,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("CreateWindowExA",140,CREATEWINDOWEX,WS_VISIBLE);
|
||||
Buttons[i++] = CreatePushButton("CreateWindowExW",140,CREATEWINDOWW,WS_VISIBLE);
|
||||
|
||||
|
||||
/* ---- The 1st page of buttons ---- */
|
||||
|
||||
xButPos = 0;
|
||||
yButPos = 10;
|
||||
|
||||
for (i = 0 ; i < 14 ; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
|
||||
|
||||
xButPos += 180;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i < 26 ; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
|
||||
|
||||
Back1But = CreatePushButton("Back - destroys edit",170,400,0);
|
||||
NextBut = CreatePushButton("Next",170,401,0);
|
||||
|
||||
/* ---- The 2nd page of buttons ------*/
|
||||
|
||||
xButPos = 0;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i<40; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
|
||||
|
||||
xButPos += 180;
|
||||
yButPos = 10;
|
||||
|
||||
for (; i < MAXMESSAGEBUTTONS ; i++)
|
||||
MessageButtons[i] = CreatePushButton(Msg[i].Text,170,600+i,0);
|
||||
|
||||
Back2But = CreatePushButton("Back",170,402,0);
|
||||
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) >= 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;
|
||||
|
||||
}
|
24
rosapps/tests/edit/makefile
Normal file
24
rosapps/tests/edit/makefile
Normal file
|
@ -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
|
33
rosapps/tests/edit/utils.c
Normal file
33
rosapps/tests/edit/utils.c
Normal file
|
@ -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 <wac at ghost.matcom.uh.cu>, June 22, 2003.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
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++)) {}
|
||||
}
|
9
rosapps/tests/edit/utils.h
Normal file
9
rosapps/tests/edit/utils.h
Normal file
|
@ -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
|
7
rosapps/tests/enhmetafile/.cvsignore
Normal file
7
rosapps/tests/enhmetafile/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
123
rosapps/tests/enhmetafile/enhmetafile.c
Normal file
123
rosapps/tests/enhmetafile/enhmetafile.c
Normal file
|
@ -0,0 +1,123 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
//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;
|
||||
}
|
23
rosapps/tests/enhmetafile/makefile
Normal file
23
rosapps/tests/enhmetafile/makefile
Normal file
|
@ -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
|
BIN
rosapps/tests/enhmetafile/test.emf
Normal file
BIN
rosapps/tests/enhmetafile/test.emf
Normal file
Binary file not shown.
7
rosapps/tests/enumfonts/.cvsignore
Normal file
7
rosapps/tests/enumfonts/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
271
rosapps/tests/enumfonts/enumfonts.cpp
Normal file
271
rosapps/tests/enumfonts/enumfonts.cpp
Normal file
|
@ -0,0 +1,271 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 4 - Listing 4.2 (Font Enumeration Demo)
|
||||
//
|
||||
// Created by Damon Chandler <dmc27@ee.cornell.edu>
|
||||
// Updates can be downloaded at: <www.coriolis.com>
|
||||
//
|
||||
// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
|
||||
// if you have any questions about this code.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
#include <windows.h>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
#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<HBRUSH>(
|
||||
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<LPARAM>(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<LPARAM>(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<HMENU>(ID_LISTBOX),
|
||||
hInst, NULL
|
||||
);
|
||||
if (hListBox)
|
||||
{
|
||||
AddScreenFonts();
|
||||
}
|
||||
}
|
||||
case WM_MEASUREITEM:
|
||||
{
|
||||
// grab a pointer to the MEASUREITEMSTRUCT structure
|
||||
LPMEASUREITEMSTRUCT lpmis =
|
||||
reinterpret_cast<LPMEASUREITEMSTRUCT>(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<LPDRAWITEMSTRUCT>(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<HBRUSH>(GetStockObject(stock))
|
||||
);
|
||||
|
||||
if ((int)lpdis->itemID != -1)
|
||||
{
|
||||
// extract the item's text
|
||||
char text[MAX_PATH];
|
||||
SNDMSG(hListBox, LB_GETTEXT, lpdis->itemID,
|
||||
reinterpret_cast<LPARAM>(text));
|
||||
|
||||
// extract the corresponding font handle
|
||||
DWORD value =
|
||||
SNDMSG(hListBox, LB_GETITEMDATA, lpdis->itemID, 0);
|
||||
HFONT hFont = reinterpret_cast<HFONT>(value);
|
||||
|
||||
// select the corresponding font
|
||||
// into the device context
|
||||
HFONT HOldFont = static_cast<HFONT>(
|
||||
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<HFONT>(value));
|
||||
}
|
||||
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
24
rosapps/tests/enumfonts/makefile
Normal file
24
rosapps/tests/enumfonts/makefile
Normal file
|
@ -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
|
7
rosapps/tests/enumwnd/.cvsignore
Normal file
7
rosapps/tests/enumwnd/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
187
rosapps/tests/enumwnd/enumwnd.c
Normal file
187
rosapps/tests/enumwnd/enumwnd.c
Normal file
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* enumwnd.c
|
||||
*
|
||||
* application to test the various Window Enumeration functions
|
||||
*/
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
90
rosapps/tests/enumwnd/enumwnd.dsp
Normal file
90
rosapps/tests/enumwnd/enumwnd.dsp
Normal file
|
@ -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
|
23
rosapps/tests/enumwnd/makefile
Normal file
23
rosapps/tests/enumwnd/makefile
Normal file
|
@ -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
|
7
rosapps/tests/enumws/.cvsignore
Normal file
7
rosapps/tests/enumws/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
35
rosapps/tests/enumws/enumws.c
Normal file
35
rosapps/tests/enumws/enumws.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
21
rosapps/tests/enumws/makefile
Normal file
21
rosapps/tests/enumws/makefile
Normal file
|
@ -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
|
7
rosapps/tests/event/.cvsignore
Normal file
7
rosapps/tests/event/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
33
rosapps/tests/event/event.c
Normal file
33
rosapps/tests/event/event.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
23
rosapps/tests/event/makefile
Normal file
23
rosapps/tests/event/makefile
Normal file
|
@ -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
|
7
rosapps/tests/eventpair/.cvsignore
Normal file
7
rosapps/tests/eventpair/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
65
rosapps/tests/eventpair/eventpair.c
Normal file
65
rosapps/tests/eventpair/eventpair.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Author: Skywing (skywing@valhallalegends.com)
|
||||
* Date: 09/09/2003
|
||||
* Purpose: Test Thread-EventPair functionality.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#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;
|
||||
}
|
23
rosapps/tests/eventpair/makefile
Normal file
23
rosapps/tests/eventpair/makefile
Normal file
|
@ -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
|
7
rosapps/tests/fiber/.cvsignore
Normal file
7
rosapps/tests/fiber/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
21
rosapps/tests/fiber/Makefile
Normal file
21
rosapps/tests/fiber/Makefile
Normal file
|
@ -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
|
446
rosapps/tests/fiber/fiber.c
Normal file
446
rosapps/tests/fiber/fiber.c
Normal file
|
@ -0,0 +1,446 @@
|
|||
/* $Id: fiber.c,v 1.1 2004/10/21 05:12:02 sedwards Exp $
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <tchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
#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 */
|
7
rosapps/tests/global_mem/.cvsignore
Normal file
7
rosapps/tests/global_mem/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
21
rosapps/tests/global_mem/Makefile
Normal file
21
rosapps/tests/global_mem/Makefile
Normal file
|
@ -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
|
1062
rosapps/tests/global_mem/global_mem.c
Normal file
1062
rosapps/tests/global_mem/global_mem.c
Normal file
File diff suppressed because it is too large
Load diff
7
rosapps/tests/gradient/.cvsignore
Normal file
7
rosapps/tests/gradient/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
181
rosapps/tests/gradient/gradient.c
Normal file
181
rosapps/tests/gradient/gradient.c
Normal file
|
@ -0,0 +1,181 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
}
|
23
rosapps/tests/gradient/makefile
Normal file
23
rosapps/tests/gradient/makefile
Normal file
|
@ -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
|
7
rosapps/tests/guithreadinfo/.cvsignore
Normal file
7
rosapps/tests/guithreadinfo/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
132
rosapps/tests/guithreadinfo/guithreadinfo.c
Normal file
132
rosapps/tests/guithreadinfo/guithreadinfo.c
Normal file
|
@ -0,0 +1,132 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
}
|
23
rosapps/tests/guithreadinfo/makefile
Normal file
23
rosapps/tests/guithreadinfo/makefile
Normal file
|
@ -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
|
7
rosapps/tests/hello/.cvsignore
Normal file
7
rosapps/tests/hello/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.o
|
||||
*.d
|
||||
*.a
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue