mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Started removing tests
svn path=/trunk/; revision=11367
This commit is contained in:
parent
75fbd2832d
commit
2b58d249c6
113 changed files with 0 additions and 12479 deletions
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,19 +0,0 @@
|
|||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = accelerator
|
||||
|
||||
#TARGET_SDKLIBS = kernel32.a user32.a
|
||||
|
||||
TARGET_OBJECTS = accelerator.o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
|
@ -1,161 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ID_ACCEL1 0x100
|
||||
#define ID_ACCEL2 0x101
|
||||
#define ID_ACCEL3 0x102
|
||||
#define ID_ACCEL4 0x103
|
||||
|
||||
/*
|
||||
* {fVirt, key, cmd}
|
||||
* fVirt |= FVIRTKEY | FCONTROL | FALT | FSHIFT
|
||||
*/
|
||||
//static HFONT tf;
|
||||
static ACCEL Accelerators[4] = {
|
||||
{ FVIRTKEY, VK_A, ID_ACCEL1},
|
||||
{ FVIRTKEY | FSHIFT, VK_A, ID_ACCEL2},
|
||||
{ FVIRTKEY | FCONTROL, VK_A, ID_ACCEL3},
|
||||
{ FVIRTKEY | FALT, VK_A, ID_ACCEL4}};
|
||||
static HACCEL hAcceleratorTable;
|
||||
static char Event[200];
|
||||
|
||||
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpszCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
MSG msg;
|
||||
HWND hWnd;
|
||||
|
||||
wc.lpszClassName = "AcceleratorTest";
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.style = CS_VREDRAW | CS_HREDRAW;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
if (RegisterClass(&wc) == 0)
|
||||
{
|
||||
fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
hWnd = CreateWindow("AcceleratorTest",
|
||||
"Accelerator Test",
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
0,
|
||||
0,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hWnd == NULL)
|
||||
{
|
||||
fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
/*tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");*/
|
||||
|
||||
Event[0] = 0;
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
|
||||
hAcceleratorTable = CreateAcceleratorTable(Accelerators,
|
||||
sizeof(Accelerators)/sizeof(Accelerators[1]));
|
||||
if (hAcceleratorTable == NULL)
|
||||
{
|
||||
fprintf(stderr, "CreateAcceleratorTable failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
if (!TranslateAccelerator(hWnd, hAcceleratorTable, &msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (!DestroyAcceleratorTable(hAcceleratorTable))
|
||||
{
|
||||
fprintf(stderr, "DestroyAcceleratorTable failed (last error 0x%lX)\n",
|
||||
GetLastError());
|
||||
return(1);
|
||||
}
|
||||
|
||||
//DeleteObject(tf);
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
char buf[200];
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_PAINT:
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
//SelectObject(hDC, tf);
|
||||
sprintf(buf, "Event: '%s'", Event);
|
||||
TextOut(hDC, 10, 10, buf, strlen(buf));
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case ID_ACCEL1:
|
||||
strcpy(Event, "A");
|
||||
break;
|
||||
|
||||
case ID_ACCEL2:
|
||||
strcpy(Event, "SHIFT+A");
|
||||
break;
|
||||
|
||||
case ID_ACCEL3:
|
||||
strcpy(Event, "CTRL+A");
|
||||
break;
|
||||
|
||||
case ID_ACCEL4:
|
||||
strcpy(Event, "ALT+A");
|
||||
break;
|
||||
|
||||
default:
|
||||
sprintf(Event, "%d", LOWORD(wParam));
|
||||
break;
|
||||
}
|
||||
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
UpdateWindow(hWnd);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
* Unit tests for crypt functions
|
||||
*
|
||||
* Copyright (c) 2004 Michael Jung
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wincrypt.h"
|
||||
#include "winerror.h"
|
||||
|
||||
static const char szRsaBaseProv[] = MS_DEF_PROV_A;
|
||||
static const char szNonExistentProv[] = "Wine Non Existent Cryptographic Provider v11.2";
|
||||
static const char szKeySet[] = "wine_test_keyset";
|
||||
static const char szBadKeySet[] = "wine_test_bad_keyset";
|
||||
#define NON_DEF_PROV_TYPE 999
|
||||
|
||||
static void init_environment(void)
|
||||
{
|
||||
HCRYPTPROV hProv;
|
||||
|
||||
/* Ensure that container "wine_test_keyset" does exist */
|
||||
if (!CryptAcquireContext(&hProv, szKeySet, szRsaBaseProv, PROV_RSA_FULL, 0))
|
||||
{
|
||||
CryptAcquireContext(&hProv, szKeySet, szRsaBaseProv, PROV_RSA_FULL, CRYPT_NEWKEYSET);
|
||||
}
|
||||
CryptReleaseContext(hProv, 0);
|
||||
|
||||
/* Ensure that container "wine_test_keyset" does exist in default PROV_RSA_FULL type provider */
|
||||
if (!CryptAcquireContext(&hProv, szKeySet, NULL, PROV_RSA_FULL, 0))
|
||||
{
|
||||
CryptAcquireContext(&hProv, szKeySet, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET);
|
||||
}
|
||||
CryptReleaseContext(hProv, 0);
|
||||
|
||||
/* Ensure that container "wine_test_bad_keyset" does not exist. */
|
||||
if (CryptAcquireContext(&hProv, szBadKeySet, szRsaBaseProv, PROV_RSA_FULL, 0))
|
||||
{
|
||||
CryptReleaseContext(hProv, 0);
|
||||
CryptAcquireContext(&hProv, szBadKeySet, szRsaBaseProv, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
|
||||
}
|
||||
}
|
||||
|
||||
static void clean_up_environment(void)
|
||||
{
|
||||
HCRYPTPROV hProv;
|
||||
|
||||
/* Remove container "wine_test_keyset" */
|
||||
if (CryptAcquireContext(&hProv, szKeySet, szRsaBaseProv, PROV_RSA_FULL, 0))
|
||||
{
|
||||
CryptReleaseContext(hProv, 0);
|
||||
CryptAcquireContext(&hProv, szKeySet, szRsaBaseProv, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
|
||||
}
|
||||
|
||||
/* Remove container "wine_test_keyset" from default PROV_RSA_FULL type provider */
|
||||
if (CryptAcquireContext(&hProv, szKeySet, NULL, PROV_RSA_FULL, 0))
|
||||
{
|
||||
CryptReleaseContext(hProv, 0);
|
||||
CryptAcquireContext(&hProv, szKeySet, NULL, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_acquire_context(void)
|
||||
{
|
||||
BOOL result;
|
||||
HCRYPTPROV hProv;
|
||||
|
||||
/* Provoke all kinds of error conditions (which are easy to provoke).
|
||||
* The order of the error tests seems to match Windows XP's rsaenh.dll CSP,
|
||||
* but since this is likely to change between CSP versions, we don't check
|
||||
* this. Please don't change the order of tests. */
|
||||
result = CryptAcquireContext(&hProv, NULL, NULL, 0, 0);
|
||||
ok(!result && GetLastError()==NTE_BAD_PROV_TYPE, "%08x\n", (unsigned int)GetLastError());
|
||||
|
||||
result = CryptAcquireContext(&hProv, NULL, NULL, 1000, 0);
|
||||
ok(!result && GetLastError()==NTE_BAD_PROV_TYPE, "%08x\n", (unsigned int)GetLastError());
|
||||
|
||||
result = CryptAcquireContext(&hProv, NULL, NULL, NON_DEF_PROV_TYPE, 0);
|
||||
ok(!result && GetLastError()==NTE_PROV_TYPE_NOT_DEF, "%08x\n", (unsigned int)GetLastError());
|
||||
|
||||
result = CryptAcquireContext(&hProv, szKeySet, szNonExistentProv, PROV_RSA_FULL, 0);
|
||||
ok(!result && GetLastError()==NTE_KEYSET_NOT_DEF, "%08x\n", (unsigned int)GetLastError());
|
||||
|
||||
result = CryptAcquireContext(&hProv, szKeySet, szRsaBaseProv, NON_DEF_PROV_TYPE, 0);
|
||||
ok(!result && GetLastError()==NTE_PROV_TYPE_NO_MATCH, "%08x\n", (unsigned int)GetLastError());
|
||||
|
||||
result = CryptAcquireContext(NULL, szKeySet, szRsaBaseProv, PROV_RSA_FULL, 0);
|
||||
ok(!result && GetLastError()==ERROR_INVALID_PARAMETER, "%08x\n", (unsigned int)GetLastError());
|
||||
|
||||
/* Last not least, try to really acquire a context. */
|
||||
result = CryptAcquireContext(&hProv, szKeySet, szRsaBaseProv, PROV_RSA_FULL, 0);
|
||||
ok(result, "%08x\n", (unsigned int)GetLastError());
|
||||
|
||||
if (GetLastError() == ERROR_SUCCESS)
|
||||
CryptReleaseContext(hProv, 0);
|
||||
|
||||
/* Try again, witch an empty ("\0") szProvider parameter */
|
||||
result = CryptAcquireContext(&hProv, szKeySet, "", PROV_RSA_FULL, 0);
|
||||
ok(result, "%08x\n", (unsigned int)GetLastError());
|
||||
|
||||
if (GetLastError() == ERROR_SUCCESS)
|
||||
CryptReleaseContext(hProv, 0);
|
||||
}
|
||||
|
||||
START_TEST(crypt)
|
||||
{
|
||||
init_environment();
|
||||
test_acquire_context();
|
||||
clean_up_environment();
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
# $Id: makefile,v 1.1 2004/08/07 22:51:27 sedwards Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
# require os code to explicitly request A/W version of structs/functions
|
||||
TARGET_CFLAGS += -D_DISABLE_TIDENTS -D__USE_W32API
|
||||
|
||||
TARGET_NAME = advapi32_test
|
||||
|
||||
TARGET_SDKLIBS = advapi32.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
testlist.o \
|
||||
registry.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,237 +0,0 @@
|
|||
/*
|
||||
* Unit tests for registry functions
|
||||
*
|
||||
* Copyright (c) 2002 Alexandre Julliard
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winreg.h"
|
||||
#include "winerror.h"
|
||||
|
||||
static HKEY hkey_main;
|
||||
|
||||
/* delete key and all its subkeys */
|
||||
static DWORD delete_key( HKEY hkey )
|
||||
{
|
||||
char name[MAX_PATH];
|
||||
DWORD ret;
|
||||
|
||||
while (!(ret = RegEnumKeyA(hkey, 0, name, sizeof(name))))
|
||||
{
|
||||
HKEY tmp;
|
||||
if (!(ret = RegOpenKeyExA( hkey, name, 0, KEY_ENUMERATE_SUB_KEYS, &tmp )))
|
||||
{
|
||||
ret = delete_key( tmp );
|
||||
RegCloseKey( tmp );
|
||||
}
|
||||
if (ret) break;
|
||||
}
|
||||
if (ret != ERROR_NO_MORE_ITEMS) return ret;
|
||||
RegDeleteKeyA( hkey, NULL );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup_main_key(void)
|
||||
{
|
||||
if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Test", &hkey_main )) delete_key( hkey_main );
|
||||
|
||||
assert (!RegCreateKeyExA( HKEY_CURRENT_USER, "Software\\Wine\\Test", 0, NULL,
|
||||
REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey_main, NULL ));
|
||||
}
|
||||
|
||||
static void test_enum_value(void)
|
||||
{
|
||||
DWORD res;
|
||||
char value[20], data[20];
|
||||
WCHAR valueW[20], dataW[20];
|
||||
DWORD val_count, data_count, type;
|
||||
static const WCHAR foobarW[] = {'f','o','o','b','a','r',0};
|
||||
static const WCHAR testW[] = {'T','e','s','t',0};
|
||||
static const WCHAR xxxW[] = {'x','x','x','x','x','x','x','x',0};
|
||||
|
||||
/* check NULL data with zero length */
|
||||
res = RegSetValueExA( hkey_main, "Test", 0, REG_SZ, NULL, 0 );
|
||||
if (GetVersion() & 0x80000000)
|
||||
ok( res == ERROR_INVALID_PARAMETER, "RegSetValueExA returned %ld\n", res );
|
||||
else
|
||||
ok( !res, "RegSetValueExA returned %ld\n", res );
|
||||
res = RegSetValueExA( hkey_main, "Test", 0, REG_EXPAND_SZ, NULL, 0 );
|
||||
ok( !res, "RegSetValueExA returned %ld\n", res );
|
||||
res = RegSetValueExA( hkey_main, "Test", 0, REG_BINARY, NULL, 0 );
|
||||
ok( !res, "RegSetValueExA returned %ld\n", res );
|
||||
|
||||
res = RegSetValueExA( hkey_main, "Test", 0, REG_SZ, (BYTE *)"foobar", 7 );
|
||||
ok( res == 0, "RegSetValueExA failed error %ld\n", res );
|
||||
|
||||
/* overflow both name and data */
|
||||
val_count = 2;
|
||||
data_count = 2;
|
||||
type = 1234;
|
||||
strcpy( value, "xxxxxxxxxx" );
|
||||
strcpy( data, "xxxxxxxxxx" );
|
||||
res = RegEnumValueA( hkey_main, 0, value, &val_count, NULL, &type, data, &data_count );
|
||||
ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res );
|
||||
ok( val_count == 2, "val_count set to %ld\n", val_count );
|
||||
ok( data_count == 7, "data_count set to %ld instead of 7\n", data_count );
|
||||
ok( type == REG_SZ, "type %ld is not REG_SZ\n", type );
|
||||
ok( !strcmp( value, "xxxxxxxxxx" ), "value set to '%s'\n", value );
|
||||
ok( !strcmp( data, "xxxxxxxxxx" ), "data set to '%s'\n", data );
|
||||
|
||||
/* overflow name */
|
||||
val_count = 3;
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
strcpy( value, "xxxxxxxxxx" );
|
||||
strcpy( data, "xxxxxxxxxx" );
|
||||
res = RegEnumValueA( hkey_main, 0, value, &val_count, NULL, &type, data, &data_count );
|
||||
ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res );
|
||||
/* Win9x returns 2 as specified by MSDN but NT returns 3... */
|
||||
ok( val_count == 2 || val_count == 3, "val_count set to %ld\n", val_count );
|
||||
ok( data_count == 7, "data_count set to %ld instead of 7\n", data_count );
|
||||
ok( type == REG_SZ, "type %ld is not REG_SZ\n", type );
|
||||
#if 0
|
||||
/* v5.1.2600.0 (XP Home) does not touch value or data in this case */
|
||||
ok( !strcmp( value, "Te" ), "value set to '%s' instead of 'Te'\n", value );
|
||||
ok( !strcmp( data, "foobar" ), "data set to '%s' instead of 'foobar'\n", data );
|
||||
#endif
|
||||
|
||||
/* overflow empty name */
|
||||
val_count = 0;
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
strcpy( value, "xxxxxxxxxx" );
|
||||
strcpy( data, "xxxxxxxxxx" );
|
||||
res = RegEnumValueA( hkey_main, 0, value, &val_count, NULL, &type, data, &data_count );
|
||||
ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res );
|
||||
ok( val_count == 0, "val_count set to %ld\n", val_count );
|
||||
ok( data_count == 7, "data_count set to %ld instead of 7\n", data_count );
|
||||
ok( type == REG_SZ, "type %ld is not REG_SZ\n", type );
|
||||
ok( !strcmp( value, "xxxxxxxxxx" ), "value set to '%s'\n", value );
|
||||
#if 0
|
||||
/* v5.1.2600.0 (XP Home) does not touch data in this case */
|
||||
ok( !strcmp( data, "foobar" ), "data set to '%s' instead of 'foobar'\n", data );
|
||||
#endif
|
||||
|
||||
/* overflow data */
|
||||
val_count = 20;
|
||||
data_count = 2;
|
||||
type = 1234;
|
||||
strcpy( value, "xxxxxxxxxx" );
|
||||
strcpy( data, "xxxxxxxxxx" );
|
||||
res = RegEnumValueA( hkey_main, 0, value, &val_count, NULL, &type, data, &data_count );
|
||||
ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res );
|
||||
ok( val_count == 20, "val_count set to %ld\n", val_count );
|
||||
ok( data_count == 7, "data_count set to %ld instead of 7\n", data_count );
|
||||
ok( type == REG_SZ, "type %ld is not REG_SZ\n", type );
|
||||
ok( !strcmp( value, "xxxxxxxxxx" ), "value set to '%s'\n", value );
|
||||
ok( !strcmp( data, "xxxxxxxxxx" ), "data set to '%s'\n", data );
|
||||
|
||||
/* no overflow */
|
||||
val_count = 20;
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
strcpy( value, "xxxxxxxxxx" );
|
||||
strcpy( data, "xxxxxxxxxx" );
|
||||
res = RegEnumValueA( hkey_main, 0, value, &val_count, NULL, &type, data, &data_count );
|
||||
ok( res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", res );
|
||||
ok( val_count == 4, "val_count set to %ld instead of 4\n", val_count );
|
||||
ok( data_count == 7, "data_count set to %ld instead of 7\n", data_count );
|
||||
ok( type == REG_SZ, "type %ld is not REG_SZ\n", type );
|
||||
ok( !strcmp( value, "Test" ), "value is '%s' instead of Test\n", value );
|
||||
ok( !strcmp( data, "foobar" ), "data is '%s' instead of foobar\n", data );
|
||||
|
||||
/* Unicode tests */
|
||||
|
||||
SetLastError(0);
|
||||
res = RegSetValueExW( hkey_main, testW, 0, REG_SZ, (BYTE *)foobarW, 7*sizeof(WCHAR) );
|
||||
if (res==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
goto CLEANUP;
|
||||
ok( res == 0, "RegSetValueExW failed error %ld\n", res );
|
||||
|
||||
/* overflow both name and data */
|
||||
val_count = 2;
|
||||
data_count = 2;
|
||||
type = 1234;
|
||||
memcpy( valueW, xxxW, sizeof(xxxW) );
|
||||
memcpy( dataW, xxxW, sizeof(xxxW) );
|
||||
res = RegEnumValueW( hkey_main, 0, valueW, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
|
||||
ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res );
|
||||
ok( val_count == 2, "val_count set to %ld\n", val_count );
|
||||
ok( data_count == 7*sizeof(WCHAR), "data_count set to %ld instead of 7*sizeof(WCHAR)\n", data_count );
|
||||
ok( type == REG_SZ, "type %ld is not REG_SZ\n", type );
|
||||
ok( !memcmp( valueW, xxxW, sizeof(xxxW) ), "value modified\n" );
|
||||
ok( !memcmp( dataW, xxxW, sizeof(xxxW) ), "data modified\n" );
|
||||
|
||||
/* overflow name */
|
||||
val_count = 3;
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
memcpy( valueW, xxxW, sizeof(xxxW) );
|
||||
memcpy( dataW, xxxW, sizeof(xxxW) );
|
||||
res = RegEnumValueW( hkey_main, 0, valueW, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
|
||||
ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res );
|
||||
ok( val_count == 3, "val_count set to %ld\n", val_count );
|
||||
ok( data_count == 7*sizeof(WCHAR), "data_count set to %ld instead of 7*sizeof(WCHAR)\n", data_count );
|
||||
ok( type == REG_SZ, "type %ld is not REG_SZ\n", type );
|
||||
ok( !memcmp( valueW, xxxW, sizeof(xxxW) ), "value modified\n" );
|
||||
ok( !memcmp( dataW, xxxW, sizeof(xxxW) ), "data modified\n" );
|
||||
|
||||
/* overflow data */
|
||||
val_count = 20;
|
||||
data_count = 2;
|
||||
type = 1234;
|
||||
memcpy( valueW, xxxW, sizeof(xxxW) );
|
||||
memcpy( dataW, xxxW, sizeof(xxxW) );
|
||||
res = RegEnumValueW( hkey_main, 0, valueW, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
|
||||
ok( res == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %ld\n", res );
|
||||
ok( val_count == 4, "val_count set to %ld instead of 4\n", val_count );
|
||||
ok( data_count == 7*sizeof(WCHAR), "data_count set to %ld instead of 7*sizeof(WCHAR)\n", data_count );
|
||||
ok( type == REG_SZ, "type %ld is not REG_SZ\n", type );
|
||||
ok( !memcmp( valueW, testW, sizeof(testW) ), "value is not 'Test'\n" );
|
||||
ok( !memcmp( dataW, xxxW, sizeof(xxxW) ), "data modified\n" );
|
||||
|
||||
/* no overflow */
|
||||
val_count = 20;
|
||||
data_count = 20;
|
||||
type = 1234;
|
||||
memcpy( valueW, xxxW, sizeof(xxxW) );
|
||||
memcpy( dataW, xxxW, sizeof(xxxW) );
|
||||
res = RegEnumValueW( hkey_main, 0, valueW, &val_count, NULL, &type, (BYTE*)dataW, &data_count );
|
||||
ok( res == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", res );
|
||||
ok( val_count == 4, "val_count set to %ld instead of 4\n", val_count );
|
||||
ok( data_count == 7*sizeof(WCHAR), "data_count set to %ld instead of 7*sizeof(WCHAR)\n", data_count );
|
||||
ok( type == REG_SZ, "type %ld is not REG_SZ\n", type );
|
||||
ok( !memcmp( valueW, testW, sizeof(testW) ), "value is not 'Test'\n" );
|
||||
ok( !memcmp( dataW, foobarW, sizeof(foobarW) ), "data is not 'foobar'\n" );
|
||||
|
||||
CLEANUP:
|
||||
/* cleanup */
|
||||
RegDeleteValueA( hkey_main, "Test" );
|
||||
}
|
||||
|
||||
START_TEST(registry)
|
||||
{
|
||||
setup_main_key();
|
||||
test_enum_value();
|
||||
|
||||
/* cleanup */
|
||||
delete_key( hkey_main );
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/* Automatically generated file; DO NOT EDIT!! */
|
||||
|
||||
/* stdarg.h is needed for Winelib */
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
extern void func_registry(void);
|
||||
|
||||
struct test
|
||||
{
|
||||
const char *name;
|
||||
void (*func)(void);
|
||||
};
|
||||
|
||||
static const struct test winetest_testlist[] =
|
||||
{
|
||||
{ "registry", func_registry },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
#define WINETEST_WANT_MAIN
|
||||
#include "wine/test.h"
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: Makefile,v 1.7 2003/11/14 17:13:14 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = alive
|
||||
|
||||
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
|
|
@ -1,48 +0,0 @@
|
|||
/* $Id: alive.c,v 1.2 2001/03/26 21:30:20 ea Exp $
|
||||
*
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
HANDLE StandardOutput = INVALID_HANDLE_VALUE;
|
||||
CHAR Message [80];
|
||||
DWORD CharactersToWrite = 0;
|
||||
DWORD WrittenCharacters = 0;
|
||||
INT d = 0, h = 0, m = 0, s = 0;
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{
|
||||
StandardOutput = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||
if (INVALID_HANDLE_VALUE == StandardOutput)
|
||||
{
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
while (TRUE)
|
||||
{
|
||||
/* Prepare the message and update it */
|
||||
CharactersToWrite =
|
||||
wsprintf (
|
||||
Message,
|
||||
"Alive for %dd %dh %d' %d\" \r",
|
||||
d, h, m, s
|
||||
);
|
||||
WriteConsole (
|
||||
StandardOutput,
|
||||
Message,
|
||||
CharactersToWrite,
|
||||
& WrittenCharacters,
|
||||
NULL
|
||||
);
|
||||
/* suspend the execution for 1s */
|
||||
Sleep (1000);
|
||||
/* increment seconds */
|
||||
++ s;
|
||||
if (60 == s) { s = 0; ++ m; }
|
||||
if (60 == m) { m = 0; ++ h; }
|
||||
if (24 == h) { h = 0; ++ d; }
|
||||
}
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,213 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef AC_SRC_ALPHA
|
||||
#define AC_SRC_ALPHA (0x1)
|
||||
#endif
|
||||
|
||||
HINSTANCE HInst;
|
||||
const char* WndClassName = "GMainWnd";
|
||||
LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
|
||||
LPARAM LParam);
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
GdiAlphaBlend(HDC hdcDst,LONG DstX,LONG DstY,LONG DstCx,LONG DstCy,HDC hdcSrc,LONG SrcX,LONG SrcY,LONG SrcCx,LONG SrcCy,BLENDFUNCTION BlendFunction);
|
||||
|
||||
|
||||
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("AlphaBlend Rendering Demo"),
|
||||
WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION |
|
||||
WS_VISIBLE | WS_CLIPSIBLINGS,
|
||||
0, 0, 320, 430,
|
||||
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, HMemDC2 = NULL;
|
||||
HBITMAP HOldBmp = NULL;
|
||||
PVOID pBmpBits = NULL;
|
||||
HBITMAP H32BppBitmap = NULL;
|
||||
BITMAPINFO bmpi;
|
||||
|
||||
BOOL ConvertBitmapTo32Bpp(HDC hDC, BITMAP *bmp)
|
||||
{
|
||||
ZeroMemory(&bmpi, sizeof(BITMAPINFO));
|
||||
bmpi.bmiHeader.biSize = sizeof(BITMAPINFO);
|
||||
bmpi.bmiHeader.biWidth = bmp->bmWidth;
|
||||
bmpi.bmiHeader.biHeight = bmp->bmHeight;
|
||||
bmpi.bmiHeader.biPlanes = 1;
|
||||
bmpi.bmiHeader.biBitCount = 32;
|
||||
bmpi.bmiHeader.biCompression = BI_RGB;
|
||||
bmpi.bmiHeader.biSizeImage = 4 * bmpi.bmiHeader.biWidth * bmpi.bmiHeader.biHeight;
|
||||
H32BppBitmap = CreateDIBSection(hDC, &bmpi, DIB_RGB_COLORS, &pBmpBits, 0, 0);
|
||||
if(H32BppBitmap)
|
||||
{
|
||||
HBITMAP bmpalpha;
|
||||
SelectObject(hDC, H32BppBitmap);
|
||||
BitBlt(hDC, 0, 0, bmp->bmWidth, bmp->bmHeight, HMemDC, 0, 0, SRCCOPY);
|
||||
|
||||
/* load and apply alpha channel */
|
||||
bmpalpha = LoadImage(HInst, TEXT("lenaalpha.bmp"), IMAGE_BITMAP,
|
||||
0, 0, LR_LOADFROMFILE);
|
||||
if(bmpalpha)
|
||||
{
|
||||
COLORREF *col = pBmpBits;
|
||||
int x, y;
|
||||
HDC hdcTemp = CreateCompatibleDC(NULL);
|
||||
if(!hdcTemp)
|
||||
{
|
||||
DeleteObject(bmpalpha);
|
||||
return FALSE;
|
||||
}
|
||||
SelectObject(hdcTemp, bmpalpha);
|
||||
|
||||
for(y = 0; y < bmp->bmHeight; y++)
|
||||
{
|
||||
for(x = 0; x < bmp->bmWidth; x++)
|
||||
{
|
||||
COLORREF Color = (COLORREF)GetRValue(GetPixel(hdcTemp, x, y)) << 24;
|
||||
*col++ |= Color;
|
||||
}
|
||||
}
|
||||
|
||||
DeleteObject(bmpalpha);
|
||||
DeleteDC(hdcTemp);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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)
|
||||
);
|
||||
HMemDC2 = CreateCompatibleDC(NULL);
|
||||
if(!ConvertBitmapTo32Bpp(HMemDC2, &bmp))
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
BLENDFUNCTION BlendFunc;
|
||||
HDC Hdc = BeginPaint(HWnd, &ps);
|
||||
#if 0
|
||||
try
|
||||
#endif
|
||||
{
|
||||
|
||||
BlendFunc.BlendOp = AC_SRC_OVER;
|
||||
BlendFunc.BlendFlags = 0;
|
||||
BlendFunc.SourceConstantAlpha = 128;
|
||||
BlendFunc.AlphaFormat = 0;
|
||||
|
||||
BitBlt(Hdc, 100, 90,
|
||||
bmp.bmWidth, bmp.bmHeight,
|
||||
HMemDC2, 0, 0,
|
||||
SRCCOPY);
|
||||
GdiAlphaBlend(Hdc, 0, 0, bmp.bmWidth, bmp.bmHeight,
|
||||
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
|
||||
BlendFunc);
|
||||
GdiAlphaBlend(Hdc, bmp.bmWidth - 15, 10, bmp.bmWidth / 2, bmp.bmHeight / 2,
|
||||
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
|
||||
BlendFunc);
|
||||
|
||||
BlendFunc.SourceConstantAlpha = 255;
|
||||
BlendFunc.AlphaFormat = AC_SRC_ALPHA;
|
||||
|
||||
GdiAlphaBlend(Hdc, 140, 200, bmp.bmWidth, bmp.bmHeight,
|
||||
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
|
||||
BlendFunc);
|
||||
GdiAlphaBlend(Hdc, 20, 210, (bmp.bmWidth / 3) * 2, (bmp.bmHeight / 3) * 2,
|
||||
HMemDC2, 0, 0, bmp.bmWidth, bmp.bmHeight,
|
||||
BlendFunc);
|
||||
}
|
||||
#if 0
|
||||
catch (...)
|
||||
{
|
||||
EndPaint(HWnd, &ps);
|
||||
}
|
||||
#endif
|
||||
EndPaint(HWnd, &ps);
|
||||
break;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
/* clean up */
|
||||
DeleteObject(SelectObject(HMemDC, HOldBmp));
|
||||
DeleteDC(HMemDC);
|
||||
DeleteDC(HMemDC2);
|
||||
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return DefWindowProc(HWnd, Msg, WParam, LParam);
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 87 KiB |
Binary file not shown.
Before Width: | Height: | Size: 87 KiB |
|
@ -1,22 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = alphablend
|
||||
|
||||
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
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,94 +0,0 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <rosrtl/string.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
VOID STDCALL
|
||||
ApcRoutine(PVOID Context,
|
||||
PIO_STATUS_BLOCK IoStatus,
|
||||
ULONG Reserved)
|
||||
{
|
||||
printf("(apc.exe) ApcRoutine(Context %p)\n", Context);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
NTSTATUS Status;
|
||||
HANDLE FileHandle;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING FileName = ROS_STRING_INITIALIZER(L"\\C:\\a.txt");
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
CHAR Buffer[256];
|
||||
HANDLE EventHandle;
|
||||
LARGE_INTEGER off;
|
||||
|
||||
AllocConsole();
|
||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
printf("APC test program\n");
|
||||
|
||||
EventHandle = CreateEventW(NULL,
|
||||
FALSE,
|
||||
FALSE,
|
||||
NULL);
|
||||
if (EventHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("Failed to create event\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Opening file\n");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&FileName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
printf("Creating file\n");
|
||||
FileHandle = CreateFileW(L"C:\\a.txt",
|
||||
FILE_GENERIC_READ | FILE_GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
|
||||
if (FileHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
||||
printf("Open failed last err 0x%lu\n",GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
off.QuadPart = 0;
|
||||
|
||||
printf("Reading file\n");
|
||||
Status = ZwReadFile(FileHandle,
|
||||
NULL,
|
||||
(PIO_APC_ROUTINE)ApcRoutine,
|
||||
(PVOID) 0xdeadbeef,
|
||||
&IoStatus,
|
||||
Buffer,
|
||||
256,//len
|
||||
&off ,//offset must exist if file was opened for asynch. i/o aka. OVERLAPPED
|
||||
NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("Read failed status 0x%lu\n",Status);
|
||||
}
|
||||
printf("Waiting\n");
|
||||
WaitForSingleObjectEx(EventHandle, INFINITE, TRUE);
|
||||
printf("Returned from wait\n");
|
||||
ZwClose(FileHandle);
|
||||
printf("Program finished\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.10 2003/11/14 17:13:14 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = apc
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,53 +0,0 @@
|
|||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
VOID CALLBACK TimerApcProc(
|
||||
LPVOID lpArg,
|
||||
DWORD dwTimerLowValue,
|
||||
DWORD dwTimerHighValue )
|
||||
{
|
||||
printf("APC Callback %lu\n", *(PDWORD)lpArg);
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
HANDLE hTimer;
|
||||
BOOL bSuccess;
|
||||
LARGE_INTEGER DueTime;
|
||||
DWORD value = 1;
|
||||
|
||||
hTimer = CreateWaitableTimer(NULL, FALSE, NULL );
|
||||
|
||||
if (!hTimer)
|
||||
{
|
||||
printf("CreateWaitableTimer failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
DueTime.QuadPart = -(LONGLONG)(5 * 10000000);
|
||||
|
||||
bSuccess = SetWaitableTimer(
|
||||
hTimer,
|
||||
&DueTime,
|
||||
2001 /*interval (using an odd number to be able to find it easy in kmode) */,
|
||||
TimerApcProc,
|
||||
&value /*callback argument*/,
|
||||
FALSE );
|
||||
|
||||
if (!bSuccess)
|
||||
{
|
||||
printf("SetWaitableTimer failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (;value <= 10; value++ )
|
||||
{
|
||||
SleepEx(INFINITE, TRUE /*alertable*/ );
|
||||
}
|
||||
|
||||
CloseHandle( hTimer );
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = apc2
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,39 +0,0 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
AllocConsole();
|
||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
printf("GetCommandLineA() %s\n",GetCommandLineA());
|
||||
debug_printf("GetCommandLineA() %s\n",GetCommandLineA());
|
||||
debug_printf("argc %d\n", argc);
|
||||
for (i=0; i<argc; i++)
|
||||
{
|
||||
debug_printf("Argv[%d]: %x\n",i,argv[i]);
|
||||
debug_printf("Argv[%d]: '%s'\n",i,argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# $Id: makefile,v 1.16 2003/11/14 17:13:14 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = args
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,114 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#define BUFFER_SIZE 256
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
PRTL_ATOM_TABLE AtomTable = NULL;
|
||||
RTL_ATOM AtomA = -1, AtomB = -1, AtomC = -1;
|
||||
NTSTATUS Status;
|
||||
WCHAR Buffer[BUFFER_SIZE];
|
||||
ULONG NameLength, Data1, Data2;
|
||||
|
||||
printf("Atom table test app\n\n");
|
||||
|
||||
printf("RtlCreateAtomTable()\n");
|
||||
Status = RtlCreateAtomTable(37,
|
||||
&AtomTable);
|
||||
printf(" Status 0x%08lx\n", Status);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
printf(" AtomTable %p\n", AtomTable);
|
||||
|
||||
printf("RtlAddAtomToAtomTable()\n");
|
||||
Status = RtlAddAtomToAtomTable(AtomTable,
|
||||
L"TestAtomA",
|
||||
&AtomA);
|
||||
printf(" Status 0x%08lx\n", Status);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
printf(" AtomA 0x%x\n", AtomA);
|
||||
}
|
||||
|
||||
printf("RtlAddAtomToAtomTable()\n");
|
||||
Status = RtlAddAtomToAtomTable(AtomTable,
|
||||
L"TestAtomB",
|
||||
&AtomB);
|
||||
printf(" Status 0x%08lx\n", Status);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
printf(" AtomB 0x%x\n", AtomB);
|
||||
}
|
||||
|
||||
|
||||
printf("RtlLookupAtomInAtomTable()\n");
|
||||
Status = RtlLookupAtomInAtomTable(AtomTable,
|
||||
L"TestAtomA",
|
||||
&AtomC);
|
||||
printf(" Status 0x%08lx\n", Status);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
printf(" AtomC 0x%x\n", AtomC);
|
||||
}
|
||||
|
||||
|
||||
printf("RtlPinAtomInAtomTable()\n");
|
||||
Status = RtlPinAtomInAtomTable(AtomTable,
|
||||
AtomC);
|
||||
printf(" Status 0x%08lx\n", Status);
|
||||
|
||||
printf("RtlPinAtomInAtomTable()\n");
|
||||
Status = RtlPinAtomInAtomTable(AtomTable,
|
||||
AtomC);
|
||||
printf(" Status 0x%08lx\n", Status);
|
||||
|
||||
|
||||
// printf("RtlDeleteAtomFromAtomTable()\n");
|
||||
// Status = RtlDeleteAtomFromAtomTable(AtomTable,
|
||||
// AtomC);
|
||||
// printf(" Status 0x%08lx\n", Status);
|
||||
|
||||
|
||||
// printf("RtlEmptyAtomTable()\n");
|
||||
// Status = RtlEmptyAtomTable(AtomTable,
|
||||
// TRUE);
|
||||
// printf(" Status 0x%08lx\n", Status);
|
||||
|
||||
|
||||
// printf("RtlLookupAtomInAtomTable()\n");
|
||||
// Status = RtlLookupAtomInAtomTable(AtomTable,
|
||||
// L"TestAtomA",
|
||||
// &AtomC);
|
||||
// printf(" Status 0x%08lx\n", Status);
|
||||
|
||||
|
||||
printf("RtlQueryAtomInAtomTable()\n");
|
||||
NameLength = sizeof(WCHAR) * BUFFER_SIZE;
|
||||
Status = RtlQueryAtomInAtomTable(AtomTable,
|
||||
AtomC,
|
||||
&Data1,
|
||||
&Data2,
|
||||
Buffer,
|
||||
&NameLength);
|
||||
printf(" Status 0x%08lx\n", Status);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
printf(" RefCount %ld\n", Data1);
|
||||
printf(" PinCount %ld\n", Data2);
|
||||
printf(" NameLength %lu\n", NameLength);
|
||||
printf(" AtomName: %S\n", Buffer);
|
||||
}
|
||||
|
||||
printf("RtlDestroyAtomTable()\n");
|
||||
RtlDestroyAtomTable(AtomTable);
|
||||
|
||||
|
||||
printf("Atom table test app finished\n");
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
# $Id: makefile,v 1.6 2003/11/14 17:13:15 weiden Exp $
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = atomtest
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,8 +0,0 @@
|
|||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.11 2003/11/14 17:13:15 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,139 +0,0 @@
|
|||
|
||||
/*
|
||||
* 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);
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 87 KiB |
|
@ -1,22 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,107 +0,0 @@
|
|||
/* 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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,219 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,70 +0,0 @@
|
|||
/* $Id: capclock.c,v 1.4 2004/10/11 21:08:03 weiden 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 */
|
Binary file not shown.
Before Width: | Height: | Size: 766 B |
|
@ -1,20 +0,0 @@
|
|||
/* $Id: capclock.rc,v 1.2 2004/10/16 20:27:20 gvg 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
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
Binary file not shown.
Before Width: | Height: | Size: 106 B |
|
@ -1,150 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#include <defines.h>
|
||||
#include <reactos/resource.h>
|
||||
#include "resource.h"
|
||||
|
||||
IDB_CARET BITMAP DISCARDABLE "caret.bmp"
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:16 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = no
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = carets
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a gdi32.a ntdll.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1 +0,0 @@
|
|||
#define IDB_CARET 101
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,687 +0,0 @@
|
|||
/* 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;
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* 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++)) {}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#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
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,21 +0,0 @@
|
|||
# $Id: Makefile,v 1.8 2003/11/14 17:13:16 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,31 +0,0 @@
|
|||
#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);
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,21 +0,0 @@
|
|||
# $Id: Makefile,v 1.2 2003/11/14 17:13:16 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
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
|
|
@ -1,303 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:21 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = thread_msg
|
||||
|
||||
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
|
|
@ -1,97 +0,0 @@
|
|||
/**
|
||||
* Test case for PostThreadMessage
|
||||
* (C) 2003 ReactOS
|
||||
* License: LGPL
|
||||
* See: LGPL.txt in top directory.
|
||||
* Author: arty
|
||||
*
|
||||
* Windows thread message queue test case.
|
||||
* Derived from ../event/event.c in part.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
HANDLE hWaitForFailure;
|
||||
HANDLE hOkToPostThreadMessage;
|
||||
HANDLE hOkToTerminate;
|
||||
|
||||
DWORD WINAPI thread( LPVOID crap )
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
/* Failure case ... Wait for the parent to try to post a message
|
||||
before queue creation */
|
||||
printf( "Waiting to create the message queue.\n" );
|
||||
|
||||
WaitForSingleObject(hWaitForFailure,INFINITE);
|
||||
|
||||
printf( "Creating message queue.\n" );
|
||||
|
||||
/* "Create" a message queue */
|
||||
PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE );
|
||||
|
||||
printf( "Signalling the parent that we're ready.\n" );
|
||||
|
||||
/* Signal that it's ok to post */
|
||||
SetEvent( hOkToPostThreadMessage );
|
||||
|
||||
printf( "Listening messages.\n" );
|
||||
|
||||
/* Now read some messages */
|
||||
while( GetMessage( &msg, 0,0,0 ) ) {
|
||||
printf( "Received message: %04x %04x %08lx\n",
|
||||
(msg.message & 0xffff),
|
||||
(msg.wParam & 0xffff),
|
||||
msg.lParam );
|
||||
assert( !msg.hwnd );
|
||||
}
|
||||
|
||||
printf( "Finished receiving messages.\n" );
|
||||
SetEvent( hOkToTerminate );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
DWORD id;
|
||||
|
||||
printf( "Creating events\n" );
|
||||
|
||||
hOkToPostThreadMessage = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
hOkToTerminate = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
hWaitForFailure = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
|
||||
printf( "Created events\n" );
|
||||
|
||||
if( CreateThread( 0, 0, thread, 0, 0, &id ) == NULL ) {
|
||||
printf( "Couldn't create one thread.\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf( "Posting to non-existent queue\n" );
|
||||
|
||||
/* Check failure case */
|
||||
assert( PostThreadMessage( id, WM_USER + 0, 1, 2 ) == FALSE );
|
||||
|
||||
printf( "Signalling thread to advance.\n" );
|
||||
|
||||
SetEvent( hWaitForFailure );
|
||||
|
||||
printf( "Waiting for signal from thread.\n" );
|
||||
WaitForSingleObject( hOkToPostThreadMessage, INFINITE );
|
||||
|
||||
printf( "Sending three messages, then quit.\n" );
|
||||
assert( PostThreadMessage( id, WM_USER + 0, 1, 2 ) );
|
||||
assert( PostThreadMessage( id, WM_USER + 1, 3, 4 ) );
|
||||
Sleep( 500 ); /* Sleep a bit, so that the queue is empty for a bit. */
|
||||
assert( PostThreadMessage( id, WM_USER + 2, 5, 6 ) );
|
||||
assert( PostThreadMessage( id, WM_QUIT, 0,0 ) );
|
||||
|
||||
WaitForSingleObject( hOkToTerminate, INFINITE );
|
||||
printf( "Test complete.\n" );
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.2 2003/11/14 17:13:21 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = threadwait
|
||||
|
||||
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
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Author: Skywing (skywing@valhallalegends.com)
|
||||
* Date: 09/09/2003
|
||||
* Purpose: Probe for PsUnblockThread crash due to double-acquire spin lock.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
DWORD __stdcall threadfunc(void* UNREFERENCED)
|
||||
{
|
||||
printf("Thread: Initialized\n");
|
||||
Sleep(2500);
|
||||
printf("Thread: Terminating...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
DWORD id;
|
||||
HANDLE Thread;
|
||||
|
||||
Thread = CreateThread(0, 0, threadfunc, 0, 0, &id);
|
||||
printf("Main: ThreadId for new thread is %08lx\n", id);
|
||||
printf("Main: Waiting on thread...\n");
|
||||
WaitForSingleObject(Thread, INFINITE);
|
||||
printf("Main: OK, somebody fixed the PsUnblockThread spinlock double-acquire crash\n");
|
||||
NtClose(Thread);
|
||||
printf("Main: Terminating...\n");
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.1 2004/07/08 10:32:18 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = tmrqueue
|
||||
|
||||
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
|
|
@ -1,365 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#define N_TIMEOUT 3
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
typedef struct _TEST *PTEST;
|
||||
|
||||
typedef VOID (*PFNTEST)(PTEST Test, HANDLE hEvent);
|
||||
|
||||
typedef struct _TEST
|
||||
{
|
||||
TCHAR *description;
|
||||
BOOL Result;
|
||||
PFNTEST Routine;
|
||||
int id;
|
||||
} TEST;
|
||||
|
||||
static TEST Tests[3];
|
||||
|
||||
VOID RunTests(VOID)
|
||||
{
|
||||
int i, nTests;
|
||||
static HANDLE hEvent;
|
||||
|
||||
hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if(hEvent == NULL)
|
||||
{
|
||||
_tprintf(_T("Unable to create event!"));
|
||||
return;
|
||||
}
|
||||
|
||||
nTests = sizeof(Tests) / sizeof(TEST);
|
||||
|
||||
for(i = 0; i < nTests; i++)
|
||||
{
|
||||
Tests[i].id = i + 1;
|
||||
|
||||
if(Tests[i].Routine == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_tprintf(_T("+++ TEST %d: %s\n"), Tests[i].id, Tests[i].description);
|
||||
|
||||
Tests[i].Routine(&Tests[i], hEvent);
|
||||
|
||||
WaitForSingleObject(hEvent, INFINITE);
|
||||
|
||||
_tprintf(_T("\n\n"));
|
||||
}
|
||||
|
||||
CloseHandle(hEvent);
|
||||
}
|
||||
|
||||
VOID PrintTestResults(VOID)
|
||||
{
|
||||
int i, nTests, nsuccess = 0, nfailed = 0;
|
||||
TCHAR *status;
|
||||
|
||||
nTests = sizeof(Tests) / sizeof(TEST);
|
||||
|
||||
for(i = 0; i < nTests; i++)
|
||||
{
|
||||
if(Tests[i].Routine == NULL)
|
||||
{
|
||||
status = _T("SKIPPED");
|
||||
}
|
||||
else if(Tests[i].Result == TRUE)
|
||||
{
|
||||
status = _T("SUCCESS");
|
||||
nsuccess++;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = _T("FAILED ");
|
||||
nfailed++;
|
||||
}
|
||||
|
||||
_tprintf(_T("Test %d: %s %s\n"), i, status, Tests[i].description);
|
||||
}
|
||||
|
||||
_tprintf(_T("\nTests succeeded: %d, failed: %d\n"), nsuccess, nfailed);
|
||||
if(nfailed == 0)
|
||||
{
|
||||
_tprintf(_T(" ALL TESTS SUCCESSFUL!\n"));
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
typedef struct _TESTINFO
|
||||
{
|
||||
PTEST Test;
|
||||
int secsleft;
|
||||
HANDLE hTimer;
|
||||
HANDLE hEvent;
|
||||
/* additional stuff */
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
/* nothing */
|
||||
} Test1;
|
||||
struct
|
||||
{
|
||||
HANDLE hWaitEvent;
|
||||
} Test2;
|
||||
struct
|
||||
{
|
||||
HANDLE hWaitEvent;
|
||||
HANDLE hNotification;
|
||||
} Test3;
|
||||
};
|
||||
} TESTINFO, *PTESTINFO;
|
||||
|
||||
VOID CALLBACK TimerCallback1(PVOID Param, BOOLEAN Fired)
|
||||
{
|
||||
PTESTINFO Info = (PTESTINFO)Param;
|
||||
|
||||
_tprintf(_T("[%d]TimerCallback(0x%x, %d) called (%d)\n"), (int)Info->Test->id, (int)Info->hTimer, (int)Fired, --Info->secsleft);
|
||||
|
||||
if(Info->secsleft == 0)
|
||||
{
|
||||
BOOL stat;
|
||||
|
||||
_tprintf(_T("[%d]Timout finished, delete timer queue..."), (int)Info->Test->id);
|
||||
stat = DeleteTimerQueueTimer(NULL, Info->hTimer, NULL);
|
||||
if(stat)
|
||||
_tprintf(_T("returned OK -> test FAILED!\n"));
|
||||
else
|
||||
{
|
||||
int error = GetLastError();
|
||||
|
||||
switch(error)
|
||||
{
|
||||
case ERROR_IO_PENDING:
|
||||
_tprintf(_T("OK, Overlapped I/O operation in progress\n"));
|
||||
/* this test is only successful in this case */
|
||||
Info->Test->Result = TRUE;
|
||||
break;
|
||||
default:
|
||||
_tprintf(_T("Failed, LastError: %d\n"), (int)GetLastError());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the event to continue tests */
|
||||
SetEvent(Info->hEvent);
|
||||
}
|
||||
}
|
||||
|
||||
VOID Test1(PTEST Test, HANDLE hEvent)
|
||||
{
|
||||
static TESTINFO Info;
|
||||
|
||||
Info.Test = Test;
|
||||
Info.hEvent = hEvent;
|
||||
Info.secsleft = N_TIMEOUT;
|
||||
|
||||
if(!CreateTimerQueueTimer(&Info.hTimer, NULL, TimerCallback1, &Info, 1000, 1000, 0))
|
||||
{
|
||||
_tprintf(_T("[%d]CreateTimerQueueTimer() failed, LastError: %d!"), (int)Info.Test->id, (int)GetLastError());
|
||||
/* we failed, set the event to continue tests */
|
||||
SetEvent(hEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
_tprintf(_T("[%d]CreateTimerQueueTimer() created timer 0x%x, countdown (%d sec)...\n"), (int)Info.Test->id, (int)Info.hTimer, (int)Info.secsleft);
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
VOID CALLBACK TimerCallback2(PVOID Param, BOOLEAN Fired)
|
||||
{
|
||||
PTESTINFO Info = (PTESTINFO)Param;
|
||||
|
||||
_tprintf(_T("[%d]TimerCallback(0x%x, %d) called (%d)\n"), (int)Info->Test->id, (int)Info->hTimer, (int)Fired, --Info->secsleft);
|
||||
|
||||
if(Info->secsleft == 0)
|
||||
{
|
||||
/* set the event to continue tests */
|
||||
SetEvent(Info->Test2.hWaitEvent);
|
||||
|
||||
/* sleep a bit */
|
||||
Sleep(1500);
|
||||
}
|
||||
}
|
||||
|
||||
VOID Test2(PTEST Test, HANDLE hEvent)
|
||||
{
|
||||
static TESTINFO Info;
|
||||
BOOL stat;
|
||||
|
||||
Info.Test = Test;
|
||||
Info.hEvent = hEvent;
|
||||
Info.secsleft = N_TIMEOUT;
|
||||
|
||||
Info.Test2.hWaitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if(Info.Test2.hWaitEvent == NULL)
|
||||
{
|
||||
_tprintf(_T("[%d]Unable to create event!\n"), (int)Info.Test->id);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CreateTimerQueueTimer(&Info.hTimer, NULL, TimerCallback2, &Info, 1000, 1000, 0))
|
||||
{
|
||||
_tprintf(_T("[%d]CreateTimerQueueTimer() failed, LastError: %d!"), (int)Info.Test->id, (int)GetLastError());
|
||||
|
||||
CloseHandle(Info.Test2.hWaitEvent);
|
||||
/* we failed, set the event to continue tests */
|
||||
SetEvent(hEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
_tprintf(_T("[%d]CreateTimerQueueTimer() created timer 0x%x, countdown (%d sec)...\n"), (int)Test->id, (int)Info.hTimer, (int)Info.secsleft);
|
||||
|
||||
WaitForSingleObject(Info.Test2.hWaitEvent, INFINITE);
|
||||
|
||||
_tprintf(_T("[%d]Timout finished, delete timer queue..."), (int)Test->id);
|
||||
stat = DeleteTimerQueueTimer(NULL, Info.hTimer, INVALID_HANDLE_VALUE);
|
||||
if(stat)
|
||||
{
|
||||
_tprintf(_T("OK\n"));
|
||||
/* this test is only successful in this case */
|
||||
Test->Result = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
int error = GetLastError();
|
||||
|
||||
switch(error)
|
||||
{
|
||||
case ERROR_IO_PENDING:
|
||||
_tprintf(_T("FAILED, Overlapped I/O operation in progress\n"));
|
||||
break;
|
||||
default:
|
||||
_tprintf(_T("Failed, LastError: %d\n"), (int)GetLastError());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetEvent(Info.hEvent);
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
VOID CALLBACK TimerCallback3(PVOID Param, BOOLEAN Fired)
|
||||
{
|
||||
PTESTINFO Info = (PTESTINFO)Param;
|
||||
|
||||
_tprintf(_T("[%d]TimerCallback(0x%x, %d) called (%d)\n"), (int)Info->Test->id, (int)Info->hTimer, (int)Fired, --Info->secsleft);
|
||||
|
||||
if(Info->secsleft == 0)
|
||||
{
|
||||
/* set the event to continue tests */
|
||||
SetEvent(Info->Test3.hWaitEvent);
|
||||
|
||||
/* sleep a bit */
|
||||
Sleep(1500);
|
||||
}
|
||||
}
|
||||
|
||||
VOID Test3(PTEST Test, HANDLE hEvent)
|
||||
{
|
||||
static TESTINFO Info;
|
||||
BOOL stat;
|
||||
|
||||
Info.Test = Test;
|
||||
Info.hEvent = hEvent;
|
||||
Info.secsleft = N_TIMEOUT;
|
||||
|
||||
Info.Test3.hWaitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if(Info.Test3.hWaitEvent == NULL)
|
||||
{
|
||||
_tprintf(_T("[%d]Unable to create event!\n"), (int)Info.Test->id);
|
||||
return;
|
||||
}
|
||||
|
||||
Info.Test3.hNotification = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
if(Info.Test3.hNotification == NULL)
|
||||
{
|
||||
_tprintf(_T("[%d]Unable to create notification event!\n"), (int)Info.Test->id);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!CreateTimerQueueTimer(&Info.hTimer, NULL, TimerCallback3, &Info, 1000, 1000, 0))
|
||||
{
|
||||
_tprintf(_T("[%d]CreateTimerQueueTimer() failed, LastError: %d!"), (int)Info.Test->id, (int)GetLastError());
|
||||
|
||||
CloseHandle(Info.Test3.hWaitEvent);
|
||||
CloseHandle(Info.Test3.hNotification);
|
||||
/* we failed, set the event to continue tests */
|
||||
SetEvent(hEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
_tprintf(_T("[%d]CreateTimerQueueTimer() created timer 0x%x, countdown (%d sec)...\n"), (int)Test->id, (int)Info.hTimer, (int)Info.secsleft);
|
||||
|
||||
WaitForSingleObject(Info.Test3.hWaitEvent, INFINITE);
|
||||
|
||||
_tprintf(_T("[%d]Timout finished, delete timer queue..."), (int)Test->id);
|
||||
stat = DeleteTimerQueueTimer(NULL, Info.hTimer, Info.Test3.hNotification);
|
||||
if(stat)
|
||||
{
|
||||
_tprintf(_T("returned OK -> test FAILED!\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
int error = GetLastError();
|
||||
|
||||
switch(error)
|
||||
{
|
||||
case ERROR_IO_PENDING:
|
||||
_tprintf(_T("OK, Overlapped I/O operation in progress\n"));
|
||||
/* this test is only successful in this case */
|
||||
Test->Result = TRUE;
|
||||
break;
|
||||
default:
|
||||
_tprintf(_T("Failed, LastError: %d\n"), (int)GetLastError());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WaitForSingleObject(Info.Test3.hNotification, INFINITE);
|
||||
|
||||
CloseHandle(Info.Test3.hWaitEvent);
|
||||
CloseHandle(Info.Test3.hNotification);
|
||||
|
||||
SetEvent(Info.hEvent);
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
VOID
|
||||
InitTests(VOID)
|
||||
{
|
||||
ZeroMemory(Tests, sizeof(Tests));
|
||||
|
||||
Tests[0].description = _T("non-blocking DeleteTimerQueueTimer() call from callback");
|
||||
Tests[0].Routine = Test1;
|
||||
|
||||
Tests[1].description = _T("blocking DeleteTimerQueueTimer() call");
|
||||
Tests[1].Routine = Test2;
|
||||
|
||||
Tests[2].description = _T("blocking DeleteTimerQueueTimer() call with specified event");
|
||||
Tests[2].Routine = Test3;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
_tprintf(_T("+++ TimerQueue test running +++\n\n"));
|
||||
|
||||
InitTests();
|
||||
|
||||
RunTests();
|
||||
|
||||
_tprintf(_T("\n+++ RESULTS +++\n"));
|
||||
|
||||
PrintTestResults();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.3 2003/11/14 17:13:22 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = tokentst
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a
|
||||
|
||||
TARGET_OBJECTS = tokentest.o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror -Wno-format
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,529 +0,0 @@
|
|||
#define UNICODE
|
||||
#define _UNICODE
|
||||
|
||||
#define ANONYMOUSUNIONS
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define INCLUDE_THE_DDK_HEADERS
|
||||
#ifdef INCLUDE_THE_DDK_HEADERS
|
||||
#include <ddk/ntddk.h>
|
||||
#define ROS_ACE_HEADER ACE_HEADER
|
||||
#define ROS_ACE ACE
|
||||
|
||||
//
|
||||
// Allocate the System Luid. The first 1000 LUIDs are reserved.
|
||||
// Use #999 here (0x3E7 = 999)
|
||||
//
|
||||
|
||||
#define SYSTEM_LUID { 0x3E7, 0x0 }
|
||||
#define ANONYMOUS_LOGON_LUID { 0x3e6, 0x0 }
|
||||
#define LOCALSERVICE_LUID { 0x3e5, 0x0 }
|
||||
#define NETWORKSERVICE_LUID { 0x3e4, 0x0 }
|
||||
|
||||
#else
|
||||
typedef LONG NTSTATUS, *PNTSTATUS;
|
||||
|
||||
typedef struct _UNICODE_STRING
|
||||
{
|
||||
USHORT Length;
|
||||
USHORT MaximumLength;
|
||||
PWSTR Buffer;
|
||||
} UNICODE_STRING, *PUNICODE_STRING;
|
||||
|
||||
typedef struct _OBJECT_ATTRIBUTES {
|
||||
ULONG Length;
|
||||
HANDLE RootDirectory;
|
||||
PUNICODE_STRING ObjectName;
|
||||
ULONG Attributes;
|
||||
PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR
|
||||
PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE
|
||||
} OBJECT_ATTRIBUTES;
|
||||
typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES;
|
||||
|
||||
typedef struct _ROS_ACE_HEADER
|
||||
{
|
||||
CHAR AceType;
|
||||
CHAR AceFlags;
|
||||
USHORT AceSize;
|
||||
} ROS_ACE_HEADER, *PROS_ACE_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ACE_HEADER Header;
|
||||
ACCESS_MASK AccessMask;
|
||||
} ROS_ACE, *PROS_ACE;
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
RtlConvertSidToUnicodeString (
|
||||
IN OUT PUNICODE_STRING String,
|
||||
IN PSID Sid,
|
||||
IN BOOLEAN AllocateString
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
RtlCreateAcl(
|
||||
PACL Acl,
|
||||
ULONG AclSize,
|
||||
ULONG AclRevision);
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
RtlAddAccessAllowedAce (
|
||||
PACL Acl,
|
||||
ULONG Revision,
|
||||
ACCESS_MASK AccessMask,
|
||||
PSID Sid
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
RtlGetAce (
|
||||
PACL Acl,
|
||||
ULONG AceIndex,
|
||||
PROS_ACE *Ace
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ZwAllocateLocallyUniqueId(
|
||||
OUT PLUID Luid
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ZwCreateToken(
|
||||
OUT PHANDLE TokenHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN TOKEN_TYPE TokenType,
|
||||
IN PLUID AuthenticationId,
|
||||
IN PLARGE_INTEGER ExpirationTime,
|
||||
IN PTOKEN_USER TokenUser,
|
||||
IN PTOKEN_GROUPS TokenGroups,
|
||||
IN PTOKEN_PRIVILEGES TokenPrivileges,
|
||||
IN PTOKEN_OWNER TokenOwner,
|
||||
IN PTOKEN_PRIMARY_GROUP TokenPrimaryGroup,
|
||||
IN PTOKEN_DEFAULT_DACL TokenDefaultDacl,
|
||||
IN PTOKEN_SOURCE TokenSource
|
||||
);
|
||||
#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#define INITIAL_PRIV_ENABLED SE_PRIVILEGE_ENABLED_BY_DEFAULT|SE_PRIVILEGE_ENABLED
|
||||
#define INITIAL_PRIV_DISABLED 0
|
||||
LUID_AND_ATTRIBUTES InitialPrivilegeSet[] =
|
||||
{
|
||||
{ { 0x00000007, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeTcbPrivilege
|
||||
{ { 0x00000002, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeCreateTokenPrivilege
|
||||
{ { 0x00000009, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeTakeOwnershipPrivilege
|
||||
{ { 0x0000000f, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeCreatePagefilePrivilege
|
||||
{ { 0x00000004, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeLockMemoryPrivilege
|
||||
{ { 0x00000003, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeAssignPrimaryTokenPrivilege
|
||||
{ { 0x00000005, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeIncreaseQuotaPrivilege
|
||||
{ { 0x0000000e, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeIncreaseBasePriorityPrivilege
|
||||
{ { 0x00000010, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeCreatePermanentPrivilege
|
||||
{ { 0x00000014, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeDebugPrivilege
|
||||
{ { 0x00000015, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeAuditPrivilege
|
||||
{ { 0x00000008, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeSecurityPrivilege
|
||||
{ { 0x00000016, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeSystemEnvironmentPrivilege
|
||||
{ { 0x00000017, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeChangeNotifyPrivilege
|
||||
{ { 0x00000011, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeBackupPrivilege
|
||||
{ { 0x00000012, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeRestorePrivilege
|
||||
{ { 0x00000013, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeShutdownPrivilege
|
||||
{ { 0x0000000a, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeLoadDriverPrivilege
|
||||
{ { 0x0000000d, 0x00000000 }, INITIAL_PRIV_ENABLED }, // SeProfileSingleProcessPrivilege
|
||||
{ { 0x0000000c, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeSystemtimePrivilege
|
||||
{ { 0x00000019, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeUndockPrivilege
|
||||
{ { 0x0000001c, 0x00000000 }, INITIAL_PRIV_DISABLED }, // SeManageVolumePrivilege
|
||||
};
|
||||
|
||||
typedef struct _SID_2
|
||||
{
|
||||
UCHAR Revision;
|
||||
UCHAR SubAuthorityCount;
|
||||
SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
|
||||
ULONG SubAuthority[2];
|
||||
} SID_2;
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
void
|
||||
PrintSid(SID_AND_ATTRIBUTES* pSid, TOKEN_OWNER* pOwner, TOKEN_PRIMARY_GROUP* pPrimary)
|
||||
{
|
||||
UNICODE_STRING scSid;
|
||||
|
||||
RtlConvertSidToUnicodeString(&scSid, pSid->Sid, TRUE);
|
||||
printf("%wZ [", &scSid);
|
||||
LocalFree(scSid.Buffer);
|
||||
|
||||
if ( EqualSid(pSid->Sid, pOwner->Owner) )
|
||||
printf("owner,");
|
||||
|
||||
if ( EqualSid(pSid->Sid, pPrimary->PrimaryGroup) )
|
||||
printf("primary,");
|
||||
|
||||
if ( pSid->Attributes & SE_GROUP_ENABLED )
|
||||
{
|
||||
if ( pSid->Attributes & SE_GROUP_ENABLED_BY_DEFAULT )
|
||||
printf("enabled-default,");
|
||||
else
|
||||
printf("enabled,");
|
||||
}
|
||||
|
||||
if ( pSid->Attributes & SE_GROUP_LOGON_ID )
|
||||
printf("logon,");
|
||||
|
||||
|
||||
if ( pSid->Attributes & SE_GROUP_MANDATORY )
|
||||
printf("mandatory,");
|
||||
|
||||
printf("]\n");
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
void
|
||||
DisplayTokenSids(TOKEN_USER* pUser,
|
||||
TOKEN_GROUPS* pGroups,
|
||||
TOKEN_OWNER* pOwner,
|
||||
TOKEN_PRIMARY_GROUP* pPrimary)
|
||||
{
|
||||
DWORD i;
|
||||
|
||||
printf("\nSids:\n");
|
||||
PrintSid(&pUser->User, pOwner, pPrimary);
|
||||
printf("\nGroups:\n");
|
||||
for (i = 0; i < pGroups->GroupCount; i++)
|
||||
PrintSid(&pGroups->Groups[i], pOwner, pPrimary);
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
void
|
||||
DisplayTokenPrivileges(TOKEN_PRIVILEGES* pPriv)
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
DWORD i;
|
||||
|
||||
printf("\nprivileges:\n");
|
||||
for (i = 0; i < pPriv->PrivilegeCount; i++)
|
||||
{
|
||||
DWORD cbName = sizeof(buffer) / sizeof(buffer[0]);
|
||||
LookupPrivilegeName(0, &pPriv->Privileges[i].Luid, buffer, &cbName);
|
||||
|
||||
printf("%S{0x%08x, 0x%08x} [", buffer, pPriv->Privileges[i].Luid.HighPart, pPriv->Privileges[i].Luid.LowPart);
|
||||
|
||||
if ( pPriv->Privileges[i].Attributes & SE_PRIVILEGE_ENABLED )
|
||||
printf("enabled,");
|
||||
if ( pPriv->Privileges[i].Attributes & SE_PRIVILEGE_ENABLED_BY_DEFAULT )
|
||||
printf("default,");
|
||||
if ( pPriv->Privileges[i].Attributes & SE_PRIVILEGE_USED_FOR_ACCESS )
|
||||
printf("used");
|
||||
|
||||
printf("]\n");
|
||||
}
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
void
|
||||
DisplayDacl(PACL pAcl)
|
||||
{
|
||||
DWORD i;
|
||||
NTSTATUS status;
|
||||
|
||||
if ( ! pAcl )
|
||||
{
|
||||
printf("\nNo Default Dacl.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\nDacl:\n");
|
||||
for (i = 0; i < pAcl->AceCount; i++)
|
||||
{
|
||||
UNICODE_STRING scSid;
|
||||
ROS_ACE* pAce;
|
||||
LPWSTR wszType = 0;
|
||||
PSID pSid;
|
||||
|
||||
status = RtlGetAce(pAcl, i, (ROS_ACE**) &pAce);
|
||||
if ( ! NT_SUCCESS(status) )
|
||||
{
|
||||
printf("RtlGetAce(): status = 0x%08x\n", status);
|
||||
break;
|
||||
}
|
||||
|
||||
pSid = (PSID) (pAce + 1);
|
||||
if ( pAce->Header.AceType == ACCESS_ALLOWED_ACE_TYPE )
|
||||
wszType = L"allow";
|
||||
if ( pAce->Header.AceType == ACCESS_DENIED_ACE_TYPE )
|
||||
wszType = L"deny ";
|
||||
|
||||
status = RtlConvertSidToUnicodeString(&scSid, pSid, TRUE);
|
||||
if ( ! NT_SUCCESS(status) )
|
||||
{
|
||||
printf("RtlConvertSidToUnicodeString(): status = 0x%08x\n", status);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("%d.) %S %wZ 0x%08x\n", i, wszType, &scSid, pAce->AccessMask);
|
||||
LocalFree(scSid.Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
PVOID
|
||||
GetFromToken(HANDLE hToken, TOKEN_INFORMATION_CLASS tic)
|
||||
{
|
||||
BOOL bResult;
|
||||
DWORD n;
|
||||
PBYTE p = 0;
|
||||
|
||||
bResult = GetTokenInformation(hToken, tic, 0, 0, &n);
|
||||
if ( ! bResult && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
return 0;
|
||||
|
||||
p = (PBYTE) malloc(n);
|
||||
if ( ! GetTokenInformation(hToken, tic, p, n, &n) )
|
||||
{
|
||||
printf("GetFromToken() failed for TOKEN_INFORMATION_CLASS(%d): %d\n", tic, GetLastError());
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
void
|
||||
DisplayToken(HANDLE hTokenSource)
|
||||
{
|
||||
TOKEN_USER* pTokenUser = (PTOKEN_USER) GetFromToken(hTokenSource, TokenUser);
|
||||
TOKEN_GROUPS* pTokenGroups = (PTOKEN_GROUPS) GetFromToken(hTokenSource, TokenGroups);
|
||||
TOKEN_OWNER* pTokenOwner = (PTOKEN_OWNER) GetFromToken(hTokenSource, TokenOwner);
|
||||
TOKEN_PRIMARY_GROUP* pTokenPrimaryGroup = (PTOKEN_PRIMARY_GROUP) GetFromToken(hTokenSource, TokenPrimaryGroup);
|
||||
TOKEN_PRIVILEGES* pTokenPrivileges = (PTOKEN_PRIVILEGES) GetFromToken(hTokenSource, TokenPrivileges);
|
||||
TOKEN_DEFAULT_DACL* pTokenDefaultDacl = (PTOKEN_DEFAULT_DACL) GetFromToken(hTokenSource, TokenDefaultDacl);
|
||||
|
||||
DisplayTokenSids(pTokenUser, pTokenGroups, pTokenOwner, pTokenPrimaryGroup);
|
||||
// DisplayTokenPrivileges(pTokenPrivileges);
|
||||
DisplayDacl(pTokenDefaultDacl->DefaultDacl);
|
||||
|
||||
free(pTokenUser);
|
||||
free(pTokenGroups);
|
||||
free(pTokenOwner);
|
||||
free(pTokenPrimaryGroup);
|
||||
free(pTokenPrivileges);
|
||||
free(pTokenDefaultDacl);
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
BOOL
|
||||
EnablePrivilege(LPWSTR wszName)
|
||||
{
|
||||
HANDLE hToken;
|
||||
TOKEN_PRIVILEGES priv = {1, {{{0, 0}, SE_PRIVILEGE_ENABLED}}};
|
||||
BOOL bResult;
|
||||
|
||||
LookupPrivilegeValue(0, wszName, &priv.Privileges[0].Luid);
|
||||
|
||||
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken);
|
||||
|
||||
AdjustTokenPrivileges(hToken, FALSE, &priv, sizeof priv, 0, 0);
|
||||
bResult = GetLastError() == ERROR_SUCCESS;
|
||||
|
||||
CloseHandle(hToken);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
NTSTATUS
|
||||
CreateInitialSystemToken(HANDLE* phSystemToken)
|
||||
{
|
||||
static SID sidSystem = { 1, 1, {SECURITY_NT_AUTHORITY}, {SECURITY_LOCAL_SYSTEM_RID} };
|
||||
static SID sidEveryone = { 1, 1, {SECURITY_WORLD_SID_AUTHORITY}, {SECURITY_WORLD_RID} };
|
||||
static SID sidAuthenticatedUser = { 1, 1, {SECURITY_NT_AUTHORITY}, {SECURITY_AUTHENTICATED_USER_RID} };
|
||||
static SID_2 sidAdministrators = { 1, 2, {SECURITY_NT_AUTHORITY}, {SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS} };
|
||||
static const int nGroupCount = 3;
|
||||
|
||||
NTSTATUS status;
|
||||
ULONG uSize;
|
||||
DWORD i;
|
||||
|
||||
TOKEN_USER tkUser;
|
||||
TOKEN_OWNER tkDefaultOwner;
|
||||
TOKEN_PRIMARY_GROUP tkPrimaryGroup;
|
||||
|
||||
TOKEN_GROUPS* ptkGroups = 0;
|
||||
TOKEN_PRIVILEGES* ptkPrivileges = 0;
|
||||
TOKEN_DEFAULT_DACL tkDefaultDacl = { 0 };
|
||||
|
||||
LARGE_INTEGER tkExpiration;
|
||||
|
||||
LUID authId = SYSTEM_LUID;
|
||||
|
||||
TOKEN_SOURCE source =
|
||||
{
|
||||
{ '*', '*', 'A', 'N', 'O', 'N', '*', '*' },
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
SECURITY_QUALITY_OF_SERVICE sqos =
|
||||
{
|
||||
sizeof(sqos),
|
||||
SecurityAnonymous,
|
||||
SECURITY_STATIC_TRACKING,
|
||||
FALSE
|
||||
};
|
||||
|
||||
OBJECT_ATTRIBUTES oa =
|
||||
{
|
||||
sizeof(oa),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
&sqos
|
||||
};
|
||||
|
||||
tkExpiration.QuadPart = -1;
|
||||
status = ZwAllocateLocallyUniqueId(&source.SourceIdentifier);
|
||||
if ( status != 0 )
|
||||
return status;
|
||||
|
||||
tkUser.User.Sid = &sidSystem;
|
||||
tkUser.User.Attributes = 0;
|
||||
|
||||
// Under WinXP (the only MS OS I've tested) ZwCreateToken()
|
||||
// squawks if we use sidAdministrators here -- though running
|
||||
// a progrem under AT and using the DisplayToken() function
|
||||
// shows that the system token does default ownership to
|
||||
// Administrator.
|
||||
|
||||
// For now, default ownership to system, since that works
|
||||
tkDefaultOwner.Owner = &sidSystem;
|
||||
tkPrimaryGroup.PrimaryGroup = &sidSystem;
|
||||
|
||||
uSize = sizeof(TOKEN_GROUPS) - sizeof(ptkGroups->Groups);
|
||||
uSize += sizeof(SID_AND_ATTRIBUTES) * nGroupCount;
|
||||
|
||||
ptkGroups = (TOKEN_GROUPS*) malloc(uSize);
|
||||
ptkGroups->GroupCount = nGroupCount;
|
||||
|
||||
ptkGroups->Groups[0].Sid = (SID*) &sidAdministrators;
|
||||
ptkGroups->Groups[0].Attributes = SE_GROUP_ENABLED;
|
||||
|
||||
ptkGroups->Groups[1].Sid = &sidEveryone;
|
||||
ptkGroups->Groups[1].Attributes = SE_GROUP_ENABLED|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_MANDATORY;
|
||||
|
||||
ptkGroups->Groups[2].Sid = &sidAuthenticatedUser;
|
||||
ptkGroups->Groups[2].Attributes = SE_GROUP_ENABLED|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_MANDATORY;
|
||||
|
||||
uSize = sizeof(TOKEN_PRIVILEGES) - sizeof(ptkPrivileges->Privileges);
|
||||
uSize += sizeof(LUID_AND_ATTRIBUTES) * sizeof(InitialPrivilegeSet) / sizeof(InitialPrivilegeSet[0]);
|
||||
ptkPrivileges = (TOKEN_PRIVILEGES*) malloc(uSize);
|
||||
ptkPrivileges->PrivilegeCount = sizeof(InitialPrivilegeSet) / sizeof(InitialPrivilegeSet[0]);
|
||||
for (i = 0; i < ptkPrivileges->PrivilegeCount; i++)
|
||||
{
|
||||
ptkPrivileges->Privileges[i].Luid.HighPart = InitialPrivilegeSet[i].Luid.HighPart;
|
||||
ptkPrivileges->Privileges[i].Luid.LowPart = InitialPrivilegeSet[i].Luid.LowPart;
|
||||
ptkPrivileges->Privileges[i].Attributes = InitialPrivilegeSet[i].Attributes;
|
||||
}
|
||||
|
||||
// Calculate the length needed for the ACL
|
||||
uSize = sizeof(ACL);
|
||||
uSize += sizeof(ACE) + sizeof(sidSystem);
|
||||
uSize += sizeof(ACE) + sizeof(sidAdministrators);
|
||||
uSize = (uSize & (~3)) + 8;
|
||||
tkDefaultDacl.DefaultDacl = (PACL) malloc(uSize);
|
||||
|
||||
status = RtlCreateAcl(tkDefaultDacl.DefaultDacl, uSize, ACL_REVISION);
|
||||
if ( ! NT_SUCCESS(status) )
|
||||
printf("RtlCreateAcl() failed: 0x%08x\n", status);
|
||||
|
||||
status = RtlAddAccessAllowedAce(tkDefaultDacl.DefaultDacl, ACL_REVISION, GENERIC_ALL, &sidSystem);
|
||||
if ( ! NT_SUCCESS(status) )
|
||||
printf("RtlAddAccessAllowedAce() failed: 0x%08x\n", status);
|
||||
|
||||
status = RtlAddAccessAllowedAce(tkDefaultDacl.DefaultDacl, ACL_REVISION, GENERIC_READ|GENERIC_EXECUTE|READ_CONTROL, (PSID) &sidAdministrators);
|
||||
if ( ! NT_SUCCESS(status) )
|
||||
printf("RtlAddAccessAllowedAce() failed: 0x%08x\n", status);
|
||||
|
||||
printf("Parameters being passed into ZwCreateToken:\n\n");
|
||||
DisplayTokenSids(&tkUser, ptkGroups, &tkDefaultOwner, &tkPrimaryGroup);
|
||||
DisplayDacl(tkDefaultDacl.DefaultDacl);
|
||||
|
||||
printf("Calling ZwCreateToken()...\n");
|
||||
status = ZwCreateToken(phSystemToken,
|
||||
TOKEN_ALL_ACCESS,
|
||||
&oa,
|
||||
TokenPrimary,
|
||||
&authId,
|
||||
&tkExpiration,
|
||||
&tkUser,
|
||||
ptkGroups,
|
||||
ptkPrivileges,
|
||||
&tkDefaultOwner,
|
||||
&tkPrimaryGroup,
|
||||
&tkDefaultDacl,
|
||||
&source);
|
||||
|
||||
// Cleanup
|
||||
free(ptkGroups);
|
||||
free(ptkPrivileges);
|
||||
free(tkDefaultDacl.DefaultDacl);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
NTSTATUS Status;
|
||||
HANDLE hSystemToken;
|
||||
CHAR buffer[512];
|
||||
HANDLE hOurToken;
|
||||
|
||||
printf("Current process Token:\n");
|
||||
|
||||
Status=ZwOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY|TOKEN_QUERY_SOURCE, &hOurToken);
|
||||
if ( NT_SUCCESS(Status) )
|
||||
{
|
||||
DisplayToken(hOurToken);
|
||||
CloseHandle(hOurToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ZwOpenProcessToken() failed: 0x%08x\n", Status);
|
||||
}
|
||||
|
||||
//#define ENABLE_PRIVILEGE
|
||||
#ifdef ENABLE_PRIVILEGE
|
||||
EnablePrivilege(SE_CREATE_TOKEN_NAME);
|
||||
#endif
|
||||
|
||||
// Now do the other one
|
||||
Status = CreateInitialSystemToken(&hSystemToken);
|
||||
if ( NT_SUCCESS(Status) )
|
||||
{
|
||||
printf("System Token: 0x%08x\n", hSystemToken);
|
||||
DisplayToken(hSystemToken);
|
||||
CloseHandle(hSystemToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CreateInitialSystemToken() return: 0x%08x\n", Status);
|
||||
}
|
||||
|
||||
printf("press return");
|
||||
gets(buffer);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,33 +0,0 @@
|
|||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = txtscale
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_CFLAGS = -fexceptions -g -O0 -DWIN32 -D_DEBUG -D_WINDOWS -D_MBCS -W -D__USE_W32API -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -Wall -Werror
|
||||
|
||||
TARGET_CPPFLAGS = -fexceptions -g -O0 -DWIN32 -D_DEBUG -D_WINDOWS -D_MBCS -W -D__USE_W32API -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -Wall -Werror
|
||||
|
||||
TARGET_SDKLIBS = \
|
||||
kernel32.a \
|
||||
user32.a \
|
||||
gdi32.a \
|
||||
comctl32.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
txtscale.o \
|
||||
mk_font.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# overide LD_CC to use g++ for linking of the executable
|
||||
LD_CC = $(CXX)
|
||||
|
||||
# EOF
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 4 - Utility functions
|
||||
//
|
||||
// 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>
|
||||
|
||||
#include "mk_font.h"
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
namespace font {
|
||||
|
||||
// creates a logical font
|
||||
HFONT MakeFont(
|
||||
IN HDC hDestDC, // handle to target DC
|
||||
IN LPCSTR typeface_name, // font's typeface name
|
||||
IN int point_size, // font's point size
|
||||
IN const BYTE charset, // font's character set
|
||||
IN const DWORD style // font's styles
|
||||
)
|
||||
{
|
||||
//
|
||||
// NOTE: On Windows 9x/Me, GetWorldTransform is not
|
||||
// supported. For compatibility with these platforms you
|
||||
// should initialize the XFORM::eM22 data member to 1.0.
|
||||
//
|
||||
XFORM xf = {0, 0, 0, 1.0, 0, 0};
|
||||
GetWorldTransform(hDestDC, &xf);
|
||||
int pixels_per_inch = GetDeviceCaps(hDestDC, LOGPIXELSY);
|
||||
|
||||
POINT PSize = {
|
||||
0,
|
||||
-MulDiv(static_cast<int>(xf.eM22 * point_size + 0.5),
|
||||
pixels_per_inch, 72)
|
||||
};
|
||||
|
||||
HFONT hResult = NULL;
|
||||
if (DPtoLP(hDestDC, &PSize, 1))
|
||||
{
|
||||
LOGFONT lf;
|
||||
memset(&lf, 0, sizeof(LOGFONT));
|
||||
|
||||
lf.lfHeight = PSize.y;
|
||||
lf.lfCharSet = charset;
|
||||
lstrcpyn(reinterpret_cast<LPTSTR>(&lf.lfFaceName),
|
||||
typeface_name, LF_FACESIZE);
|
||||
|
||||
lf.lfWeight = (style & FS_BOLD) ? FW_BOLD : FW_DONTCARE;
|
||||
lf.lfItalic = (style & FS_ITALIC) ? true : false;
|
||||
lf.lfUnderline = (style & FS_UNDERLINE) ? true : false;
|
||||
lf.lfStrikeOut = (style & FS_STRIKEOUT) ? true : false;
|
||||
|
||||
// create the logical font
|
||||
hResult = CreateFontIndirect(&lf);
|
||||
}
|
||||
return hResult;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
} // namespace font
|
|
@ -1,39 +0,0 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 4 - Utility functions
|
||||
//
|
||||
// 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.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
#ifndef CH4_UTILS_H
|
||||
#define CH4_UTILS_H
|
||||
|
||||
#include <windows.h>
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
// change namespace name appropriately to suit your needs
|
||||
namespace font {
|
||||
|
||||
// font options
|
||||
static const ULONG FS_NONE = 0x00000000;
|
||||
static const ULONG FS_BOLD = 0x00000001;
|
||||
static const ULONG FS_ITALIC = 0x00000002;
|
||||
static const ULONG FS_UNDERLINE = 0x00000004;
|
||||
static const ULONG FS_STRIKEOUT = 0x00000008;
|
||||
|
||||
// creates a logical font
|
||||
HFONT MakeFont(IN HDC hDestDC, IN LPCSTR typeface_name,
|
||||
IN int point_size, IN const BYTE charset = ANSI_CHARSET,
|
||||
IN const DWORD style = FS_NONE);
|
||||
|
||||
}
|
||||
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
#endif // CH4_UTILS_H
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
@ -1,266 +0,0 @@
|
|||
|
||||
// ------------------------------------------------------------------
|
||||
// Windows 2000 Graphics API Black Book
|
||||
// Chapter 8 - Listing 8.1 (Scaled Text 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 <commctrl.h>
|
||||
#include <cassert>
|
||||
|
||||
// for the MakeFont() function...
|
||||
#include "mk_font.h"
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
|
||||
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_HREDRAW | CS_VREDRAW;
|
||||
wc.lpszClassName = WndClassName;
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.hInstance = hInst;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = reinterpret_cast<HBRUSH>(
|
||||
COLOR_BTNFACE + 1
|
||||
);
|
||||
|
||||
if (RegisterClass(&wc))
|
||||
{
|
||||
HWND hWnd =
|
||||
CreateWindow(
|
||||
WndClassName, TEXT("Scaled Text Demo"),
|
||||
WS_OVERLAPPEDWINDOW | WS_CAPTION |
|
||||
WS_VISIBLE | WS_CLIPCHILDREN,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 800, 300,
|
||||
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;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
HWND hTrackBar = NULL;
|
||||
HFONT hTTFont = NULL;
|
||||
double scale = 0.0;
|
||||
LPCSTR pText = TEXT("The Scaled Text!");
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
INITCOMMONCONTROLSEX icx;
|
||||
icx.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icx.dwICC = ICC_BAR_CLASSES;
|
||||
|
||||
InitCommonControlsEx(&icx);
|
||||
|
||||
hTrackBar =
|
||||
CreateWindow(
|
||||
TRACKBAR_CLASS, "",
|
||||
TBS_HORZ | TBS_BOTH | TBS_AUTOTICKS |
|
||||
TBS_FIXEDLENGTH | TBS_ENABLESELRANGE |
|
||||
WS_CHILD | WS_VISIBLE,
|
||||
10, 260, 375, 40,
|
||||
hWnd, NULL, hInst, NULL
|
||||
);
|
||||
|
||||
assert(hTrackBar != NULL);
|
||||
SNDMSG(hTrackBar, TBM_SETTHUMBLENGTH, 20, 0);
|
||||
SNDMSG(hTrackBar, TBM_SETRANGEMAX, TRUE, 100);
|
||||
|
||||
// create the TrueType (scalable) font
|
||||
HDC hDC = GetDC(hWnd);
|
||||
try
|
||||
{
|
||||
// see Chapter 4 for the definition of MakeFont
|
||||
hTTFont = font::MakeFont(hDC, "Impact", 72);
|
||||
if (!hTTFont) throw;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ReleaseDC(hWnd, hDC);
|
||||
}
|
||||
ReleaseDC(hWnd, hDC);
|
||||
break;
|
||||
}
|
||||
case WM_HSCROLL:
|
||||
{
|
||||
if (reinterpret_cast<HWND>(lParam) == hTrackBar)
|
||||
{
|
||||
//
|
||||
// adjust the scaling factor according to
|
||||
// the position of the trackbar's slider
|
||||
//
|
||||
scale = static_cast<double>(
|
||||
(SNDMSG(hTrackBar, TBM_GETPOS, 0, 0) + 1) / 50.0
|
||||
);
|
||||
InvalidateRect(hWnd, NULL, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
LRESULT res = DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
|
||||
HDC hDC = reinterpret_cast<HDC>(wParam);
|
||||
HFONT hOldFont = static_cast<HFONT>(
|
||||
SelectObject(hDC, hTTFont)
|
||||
);
|
||||
try
|
||||
{
|
||||
SetBkMode(hDC, TRANSPARENT);
|
||||
|
||||
// open a path bracket
|
||||
if (!BeginPath(hDC)) throw;
|
||||
|
||||
// record the text to the path
|
||||
TextOut(hDC, 10, 10, pText, lstrlen(pText));
|
||||
|
||||
// close the path bracket and
|
||||
// select the path into hDC
|
||||
EndPath(hDC);
|
||||
|
||||
// determine the number of endpoints in the path
|
||||
const int num_points = GetPath(hDC, NULL, NULL, 0);
|
||||
if (num_points > 0)
|
||||
{
|
||||
// make room for the POINTs and vertex types
|
||||
POINT* pPEnds = new POINT[num_points];
|
||||
unsigned char* pTypes = new unsigned char[num_points];
|
||||
try
|
||||
{
|
||||
// get the path's description
|
||||
int num_got = GetPath(hDC, pPEnds, pTypes, num_points);
|
||||
if (num_got > 0)
|
||||
{
|
||||
// start a new path bracket
|
||||
if (!BeginPath(hDC)) throw;
|
||||
|
||||
// scale each point in the description
|
||||
int iPoint;
|
||||
for (iPoint = 0; iPoint < num_got; ++iPoint)
|
||||
{
|
||||
pPEnds[iPoint].x = static_cast<LONG>(
|
||||
scale * pPEnds[iPoint].x + 0.5
|
||||
);
|
||||
pPEnds[iPoint].y = static_cast<LONG>(
|
||||
scale * pPEnds[iPoint].y + 0.5
|
||||
);
|
||||
}
|
||||
|
||||
for (iPoint = 0; iPoint < num_points; ++iPoint)
|
||||
{
|
||||
// handle the MoveToEx case
|
||||
if (pTypes[iPoint] == PT_MOVETO)
|
||||
{
|
||||
MoveToEx(
|
||||
hDC, pPEnds[iPoint].x, pPEnds[iPoint].y, NULL
|
||||
);
|
||||
}
|
||||
// handle the LineTo case
|
||||
else if (
|
||||
pTypes[iPoint] == PT_LINETO ||
|
||||
pTypes[iPoint] == (PT_LINETO | PT_CLOSEFIGURE)
|
||||
)
|
||||
{
|
||||
LineTo(hDC, pPEnds[iPoint].x, pPEnds[iPoint].y);
|
||||
}
|
||||
// handle the PolyBezierTo case
|
||||
else if (
|
||||
pTypes[iPoint] == PT_BEZIERTO ||
|
||||
pTypes[iPoint] == (PT_BEZIERTO | PT_CLOSEFIGURE)
|
||||
)
|
||||
{
|
||||
PolyBezierTo(hDC, pPEnds + iPoint, 3);
|
||||
iPoint += 2;
|
||||
}
|
||||
}
|
||||
|
||||
// close the new path bracket
|
||||
EndPath(hDC);
|
||||
|
||||
// stroke and fill the new path
|
||||
StrokeAndFillPath(hDC);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// clean up
|
||||
delete [] pTypes;
|
||||
delete [] pPEnds;
|
||||
throw;
|
||||
}
|
||||
// clean up
|
||||
delete [] pTypes;
|
||||
delete [] pPEnds;
|
||||
}
|
||||
// ...
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
SelectObject(hDC, hOldFont);
|
||||
}
|
||||
SelectObject(hDC, hOldFont);
|
||||
return res;
|
||||
}
|
||||
case WM_SIZE:
|
||||
{
|
||||
MoveWindow(
|
||||
hTrackBar,
|
||||
0, HIWORD(lParam) - 40, LOWORD(lParam), 40,
|
||||
false
|
||||
);
|
||||
break;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
// clean up
|
||||
DeleteObject(hTTFont);
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,478 +0,0 @@
|
|||
/* Unit test suite for window classes.
|
||||
*
|
||||
* Copyright 2002 Mike McCormack
|
||||
* Copyright 2003 Alexandre Julliard
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* To get CS_DROPSHADOW with the MSVC headers */
|
||||
#define _WIN32_WINNT 0x0501
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winreg.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
|
||||
#define NUMCLASSWORDS 4
|
||||
|
||||
static LRESULT WINAPI ClassTest_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
return DefWindowProcW (hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*/
|
||||
static void ClassTest(HINSTANCE hInstance, BOOL global)
|
||||
{
|
||||
WNDCLASSW cls, wc;
|
||||
static const WCHAR className[] = {'T','e','s','t','C','l','a','s','s',0};
|
||||
static const WCHAR winName[] = {'W','i','n','C','l','a','s','s','T','e','s','t',0};
|
||||
ATOM test_atom;
|
||||
HWND hTestWnd;
|
||||
DWORD i;
|
||||
WCHAR str[20];
|
||||
ATOM classatom;
|
||||
|
||||
cls.style = CS_HREDRAW | CS_VREDRAW | (global?CS_GLOBALCLASS:0);
|
||||
cls.lpfnWndProc = ClassTest_WndProc;
|
||||
cls.cbClsExtra = NUMCLASSWORDS*sizeof(DWORD);
|
||||
cls.cbWndExtra = 12;
|
||||
cls.hInstance = hInstance;
|
||||
cls.hIcon = LoadIconW (0, (LPWSTR)IDI_APPLICATION);
|
||||
cls.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
|
||||
cls.hbrBackground = GetStockObject (WHITE_BRUSH);
|
||||
cls.lpszMenuName = 0;
|
||||
cls.lpszClassName = className;
|
||||
|
||||
classatom=RegisterClassW(&cls);
|
||||
if (!classatom && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return;
|
||||
ok(classatom, "failed to register class\n");
|
||||
|
||||
ok(!RegisterClassW (&cls),
|
||||
"RegisterClass of the same class should fail for the second time\n");
|
||||
|
||||
/* Setup windows */
|
||||
hTestWnd = CreateWindowW (className, winName,
|
||||
WS_OVERLAPPEDWINDOW + WS_HSCROLL + WS_VSCROLL,
|
||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
|
||||
0, hInstance, 0);
|
||||
|
||||
ok(hTestWnd!=0, "Failed to create window\n");
|
||||
|
||||
/* test initial values of valid classwords */
|
||||
for(i=0; i<NUMCLASSWORDS; i++)
|
||||
{
|
||||
SetLastError(0);
|
||||
ok(!GetClassLongW(hTestWnd,i*sizeof (DWORD)),
|
||||
"GetClassLongW initial value nonzero!\n");
|
||||
ok(!GetLastError(),
|
||||
"GetClassLongW failed!\n");
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* GetClassLongW(hTestWnd, NUMCLASSWORDS*sizeof(DWORD))
|
||||
* does not fail on Win 98, though MSDN says it should
|
||||
*/
|
||||
SetLastError(0);
|
||||
GetClassLongW(hTestWnd, NUMCLASSWORDS*sizeof(DWORD));
|
||||
ok(GetLastError(),
|
||||
"GetClassLongW() with invalid offset did not fail\n");
|
||||
#endif
|
||||
|
||||
/* set values of valid class words */
|
||||
for(i=0; i<NUMCLASSWORDS; i++)
|
||||
{
|
||||
SetLastError(0);
|
||||
ok(!SetClassLongW(hTestWnd,i*sizeof(DWORD),i+1),
|
||||
"GetClassLongW(%ld) initial value nonzero!\n",i*sizeof(DWORD));
|
||||
ok(!GetLastError(),
|
||||
"SetClassLongW(%ld) failed!\n",i*sizeof(DWORD));
|
||||
}
|
||||
|
||||
/* test values of valid classwords that we set */
|
||||
for(i=0; i<NUMCLASSWORDS; i++)
|
||||
{
|
||||
SetLastError(0);
|
||||
ok( (i+1) == GetClassLongW(hTestWnd,i*sizeof (DWORD)),
|
||||
"GetClassLongW value doesn't match what was set!\n");
|
||||
ok(!GetLastError(),
|
||||
"GetClassLongW failed!\n");
|
||||
}
|
||||
|
||||
/* check GetClassName */
|
||||
i = GetClassNameW(hTestWnd, str, sizeof(str));
|
||||
ok(i == lstrlenW(className),
|
||||
"GetClassName returned incorrect length\n");
|
||||
ok(!lstrcmpW(className,str),
|
||||
"GetClassName returned incorrect name for this window's class\n");
|
||||
|
||||
/* check GetClassInfo with our hInstance */
|
||||
if((test_atom = GetClassInfoW(hInstance, str, &wc)))
|
||||
{
|
||||
ok(test_atom == classatom,
|
||||
"class atom did not match\n");
|
||||
ok(wc.cbClsExtra == cls.cbClsExtra,
|
||||
"cbClsExtra did not match\n");
|
||||
ok(wc.cbWndExtra == cls.cbWndExtra,
|
||||
"cbWndExtra did not match\n");
|
||||
ok(wc.hbrBackground == cls.hbrBackground,
|
||||
"hbrBackground did not match\n");
|
||||
ok(wc.hCursor== cls.hCursor,
|
||||
"hCursor did not match\n");
|
||||
ok(wc.hInstance== cls.hInstance,
|
||||
"hInstance did not match\n");
|
||||
}
|
||||
else
|
||||
ok(FALSE,"GetClassInfo (hinstance) failed!\n");
|
||||
|
||||
/* check GetClassInfo with zero hInstance */
|
||||
if(global)
|
||||
{
|
||||
if((test_atom = GetClassInfoW(0, str, &wc)))
|
||||
{
|
||||
ok(test_atom == classatom,
|
||||
"class atom did not match %x != %x\n", test_atom, classatom);
|
||||
ok(wc.cbClsExtra == cls.cbClsExtra,
|
||||
"cbClsExtra did not match %x!=%x\n",wc.cbClsExtra,cls.cbClsExtra);
|
||||
ok(wc.cbWndExtra == cls.cbWndExtra,
|
||||
"cbWndExtra did not match %x!=%x\n",wc.cbWndExtra,cls.cbWndExtra);
|
||||
ok(wc.hbrBackground == cls.hbrBackground,
|
||||
"hbrBackground did not match %p!=%p\n",wc.hbrBackground,cls.hbrBackground);
|
||||
ok(wc.hCursor== cls.hCursor,
|
||||
"hCursor did not match %p!=%p\n",wc.hCursor,cls.hCursor);
|
||||
ok(!wc.hInstance,
|
||||
"hInstance not zero for global class %p\n",wc.hInstance);
|
||||
}
|
||||
else
|
||||
ok(FALSE,"GetClassInfo (0) failed for global class!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(!GetClassInfoW(0, str, &wc),
|
||||
"GetClassInfo (0) succeeded for local class!\n");
|
||||
}
|
||||
|
||||
ok(!UnregisterClassW(className, hInstance),
|
||||
"Unregister class succeeded with window existing\n");
|
||||
|
||||
ok(DestroyWindow(hTestWnd),
|
||||
"DestroyWindow() failed!\n");
|
||||
|
||||
ok(UnregisterClassW(className, hInstance),
|
||||
"UnregisterClass() failed\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void check_style( const char *name, int must_exist, UINT style, UINT ignore )
|
||||
{
|
||||
WNDCLASS wc;
|
||||
|
||||
if (GetClassInfo( 0, name, &wc ))
|
||||
{
|
||||
ok( !(~wc.style & style & ~ignore), "System class %s is missing bits %x (%08x/%08x)\n",
|
||||
name, ~wc.style & style, wc.style, style );
|
||||
ok( !(wc.style & ~style), "System class %s has extra bits %x (%08x/%08x)\n",
|
||||
name, wc.style & ~style, wc.style, style );
|
||||
}
|
||||
else
|
||||
ok( !must_exist, "System class %s does not exist\n", name );
|
||||
}
|
||||
|
||||
/* test styles of system classes */
|
||||
static void test_styles(void)
|
||||
{
|
||||
/* check style bits */
|
||||
check_style( "Button", 1, CS_PARENTDC | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, 0 );
|
||||
check_style( "ComboBox", 1, CS_PARENTDC | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, 0 );
|
||||
check_style( "Edit", 1, CS_PARENTDC | CS_DBLCLKS, 0 );
|
||||
check_style( "ListBox", 1, CS_PARENTDC | CS_DBLCLKS, CS_PARENTDC /*FIXME*/ );
|
||||
check_style( "MDIClient", 1, 0, 0 );
|
||||
check_style( "ScrollBar", 1, CS_PARENTDC | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, 0 );
|
||||
check_style( "Static", 1, CS_PARENTDC | CS_DBLCLKS, 0 );
|
||||
check_style( "ComboLBox", 1, CS_SAVEBITS | CS_DBLCLKS, 0 );
|
||||
check_style( "DDEMLEvent", 0, 0, 0 );
|
||||
check_style( "Message", 0, 0, 0 );
|
||||
check_style( "#32768", 1, CS_DROPSHADOW | CS_SAVEBITS | CS_DBLCLKS, CS_DROPSHADOW ); /* menu */
|
||||
check_style( "#32769", 1, CS_DBLCLKS, 0 ); /* desktop */
|
||||
check_style( "#32770", 1, CS_SAVEBITS | CS_DBLCLKS, 0 ); /* dialog */
|
||||
todo_wine { check_style( "#32771", 1, CS_SAVEBITS | CS_HREDRAW | CS_VREDRAW, 0 ); } /* task switch */
|
||||
check_style( "#32772", 1, 0, 0 ); /* icon title */
|
||||
}
|
||||
|
||||
static void check_class(HINSTANCE inst, const char *name, const char *menu_name)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
UINT atom = GetClassInfo(inst,name,&wc);
|
||||
ok( atom, "Class %s %p not found\n", name, inst );
|
||||
if (atom)
|
||||
{
|
||||
if (wc.lpszMenuName && menu_name)
|
||||
ok( !strcmp( menu_name, wc.lpszMenuName ), "Wrong name %s/%s for class %s %p\n",
|
||||
wc.lpszMenuName, menu_name, name, inst );
|
||||
else
|
||||
ok( !menu_name == !wc.lpszMenuName, "Wrong name %p/%p for class %s %p\n",
|
||||
wc.lpszMenuName, menu_name, name, inst );
|
||||
}
|
||||
}
|
||||
|
||||
static void check_instance( const char *name, HINSTANCE inst, HINSTANCE info_inst, HINSTANCE gcl_inst )
|
||||
{
|
||||
WNDCLASSA wc;
|
||||
HWND hwnd;
|
||||
|
||||
ok( GetClassInfo( inst, name, &wc ), "Couldn't find class %s inst %p\n", name, inst );
|
||||
ok( wc.hInstance == info_inst, "Wrong info instance %p/%p for class %s\n",
|
||||
wc.hInstance, info_inst, name );
|
||||
hwnd = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, inst, 0 );
|
||||
ok( hwnd != NULL, "Couldn't create window for class %s inst %p\n", name, inst );
|
||||
ok( (HINSTANCE)GetClassLongA( hwnd, GCL_HMODULE ) == gcl_inst,
|
||||
"Wrong GCL instance %p/%p for class %s\n",
|
||||
(HINSTANCE)GetClassLongA( hwnd, GCL_HMODULE ), gcl_inst, name );
|
||||
ok( (HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE ) == inst,
|
||||
"Wrong GWL instance %p/%p for window %s\n",
|
||||
(HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE ), inst, name );
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
/* test various instance parameters */
|
||||
static void test_instances(void)
|
||||
{
|
||||
WNDCLASSA cls, wc;
|
||||
HWND hwnd, hwnd2;
|
||||
const char *name = "__test__";
|
||||
HINSTANCE kernel32 = GetModuleHandleA("kernel32");
|
||||
HINSTANCE user32 = GetModuleHandleA("user32");
|
||||
HINSTANCE main_module = GetModuleHandleA(NULL);
|
||||
|
||||
memset( &cls, 0, sizeof(cls) );
|
||||
cls.style = CS_HREDRAW | CS_VREDRAW;
|
||||
cls.lpfnWndProc = ClassTest_WndProc;
|
||||
cls.cbClsExtra = 0;
|
||||
cls.cbWndExtra = 0;
|
||||
cls.lpszClassName = name;
|
||||
|
||||
cls.lpszMenuName = "main_module";
|
||||
cls.hInstance = main_module;
|
||||
ok( RegisterClassA( &cls ), "Failed to register local class for main module\n" );
|
||||
check_class( main_module, name, "main_module" );
|
||||
check_instance( name, main_module, main_module, main_module );
|
||||
|
||||
cls.lpszMenuName = "kernel32";
|
||||
cls.hInstance = kernel32;
|
||||
ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
|
||||
check_class( kernel32, name, "kernel32" );
|
||||
check_class( main_module, name, "main_module" );
|
||||
check_instance( name, kernel32, kernel32, kernel32 );
|
||||
ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
|
||||
|
||||
/* setting global flag doesn't change status of class */
|
||||
hwnd = CreateWindowExA( 0, name, "test", 0, 0, 0, 0, 0, 0, 0, main_module, 0 );
|
||||
SetClassLongA( hwnd, GCL_STYLE, CS_GLOBALCLASS );
|
||||
cls.lpszMenuName = "kernel32";
|
||||
cls.hInstance = kernel32;
|
||||
ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
|
||||
check_class( kernel32, name, "kernel32" );
|
||||
check_class( main_module, name, "main_module" );
|
||||
check_instance( name, kernel32, kernel32, kernel32 );
|
||||
check_instance( name, main_module, main_module, main_module );
|
||||
ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
|
||||
|
||||
/* changing the instance doesn't make it global */
|
||||
SetClassLongA( hwnd, GCL_HMODULE, 0 );
|
||||
ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
|
||||
check_class( kernel32, name, "kernel32" );
|
||||
check_instance( name, kernel32, kernel32, kernel32 );
|
||||
ok( !GetClassInfo( 0, name, &wc ), "Class found with null instance\n" );
|
||||
ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
|
||||
|
||||
/* GetClassInfo with instance 0 finds user32 instance */
|
||||
SetClassLongA( hwnd, GCL_HMODULE, (LONG)user32 );
|
||||
ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
|
||||
check_class( kernel32, name, "kernel32" );
|
||||
check_class( user32, name, "main_module" );
|
||||
check_class( 0, name, "main_module" );
|
||||
check_instance( name, kernel32, kernel32, kernel32 );
|
||||
check_instance( name, user32, 0, user32 );
|
||||
check_instance( name, 0, 0, kernel32 );
|
||||
ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
|
||||
|
||||
SetClassLongA( hwnd, GCL_HMODULE, 0x12345678 );
|
||||
ok( RegisterClassA( &cls ), "Failed to register local class for kernel32\n" );
|
||||
check_class( kernel32, name, "kernel32" );
|
||||
check_class( (HINSTANCE)0x12345678, name, "main_module" );
|
||||
check_instance( name, kernel32, kernel32, kernel32 );
|
||||
check_instance( name, (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0x12345678 );
|
||||
ok( !GetClassInfo( 0, name, &wc ), "Class found with null instance\n" );
|
||||
|
||||
/* creating a window with instance 0 uses the first class found */
|
||||
cls.hInstance = (HINSTANCE)0xdeadbeef;
|
||||
cls.lpszMenuName = "deadbeef";
|
||||
cls.style = 3;
|
||||
ok( RegisterClassA( &cls ), "Failed to register local class for deadbeef\n" );
|
||||
hwnd2 = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL, 0 );
|
||||
ok( GetClassLong( hwnd2, GCL_HMODULE ) == 0xdeadbeef,
|
||||
"Didn't get deadbeef class for null instance\n" );
|
||||
DestroyWindow( hwnd2 );
|
||||
ok( UnregisterClassA( name, (HINSTANCE)0xdeadbeef ), "Unregister failed for deadbeef\n" );
|
||||
|
||||
hwnd2 = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL, 0 );
|
||||
ok( (HINSTANCE)GetClassLong( hwnd2, GCL_HMODULE ) == kernel32,
|
||||
"Didn't get kernel32 class for null instance\n" );
|
||||
DestroyWindow( hwnd2 );
|
||||
|
||||
ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
|
||||
|
||||
hwnd2 = CreateWindowExA( 0, name, "test_window", 0, 0, 0, 0, 0, 0, 0, NULL, 0 );
|
||||
ok( GetClassLong( hwnd2, GCL_HMODULE ) == 0x12345678,
|
||||
"Didn't get 12345678 class for null instance\n" );
|
||||
DestroyWindow( hwnd2 );
|
||||
|
||||
SetClassLongA( hwnd, GCL_HMODULE, (LONG)main_module );
|
||||
DestroyWindow( hwnd );
|
||||
|
||||
/* null handle means the same thing as main module */
|
||||
cls.lpszMenuName = "null";
|
||||
cls.hInstance = 0;
|
||||
ok( !RegisterClassA( &cls ), "Succeeded registering local class for null instance\n" );
|
||||
ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %ld\n", GetLastError() );
|
||||
ok( UnregisterClassA( name, main_module ), "Unregister failed for main module\n" );
|
||||
|
||||
ok( RegisterClassA( &cls ), "Failed to register local class for null instance\n" );
|
||||
/* must be found with main module handle */
|
||||
check_class( main_module, name, "null" );
|
||||
check_instance( name, main_module, main_module, main_module );
|
||||
ok( !GetClassInfo( 0, name, &wc ), "Class found with null instance\n" );
|
||||
ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST, "Wrong error code %ld\n", GetLastError() );
|
||||
ok( UnregisterClassA( name, 0 ), "Unregister failed for null instance\n" );
|
||||
|
||||
/* registering for user32 always fails */
|
||||
cls.lpszMenuName = "user32";
|
||||
cls.hInstance = user32;
|
||||
ok( !RegisterClassA( &cls ), "Succeeded registering local class for user32\n" );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error code %ld\n", GetLastError() );
|
||||
cls.style |= CS_GLOBALCLASS;
|
||||
ok( !RegisterClassA( &cls ), "Succeeded registering global class for user32\n" );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "Wrong error code %ld\n", GetLastError() );
|
||||
|
||||
/* unregister is OK though */
|
||||
cls.hInstance = main_module;
|
||||
ok( RegisterClassA( &cls ), "Failed to register global class for main module\n" );
|
||||
ok( UnregisterClassA( name, user32 ), "Unregister failed for user32\n" );
|
||||
|
||||
/* instance doesn't matter for global class */
|
||||
cls.style |= CS_GLOBALCLASS;
|
||||
cls.lpszMenuName = "main_module";
|
||||
cls.hInstance = main_module;
|
||||
ok( RegisterClassA( &cls ), "Failed to register global class for main module\n" );
|
||||
cls.lpszMenuName = "kernel32";
|
||||
cls.hInstance = kernel32;
|
||||
ok( !RegisterClassA( &cls ), "Succeeded registering local class for kernel32\n" );
|
||||
ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %ld\n", GetLastError() );
|
||||
/* even if global flag is cleared */
|
||||
hwnd = CreateWindowExA( 0, name, "test", 0, 0, 0, 0, 0, 0, 0, main_module, 0 );
|
||||
SetClassLongA( hwnd, GCL_STYLE, 0 );
|
||||
ok( !RegisterClassA( &cls ), "Succeeded registering local class for kernel32\n" );
|
||||
ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %ld\n", GetLastError() );
|
||||
|
||||
check_class( main_module, name, "main_module" );
|
||||
check_class( kernel32, name, "main_module" );
|
||||
check_class( 0, name, "main_module" );
|
||||
check_class( (HINSTANCE)0x12345678, name, "main_module" );
|
||||
check_instance( name, main_module, main_module, main_module );
|
||||
check_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, main_module );
|
||||
|
||||
/* changing the instance for global class doesn't make much difference */
|
||||
SetClassLongA( hwnd, GCL_HMODULE, 0xdeadbeef );
|
||||
check_instance( name, main_module, main_module, (HINSTANCE)0xdeadbeef );
|
||||
check_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef );
|
||||
|
||||
DestroyWindow( hwnd );
|
||||
ok( UnregisterClassA( name, (HINSTANCE)0x87654321 ), "Unregister failed for main module global\n" );
|
||||
ok( !UnregisterClassA( name, (HINSTANCE)0x87654321 ), "Unregister succeeded the second time\n" );
|
||||
ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST, "Wrong error code %ld\n", GetLastError() );
|
||||
|
||||
cls.hInstance = (HINSTANCE)0x12345678;
|
||||
ok( RegisterClassA( &cls ), "Failed to register global class for dummy instance\n" );
|
||||
check_instance( name, main_module, main_module, (HINSTANCE)0x12345678 );
|
||||
check_instance( name, (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, (HINSTANCE)0x12345678 );
|
||||
ok( UnregisterClassA( name, (HINSTANCE)0x87654321 ), "Unregister failed for main module global\n" );
|
||||
|
||||
/* check system classes */
|
||||
|
||||
/* we cannot register a global class with the name of a system class */
|
||||
cls.style |= CS_GLOBALCLASS;
|
||||
cls.lpszMenuName = "button_main_module";
|
||||
cls.lpszClassName = "BUTTON";
|
||||
cls.hInstance = main_module;
|
||||
ok( !RegisterClassA( &cls ), "Succeeded registering global button class for main module\n" );
|
||||
ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %ld\n", GetLastError() );
|
||||
cls.hInstance = kernel32;
|
||||
ok( !RegisterClassA( &cls ), "Succeeded registering global button class for kernel32\n" );
|
||||
ok( GetLastError() == ERROR_CLASS_ALREADY_EXISTS, "Wrong error code %ld\n", GetLastError() );
|
||||
|
||||
/* local class is OK however */
|
||||
cls.style &= ~CS_GLOBALCLASS;
|
||||
cls.lpszMenuName = "button_main_module";
|
||||
cls.hInstance = main_module;
|
||||
ok( RegisterClassA( &cls ), "Failed to register local button class for main module\n" );
|
||||
check_class( main_module, "BUTTON", "button_main_module" );
|
||||
cls.lpszMenuName = "button_kernel32";
|
||||
cls.hInstance = kernel32;
|
||||
ok( RegisterClassA( &cls ), "Failed to register local button class for kernel32\n" );
|
||||
check_class( kernel32, "BUTTON", "button_kernel32" );
|
||||
check_class( main_module, "BUTTON", "button_main_module" );
|
||||
ok( UnregisterClassA( "BUTTON", kernel32 ), "Unregister failed for kernel32 button\n" );
|
||||
ok( UnregisterClassA( "BUTTON", main_module ), "Unregister failed for main module button\n" );
|
||||
/* GetClassInfo sets instance to passed value for global classes */
|
||||
check_instance( "BUTTON", 0, 0, user32 );
|
||||
check_instance( "BUTTON", (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, user32 );
|
||||
check_instance( "BUTTON", user32, 0, user32 );
|
||||
|
||||
/* we can unregister system classes */
|
||||
ok( GetClassInfo( 0, "BUTTON", &wc ), "Button class not found with null instance\n" );
|
||||
ok( GetClassInfo( kernel32, "BUTTON", &wc ), "Button class not found with kernel32\n" );
|
||||
ok( UnregisterClass( "BUTTON", (HINSTANCE)0x12345678 ), "Failed to unregister button\n" );
|
||||
ok( !UnregisterClass( "BUTTON", (HINSTANCE)0x87654321 ), "Unregistered button a second time\n" );
|
||||
ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST, "Wrong error code %ld\n", GetLastError() );
|
||||
ok( !GetClassInfo( 0, "BUTTON", &wc ), "Button still exists\n" );
|
||||
ok( GetLastError() == ERROR_CLASS_DOES_NOT_EXIST, "Wrong error code %ld\n", GetLastError() );
|
||||
|
||||
/* we can change the instance of a system class */
|
||||
check_instance( "EDIT", (HINSTANCE)0xdeadbeef, (HINSTANCE)0xdeadbeef, user32 );
|
||||
hwnd = CreateWindowExA( 0, "EDIT", "test", 0, 0, 0, 0, 0, 0, 0, main_module, 0 );
|
||||
SetClassLongA( hwnd, GCL_HMODULE, 0xdeadbeef );
|
||||
check_instance( "EDIT", (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0xdeadbeef );
|
||||
}
|
||||
|
||||
START_TEST(class)
|
||||
{
|
||||
HANDLE hInstance = GetModuleHandleA( NULL );
|
||||
|
||||
ClassTest(hInstance,FALSE);
|
||||
ClassTest(hInstance,TRUE);
|
||||
test_styles();
|
||||
test_instances();
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* Unit tests for DDE functions
|
||||
*
|
||||
* Copyright (c) 2004 Dmitry Timoshkov
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "ddeml.h"
|
||||
#include "winerror.h"
|
||||
|
||||
static HDDEDATA CALLBACK DdeCallback(UINT uType, UINT uFmt, HCONV hconv,
|
||||
HSZ hsz1, HSZ hsz2, HDDEDATA hdata,
|
||||
ULONG_PTR dwData1, ULONG_PTR dwData2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void test_DdeCreateStringHandleW(DWORD dde_inst, int codepage)
|
||||
{
|
||||
static const WCHAR dde_string[] = {'D','D','E',' ','S','t','r','i','n','g',0};
|
||||
HSZ str_handle;
|
||||
WCHAR bufW[256];
|
||||
char buf[256];
|
||||
int ret;
|
||||
|
||||
str_handle = DdeCreateStringHandleW(dde_inst, dde_string, codepage);
|
||||
ok(str_handle != 0, "DdeCreateStringHandleW failed with error %08x\n",
|
||||
DdeGetLastError(dde_inst));
|
||||
|
||||
ret = DdeQueryStringW(dde_inst, str_handle, NULL, 0, codepage);
|
||||
if (codepage == CP_WINANSI)
|
||||
ok(ret == 1, "DdeQueryStringW returned wrong length %d\n", ret);
|
||||
else
|
||||
ok(ret == lstrlenW(dde_string), "DdeQueryStringW returned wrong length %d\n", ret);
|
||||
|
||||
ret = DdeQueryStringW(dde_inst, str_handle, bufW, 256, codepage);
|
||||
if (codepage == CP_WINANSI)
|
||||
{
|
||||
ok(ret == 1, "DdeQueryStringW returned wrong length %d\n", ret);
|
||||
ok(!lstrcmpA("D", (LPCSTR)bufW), "DdeQueryStringW returned wrong string\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(ret == lstrlenW(dde_string), "DdeQueryStringW returned wrong length %d\n", ret);
|
||||
ok(!lstrcmpW(dde_string, bufW), "DdeQueryStringW returned wrong string\n");
|
||||
}
|
||||
|
||||
ret = DdeQueryStringA(dde_inst, str_handle, buf, 256, CP_WINANSI);
|
||||
if (codepage == CP_WINANSI)
|
||||
{
|
||||
ok(ret == 1, "DdeQueryStringA returned wrong length %d\n", ret);
|
||||
ok(!lstrcmpA("D", buf), "DdeQueryStringW returned wrong string\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(ret == lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret);
|
||||
ok(!lstrcmpA("DDE String", buf), "DdeQueryStringA returned wrong string %s\n", buf);
|
||||
}
|
||||
|
||||
ret = DdeQueryStringA(dde_inst, str_handle, buf, 256, CP_WINUNICODE);
|
||||
if (codepage == CP_WINANSI)
|
||||
{
|
||||
ok(ret == 1, "DdeQueryStringA returned wrong length %d\n", ret);
|
||||
ok(!lstrcmpA("D", buf), "DdeQueryStringA returned wrong string %s\n", buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
ok(ret == lstrlenA("DDE String"), "DdeQueryStringA returned wrong length %d\n", ret);
|
||||
ok(!lstrcmpW(dde_string, (LPCWSTR)buf), "DdeQueryStringW returned wrong string\n");
|
||||
}
|
||||
|
||||
ok(DdeFreeStringHandle(dde_inst, str_handle), "DdeFreeStringHandle failed\n");
|
||||
}
|
||||
|
||||
START_TEST(dde)
|
||||
{
|
||||
DWORD dde_inst, ret;
|
||||
|
||||
dde_inst = 0xdeadbeef;
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = DdeInitializeW(&dde_inst, DdeCallback, APPCMD_CLIENTONLY, 0);
|
||||
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
||||
{
|
||||
trace("Skipping the DDE test on a Win9x platform\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ok(ret == DMLERR_INVALIDPARAMETER, "DdeInitializeW should fail, but got %04lx instead\n", ret);
|
||||
ok(DdeGetLastError(dde_inst) == DMLERR_INVALIDPARAMETER, "expected DMLERR_INVALIDPARAMETER\n");
|
||||
|
||||
dde_inst = 0;
|
||||
ret = DdeInitializeW(&dde_inst, DdeCallback, APPCMD_CLIENTONLY, 0);
|
||||
ok(ret == DMLERR_NO_ERROR, "DdeInitializeW failed with error %04lx (%08x)\n",
|
||||
ret, DdeGetLastError(dde_inst));
|
||||
|
||||
test_DdeCreateStringHandleW(dde_inst, 0);
|
||||
test_DdeCreateStringHandleW(dde_inst, CP_WINUNICODE);
|
||||
test_DdeCreateStringHandleW(dde_inst, CP_WINANSI);
|
||||
|
||||
ok(DdeUninitialize(dde_inst), "DdeUninitialize failed\n");
|
||||
}
|
|
@ -1,518 +0,0 @@
|
|||
/* Unit test suite for the dialog functions.
|
||||
*
|
||||
* Copyright 2004 Bill Medland
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
*
|
||||
* This test suite currently works by building a quite complex hierarchy of
|
||||
* objects in a variety of styles and then performs a limited number of tests
|
||||
* for the previous and next dialog group or tab items.
|
||||
*
|
||||
* The test specifically does not test all possibilities at this time since
|
||||
* there are several cases where the Windows behaviour is rather strange and
|
||||
* significant work would be required to get the Wine code to duplicate the
|
||||
* strangeness, especially since most are in situations that would not
|
||||
* normally be met.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
|
||||
#define MAXHWNDS 1024
|
||||
static HWND hwnd [MAXHWNDS];
|
||||
static int numwnds=1; /* 0 is reserved for null */
|
||||
|
||||
/* Global handles */
|
||||
static HINSTANCE g_hinst; /* This application's HINSTANCE */
|
||||
static HWND g_hwndMain, g_hwndButton1, g_hwndButton2, g_hwndButtonCancel;
|
||||
static int g_terminated;
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
int parent;
|
||||
DWORD style;
|
||||
DWORD exstyle;
|
||||
} h_entry;
|
||||
|
||||
static const h_entry hierarchy [] = {
|
||||
/* 0 is reserved for the null window */
|
||||
{ 1, 0, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS, WS_EX_WINDOWEDGE},
|
||||
{ 20, 1, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
{ 2, 1, WS_CHILD | WS_VISIBLE, WS_EX_CONTROLPARENT},
|
||||
{ 60, 2, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
/* What happens with groups when the parent is disabled */
|
||||
{ 8, 2, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_TABSTOP, WS_EX_CONTROLPARENT},
|
||||
{ 85, 8, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_GROUP, 0},
|
||||
{ 9, 8, WS_CHILD, WS_EX_CONTROLPARENT},
|
||||
{ 86, 9, WS_CHILD | WS_VISIBLE, 0},
|
||||
{ 87, 9, WS_CHILD | WS_VISIBLE, 0},
|
||||
{ 31, 8, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
{ 10, 2, WS_CHILD | WS_VISIBLE, WS_EX_CONTROLPARENT},
|
||||
{ 88, 10, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
{ 11, 10, WS_CHILD, WS_EX_CONTROLPARENT},
|
||||
{ 89, 11, WS_CHILD | WS_VISIBLE, 0},
|
||||
{ 32, 11, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
{ 90, 11, WS_CHILD | WS_VISIBLE, 0},
|
||||
{ 33, 10, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
{ 21, 2, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
{ 61, 2, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
{ 3, 1, WS_CHILD | WS_VISIBLE | DS_CONTROL, 0},
|
||||
{ 22, 3, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
{ 62, 3, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
{ 7, 3, WS_CHILD | WS_VISIBLE, WS_EX_CONTROLPARENT},
|
||||
{ 4, 7, WS_CHILD | WS_VISIBLE | DS_CONTROL, 0},
|
||||
{ 83, 4, WS_CHILD | WS_VISIBLE, 0},
|
||||
{ 5, 4, WS_CHILD | WS_VISIBLE | DS_CONTROL, 0},
|
||||
/* A couple of controls around the main dialog */
|
||||
{ 29, 5, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
{ 81, 5, WS_CHILD | WS_VISIBLE, 0},
|
||||
/* The main dialog with lots of controls */
|
||||
{ 6, 5, WS_CHILD | WS_VISIBLE, WS_EX_CONTROLPARENT},
|
||||
/* At the start of a dialog */
|
||||
/* Disabled controls are skipped */
|
||||
{ 63, 6, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_TABSTOP, 0},
|
||||
/* Invisible controls are skipped */
|
||||
{ 64, 6, WS_CHILD | WS_TABSTOP, 0},
|
||||
/* Invisible disabled controls are skipped */
|
||||
{ 65, 6, WS_CHILD | WS_DISABLED | WS_TABSTOP, 0},
|
||||
/* Non-tabstop controls are skipped for tabs but not for groups */
|
||||
{ 66, 6, WS_CHILD | WS_VISIBLE, 0},
|
||||
/* End of first group, with no tabstops in it */
|
||||
{ 23, 6, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
/* At last a tabstop */
|
||||
{ 67, 6, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
/* A group that is totally disabled or invisible */
|
||||
{ 24, 6, WS_CHILD | WS_DISABLED | WS_GROUP, 0},
|
||||
{ 68, 6, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_TABSTOP, 0},
|
||||
{ 69, 6, WS_CHILD | WS_TABSTOP, 0},
|
||||
/* A valid group in the middle of the dialog (not the first nor last group*/
|
||||
{ 25, 6, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
/* A non-tabstop item will be skipped for tabs */
|
||||
{ 70, 6, WS_CHILD | WS_VISIBLE, 0},
|
||||
/* A disabled item will be skipped for tabs and groups */
|
||||
{ 71, 6, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_TABSTOP, 0},
|
||||
/* A valid item will be found for tabs and groups */
|
||||
{ 72, 6, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
/* A disabled item to skip when looking for the next group item */
|
||||
{ 73, 6, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_TABSTOP, 0},
|
||||
/* The next group begins with an enabled visible label */
|
||||
{ 26, 6, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
{ 74, 6, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
{ 75, 6, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
/* That group is terminated by a disabled label */
|
||||
{ 27, 6, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_GROUP, 0},
|
||||
{ 76, 6, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
{ 77, 6, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
/* That group is terminated by an invisible label */
|
||||
{ 28, 6, WS_CHILD | WS_GROUP, 0},
|
||||
/* The end of the dialog with item for loop and recursion testing */
|
||||
{ 78, 6, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
/* No tabstop so skipped for prev tab, but found for prev group */
|
||||
{ 79, 6, WS_CHILD | WS_VISIBLE, 0},
|
||||
{ 80, 6, WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_TABSTOP, 0},
|
||||
/* A couple of controls after the main dialog */
|
||||
{ 82, 5, WS_CHILD | WS_VISIBLE, 0},
|
||||
{ 30, 5, WS_CHILD | WS_VISIBLE | WS_GROUP, 0},
|
||||
/* And around them */
|
||||
{ 84, 4, WS_CHILD | WS_VISIBLE | WS_TABSTOP, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static BOOL CreateWindows (HINSTANCE hinst)
|
||||
{
|
||||
const h_entry *p = hierarchy;
|
||||
|
||||
while (p->id != 0)
|
||||
{
|
||||
DWORD style, exstyle;
|
||||
char ctrlname[9];
|
||||
|
||||
/* Basically assert that the hierarchy is valid and track the
|
||||
* maximum control number
|
||||
*/
|
||||
if (p->id >= numwnds)
|
||||
{
|
||||
if (p->id >= sizeof(hwnd)/sizeof(hwnd[0]))
|
||||
{
|
||||
trace ("Control %d is out of range\n", p->id);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
numwnds = p->id+1;
|
||||
}
|
||||
if (p->id <= 0)
|
||||
{
|
||||
trace ("Control %d is out of range\n", p->id);
|
||||
return FALSE;
|
||||
}
|
||||
if (hwnd[p->id] != 0)
|
||||
{
|
||||
trace ("Control %d is used more than once\n", p->id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Create the control */
|
||||
sprintf (ctrlname, "ctrl%4.4d", p->id);
|
||||
hwnd[p->id] = CreateWindowEx (p->exstyle, TEXT(p->parent ? "static" : "GetNextDlgItemWindowClass"), TEXT(ctrlname), p->style, 10, 10, 10, 10, hwnd[p->parent], p->parent ? (HMENU) (2000 + p->id) : 0, hinst, 0);
|
||||
if (!hwnd[p->id])
|
||||
{
|
||||
trace ("Failed to create control %d\n", p->id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check that the styles are as we specified (except the main one
|
||||
* which is quite frequently messed up). If this keeps breaking then
|
||||
* we could mask out the bits that don't concern us.
|
||||
*/
|
||||
if (p->parent)
|
||||
{
|
||||
style = GetWindowLong (hwnd[p->id], GWL_STYLE);
|
||||
exstyle = GetWindowLong (hwnd[p->id], GWL_EXSTYLE);
|
||||
if (style == p->style && exstyle == p->exstyle)
|
||||
{
|
||||
trace ("Style mismatch at %d: %8.8lx %8.8lx cf %8.8lx %8.8lx\n", p->id, style, exstyle, p->style, p->exstyle);
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Form the lParam of a WM_KEYDOWN message */
|
||||
static DWORD KeyDownData (int repeat, int scancode, int extended, int wasdown)
|
||||
{
|
||||
return ((repeat & 0x0000FFFF) | ((scancode & 0x00FF) >> 16) |
|
||||
(extended ? 0x01000000 : 0) | (wasdown ? 0x40000000 : 0));
|
||||
}
|
||||
|
||||
/* Form a WM_KEYDOWN VK_TAB message to the specified window */
|
||||
static void FormTabMsg (MSG *pMsg, HWND hwnd)
|
||||
{
|
||||
pMsg->hwnd = hwnd;
|
||||
pMsg->message = WM_KEYDOWN;
|
||||
pMsg->wParam = VK_TAB;
|
||||
pMsg->lParam = KeyDownData (1, 0x0F, 0, 0);
|
||||
/* pMsg->time is not set. It shouldn't be needed */
|
||||
/* pMsg->pt is ignored */
|
||||
}
|
||||
|
||||
/* Form a WM_KEYDOWN VK_RETURN message to the specified window */
|
||||
static void FormEnterMsg (MSG *pMsg, HWND hwnd)
|
||||
{
|
||||
pMsg->hwnd = hwnd;
|
||||
pMsg->message = WM_KEYDOWN;
|
||||
pMsg->wParam = VK_RETURN;
|
||||
pMsg->lParam = KeyDownData (1, 0x1C, 0, 0);
|
||||
/* pMsg->time is not set. It shouldn't be needed */
|
||||
/* pMsg->pt is ignored */
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* The actual tests
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int isok; /* or is it todo */
|
||||
int test;
|
||||
int dlg;
|
||||
int ctl;
|
||||
int tab;
|
||||
int prev;
|
||||
int res;
|
||||
} test_record;
|
||||
|
||||
static int id (HWND h)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < numwnds; i++)
|
||||
if (hwnd[i] == h)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Tests
|
||||
*
|
||||
* Tests 1-8 test the hCtl argument of null or the dialog itself.
|
||||
*
|
||||
* 1. Prev Group of null is null
|
||||
* 2. Prev Tab of null is null
|
||||
* 3. Prev Group of hDlg in hDlg is null
|
||||
* 4. Prev Tab of hDlg in hDlg is null
|
||||
* 5. Next Group of null is first visible enabled child
|
||||
* Check it skips invisible, diabled and both.
|
||||
* 6. Next Tab of null is first visible enabled tabstop
|
||||
* Check it skips invisible, disabled, nontabstop, and in combination.
|
||||
* 7. Next Group of hDlg in hDlg is as of null
|
||||
* 8. Next Tab of hDlg in hDlg is as of null
|
||||
*
|
||||
* Tests 9-14 test descent
|
||||
*
|
||||
* 9. DS_CONTROL does not result in descending the hierarchy for Tab Next
|
||||
* 10. DS_CONTROL does not result in descending the hierarchy for Group Next
|
||||
* 11. WS_EX_CONTROLPARENT results in descending the hierarchy for Tab Next
|
||||
* 12. WS_EX_CONTROLPARENT results in descending the hierarchy for Group Next
|
||||
* 13. WS_EX_CONTROLPARENT results in descending the hierarchy for Tab Prev
|
||||
* 14. WS_EX_CONTROLPARENT results in descending the hierarchy for Group Prev
|
||||
*
|
||||
* Tests 15-24 are the basic Prev/Next Group tests
|
||||
*
|
||||
* 15. Next Group of a visible enabled non-group control is the next visible
|
||||
* enabled non-group control, if there is one before the next group
|
||||
* 16. Next Group of a visible enabled non-group control wraps around to the
|
||||
* beginning of the group on finding a control that starts another group.
|
||||
* Note that the group is in the middle of the dialog.
|
||||
* 17. As 16 except note that the next group is started with a disabled
|
||||
* visible control.
|
||||
* 18. As 16 except note that the next group is started with an invisible
|
||||
* enabled control.
|
||||
* 19. Next Group wraps around the controls of the dialog
|
||||
* 20. Next Group is the same even if the initial control is disabled.
|
||||
* 21. Next Group is the same even if the initial control is invisible.
|
||||
* 22. Next Group is the same even if the initial control has the group style
|
||||
* 23. Next Group returns the initial control if there is no visible enabled
|
||||
* control in the group. (Initial control disabled and not group style).
|
||||
* 24. Prev version of test 16.
|
||||
* Prev Group of a visible enabled non-group control wraps around to the
|
||||
* beginning of the group on finding a control that starts the group.
|
||||
* Note that the group is in the middle of the dialog.
|
||||
*
|
||||
* In tests 25 to 28 the control is sitting under dialogs which do not have
|
||||
* the WS_EX_CONTROLPARENT style and so cannot be reached from the top of
|
||||
* the dialog.
|
||||
*
|
||||
* 25. Next Group of an inaccessible control is as if it were accessible
|
||||
* 26. Prev Group of an inaccessible control begins searching at the highest
|
||||
* level ancestor that did not permit recursion down the hierarchy
|
||||
* 27. Next Tab of an inaccessible control is as if it were accessible
|
||||
* 28. Prev Tab of an inaccessible control begins searching at the highest
|
||||
* level ancestor that did not permit recursion down the hierarchy.
|
||||
*
|
||||
* Tests 29- are the basic Tab tests
|
||||
*
|
||||
* 29. Next Tab of a control is the next visible enabled control with the
|
||||
* Tabstop style (N.B. skips disabled, invisible and non-tabstop)
|
||||
* 30. Prev Tab of a control is the previous visible enabled control with the
|
||||
* Tabstop style (N.B. skips disabled, invisible and non-tabstop)
|
||||
* 31. Next Tab test with at least two layers of descent and finding the
|
||||
* result not at the first control.
|
||||
* 32. Next Tab test with at least two layers of descent with the descent and
|
||||
* control at the start of each level.
|
||||
* 33. Prev Tab test with at least two layers of descent and finding the
|
||||
* result not at the last control.
|
||||
* 34. Prev Tab test with at least two layers of descent with the descent and
|
||||
* control at the end of each level.
|
||||
*
|
||||
* 35. Passing NULL may result in the first child being the one returned.
|
||||
* (group test)
|
||||
* 36. Passing NULL may result in the first child being the one returned.
|
||||
* (tab test)
|
||||
*/
|
||||
|
||||
static void GetNextDlgItemTest (void)
|
||||
{
|
||||
static test_record test [] =
|
||||
{
|
||||
/* isok test dlg ctl tab prev res */
|
||||
|
||||
{ 1, 1, 6, 0, 0, 1, 0},
|
||||
{ 1, 2, 6, 0, 1, 1, 0},
|
||||
{ 1, 3, 6, 6, 0, 1, 0},
|
||||
{ 1, 4, 6, 6, 1, 1, 0},
|
||||
{ 1, 5, 6, 0, 0, 0, 66},
|
||||
{ 1, 6, 6, 0, 1, 0, 67},
|
||||
{ 1, 7, 6, 6, 0, 0, 66},
|
||||
{ 1, 8, 6, 6, 1, 0, 67},
|
||||
|
||||
{ 1, 9, 4, 83, 1, 0, 84},
|
||||
{ 1, 10, 4, 83, 0, 0, 5},
|
||||
{ 1, 11, 5, 81, 1, 0, 67},
|
||||
{ 1, 12, 5, 81, 0, 0, 66},
|
||||
{ 1, 13, 5, 82, 1, 1, 78},
|
||||
|
||||
{ 1, 14, 5, 82, 0, 1, 79},
|
||||
{ 1, 15, 6, 70, 0, 0, 72},
|
||||
{ 1, 16, 6, 72, 0, 0, 25},
|
||||
{ 1, 17, 6, 75, 0, 0, 26},
|
||||
{ 1, 18, 6, 77, 0, 0, 76},
|
||||
{ 1, 19, 6, 79, 0, 0, 66},
|
||||
{ 1, 20, 6, 71, 0, 0, 72},
|
||||
{ 1, 21, 6, 64, 0, 0, 66},
|
||||
|
||||
{ 1, 22, 6, 25, 0, 0, 70},
|
||||
{ 1, 23, 6, 68, 0, 0, 68},
|
||||
{ 1, 24, 6, 25, 0, 1, 72},
|
||||
{ 1, 25, 1, 70, 0, 0, 72},
|
||||
/*{ 0, 26, 1, 70, 0, 1, 3}, Crashes Win95*/
|
||||
{ 1, 27, 1, 70, 1, 0, 72},
|
||||
/*{ 0, 28, 1, 70, 1, 1, 61}, Crashes Win95*/
|
||||
|
||||
{ 1, 29, 6, 67, 1, 0, 72},
|
||||
{ 1, 30, 6, 72, 1, 1, 67},
|
||||
|
||||
{ 1, 35, 2, 0, 0, 0, 60},
|
||||
{ 1, 36, 2, 0, 1, 0, 60},
|
||||
|
||||
{ 0, 0, 0, 0, 0, 0, 0} /* End of test */
|
||||
};
|
||||
const test_record *p = test;
|
||||
|
||||
ok (CreateWindows (g_hinst), "Could not create test windows\n");
|
||||
|
||||
while (p->dlg)
|
||||
{
|
||||
HWND a;
|
||||
a = (p->tab ? GetNextDlgTabItem : GetNextDlgGroupItem) (hwnd[p->dlg], hwnd[p->ctl], p->prev);
|
||||
if (p->isok)
|
||||
{
|
||||
ok (a == hwnd[p->res], "Test %d: %s %s item of %d in %d was %d instead of %d\n", p->test, p->prev ? "Prev" : "Next", p->tab ? "Tab" : "Group", p->ctl, p->dlg, id(a), p->res);
|
||||
}
|
||||
else
|
||||
{
|
||||
todo_wine
|
||||
{
|
||||
ok (a == hwnd[p->res], "Test %d: %s %s item of %d in %d was actually %d matching expected %d\n", p->test, p->prev ? "Prev" : "Next", p->tab ? "Tab" : "Group", p->ctl, p->dlg, id(a), p->res);
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* OnMainWindowCreate
|
||||
*/
|
||||
static BOOL OnMainWindowCreate (HWND hwnd, LPCREATESTRUCT lpcs)
|
||||
{
|
||||
g_hwndButton1 = CreateWindow (TEXT("button"), TEXT("Button &1"),
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON | BS_TEXT,
|
||||
10, 10, 80, 80, hwnd, (HMENU)100, g_hinst, 0);
|
||||
if (!g_hwndButton1) return FALSE;
|
||||
|
||||
g_hwndButton2 = CreateWindow (TEXT("button"), TEXT("Button &2"),
|
||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_TEXT,
|
||||
110, 10, 80, 80, hwnd, (HMENU)200, g_hinst, 0);
|
||||
if (!g_hwndButton2) return FALSE;
|
||||
|
||||
g_hwndButtonCancel = CreateWindow (TEXT("button"), TEXT("Cancel"),
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_TEXT,
|
||||
210, 10, 80, 80, hwnd, (HMENU)IDCANCEL, g_hinst, 0);
|
||||
if (!g_hwndButtonCancel) return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static LRESULT CALLBACK main_window_procA (HWND hwnd, UINT uiMsg, WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
LRESULT result;
|
||||
switch (uiMsg)
|
||||
{
|
||||
/* Add blank case statements for these to ensure we don't use them
|
||||
* by mistake.
|
||||
*/
|
||||
case DM_GETDEFID: break;
|
||||
case DM_SETDEFID: break;
|
||||
|
||||
case WM_CREATE:
|
||||
return (OnMainWindowCreate (hwnd,
|
||||
(LPCREATESTRUCTA) lParam) ? 0 : (LRESULT) -1);
|
||||
case WM_COMMAND:
|
||||
if (wParam == IDCANCEL)
|
||||
{
|
||||
g_terminated = TRUE;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
result=DefWindowProcA (hwnd, uiMsg, wParam, lParam);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static BOOL RegisterWindowClasses (void)
|
||||
{
|
||||
WNDCLASSA cls;
|
||||
|
||||
cls.style = 0;
|
||||
cls.lpfnWndProc = DefWindowProcA;
|
||||
cls.cbClsExtra = 0;
|
||||
cls.cbWndExtra = 0;
|
||||
cls.hInstance = g_hinst;
|
||||
cls.hIcon = NULL;
|
||||
cls.hCursor = LoadCursorA (NULL, IDC_ARROW);
|
||||
cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
cls.lpszMenuName = NULL;
|
||||
cls.lpszClassName = "GetNextDlgItemWindowClass";
|
||||
|
||||
if (!RegisterClassA (&cls)) return FALSE;
|
||||
|
||||
cls.lpfnWndProc = main_window_procA;
|
||||
cls.lpszClassName = "IsDialogMessageWindowClass";
|
||||
|
||||
if (!RegisterClassA (&cls)) return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void IsDialogMessageWTest (void)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
g_hwndMain = CreateWindow ("IsDialogMessageWindowClass", "IsDialogMessageWindowClass",
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL, NULL, g_hinst, 0);
|
||||
|
||||
assert (g_hwndMain);
|
||||
assert (g_hwndButton1);
|
||||
assert (g_hwndButtonCancel);
|
||||
|
||||
/* The focus should initially be nowhere. The first TAB should take it
|
||||
* to the first button. The second TAB should take it to the Cancel
|
||||
* button.
|
||||
*/
|
||||
FormTabMsg (&msg, g_hwndMain);
|
||||
ok (IsDialogMessage (g_hwndMain, &msg), "Did not handle first TAB\n");
|
||||
ok ((GetFocus() == g_hwndButton1), "Focus did not move to first button\n");
|
||||
FormTabMsg (&msg, g_hwndButton1);
|
||||
ok (IsDialogMessage (g_hwndMain, &msg), "Did not handle second TAB\n");
|
||||
ok ((GetFocus() == g_hwndButtonCancel),
|
||||
"Focus did not move to cancel button\n");
|
||||
FormEnterMsg (&msg, g_hwndButtonCancel);
|
||||
ok (IsDialogMessage (g_hwndMain, &msg), "Did not handle the ENTER\n");
|
||||
ok (g_terminated, "ENTER did not terminate\n");
|
||||
}
|
||||
|
||||
START_TEST(dialog)
|
||||
{
|
||||
g_hinst = GetModuleHandleA (0);
|
||||
|
||||
if (!RegisterWindowClasses()) assert(0);
|
||||
|
||||
GetNextDlgItemTest();
|
||||
IsDialogMessageWTest();
|
||||
}
|
|
@ -1,365 +0,0 @@
|
|||
/* Test Key event to Key message translation
|
||||
*
|
||||
* Copyright 2003 Rein Klazes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* test whether the right type of messages:
|
||||
* WM_KEYUP/DOWN vs WM_SYSKEYUP/DOWN are sent in case of combined
|
||||
* keystrokes.
|
||||
*
|
||||
* For instance <ALT>-X can be accompished by
|
||||
* the sequence ALT-KEY-DOWN, X-KEY-DOWN, ALT-KEY-UP, X-KEY-UP
|
||||
* but also X-KEY-DOWN, ALT-KEY-DOWN, X-KEY-UP, ALT-KEY-UP
|
||||
* Whether a KEY or a SYSKEY message is sent is not always clear, it is
|
||||
* also not the same in WINNT as in WIN9X */
|
||||
|
||||
/* NOTE that there will be test failures under WIN9X
|
||||
* No applications are known to me that rely on this
|
||||
* so I don't fix it */
|
||||
|
||||
/* TODO:
|
||||
* 1. extend it to the wm_command and wm_syscommand notifications
|
||||
* 2. add some more tests with special cases like dead keys or right (alt) key
|
||||
* 3. there is some adapted code from input.c in here. Should really
|
||||
* make that code exactly the same.
|
||||
* 4. resolve the win9x case when there is a need or the testing frame work
|
||||
* offers a nice way.
|
||||
* 5. The test app creates a window, the user should not take the focus
|
||||
* away during its short existence. I could do something to prevent that
|
||||
* if it is a problem.
|
||||
*
|
||||
*/
|
||||
|
||||
#define _WIN32_WINNT 0x401
|
||||
|
||||
#include <windows.h>
|
||||
#include "wine/test.h"
|
||||
//#include "winbase.h"
|
||||
//#include "winuser.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/* globals */
|
||||
HWND hWndTest;
|
||||
long timetag = 0x10000000;
|
||||
|
||||
static UINT (WINAPI *ptr_SendInput) (UINT, INPUT*, size_t);
|
||||
|
||||
#define MAXKEYEVENTS 6
|
||||
#define MAXKEYMESSAGES MAXKEYEVENTS /* assuming a key event generates one
|
||||
and only one message */
|
||||
|
||||
/* keyboard message names, sorted as their value */
|
||||
static const char *MSGNAME[]={"WM_KEYDOWN", "WM_KEYUP", "WM_CHAR","WM_DEADCHAR",
|
||||
"WM_SYSKEYDOWN", "WM_SYSKEYUP", "WM_SYSCHAR", "WM_SYSDEADCHAR" ,"WM_KEYLAST"};
|
||||
|
||||
/* keyevents, add more as needed */
|
||||
typedef enum KEVtag
|
||||
{ ALTDOWN = 1, ALTUP, XDOWN, XUP, SHIFTDOWN, SHIFTUP, CTRLDOWN, CTRLUP } KEV;
|
||||
/* matching VK's */
|
||||
int GETVKEY[]={0, VK_MENU, VK_MENU, 'X', 'X', VK_SHIFT, VK_SHIFT, VK_CONTROL, VK_CONTROL};
|
||||
/* matching scan codes */
|
||||
int GETSCAN[]={0, 0x38, 0x38, 0x2D, 0x2D, 0x2A, 0x2A, 0x1D, 0x1D };
|
||||
/* matching updown events */
|
||||
int GETUPDOWN[]={0, 0, KEYEVENTF_KEYUP, 0, KEYEVENTF_KEYUP, 0, KEYEVENTF_KEYUP, 0, KEYEVENTF_KEYUP};
|
||||
/* matching descripts */
|
||||
char *getdesc[]={"", "+alt","-alt","+X","-X","+shift","-shift","+ctrl","-ctrl"};
|
||||
|
||||
/* The MSVC headers ignore our NONAMELESSUNION requests so we have to define our own type */
|
||||
typedef struct
|
||||
{
|
||||
DWORD type;
|
||||
union
|
||||
{
|
||||
MOUSEINPUT mi;
|
||||
KEYBDINPUT ki;
|
||||
HARDWAREINPUT hi;
|
||||
} u;
|
||||
} TEST_INPUT;
|
||||
|
||||
#define ADDTOINPUTS(kev) \
|
||||
inputs[evtctr].type = INPUT_KEYBOARD; \
|
||||
((TEST_INPUT*)inputs)[evtctr].u.ki.wVk = GETVKEY[ kev]; \
|
||||
((TEST_INPUT*)inputs)[evtctr].u.ki.wScan = GETSCAN[ kev]; \
|
||||
((TEST_INPUT*)inputs)[evtctr].u.ki.dwFlags = GETUPDOWN[ kev]; \
|
||||
((TEST_INPUT*)inputs)[evtctr].u.ki.dwExtraInfo = 0; \
|
||||
((TEST_INPUT*)inputs)[evtctr].u.ki.time = ++timetag; \
|
||||
if( kev) evtctr++;
|
||||
|
||||
typedef struct {
|
||||
UINT message;
|
||||
WPARAM wParam;
|
||||
LPARAM lParam;
|
||||
} KMSG;
|
||||
|
||||
/*******************************************
|
||||
* add new test sets here
|
||||
* the software will make all combinations of the
|
||||
* keyevent defined here
|
||||
*/
|
||||
struct { int nrkev;
|
||||
KEV keydwn[MAXKEYEVENTS];
|
||||
KEV keyup[MAXKEYEVENTS];
|
||||
} testkeyset[]= {
|
||||
{ 2, { ALTDOWN, XDOWN }, { ALTUP, XUP}},
|
||||
{ 3, { ALTDOWN, XDOWN , SHIFTDOWN}, { ALTUP, XUP, SHIFTUP}},
|
||||
{ 3, { ALTDOWN, XDOWN , CTRLDOWN}, { ALTUP, XUP, CTRLUP}},
|
||||
{ 3, { SHIFTDOWN, XDOWN , CTRLDOWN}, { SHIFTUP, XUP, CTRLUP}},
|
||||
{ 0 } /* mark the end */
|
||||
};
|
||||
|
||||
/**********************adapted from input.c **********************************/
|
||||
|
||||
BYTE InputKeyStateTable[256];
|
||||
BYTE AsyncKeyStateTable[256];
|
||||
BYTE TrackSysKey = 0; /* determine whether ALT key up will cause a WM_SYSKEYUP
|
||||
or a WM_KEYUP message */
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned long count : 16;
|
||||
unsigned long code : 8;
|
||||
unsigned long extended : 1;
|
||||
unsigned long unused : 2;
|
||||
unsigned long win_internal : 2;
|
||||
unsigned long context : 1;
|
||||
unsigned long previous : 1;
|
||||
unsigned long transition : 1;
|
||||
} lp1;
|
||||
unsigned long lp2;
|
||||
} KEYLP;
|
||||
|
||||
int KbdMessage( KEV kev, WPARAM *pwParam, LPARAM *plParam )
|
||||
{
|
||||
UINT message;
|
||||
int VKey = GETVKEY[kev];
|
||||
KEYLP keylp;
|
||||
|
||||
keylp.lp2 = 0;
|
||||
|
||||
keylp.lp1.count = 1;
|
||||
keylp.lp1.code = GETSCAN[kev];
|
||||
keylp.lp1.extended = 0 ;/* FIXME (ki->dwFlags & KEYEVENTF_EXTENDEDKEY) != 0; */
|
||||
keylp.lp1.win_internal = 0;
|
||||
|
||||
if (GETUPDOWN[kev] & KEYEVENTF_KEYUP )
|
||||
{
|
||||
message = WM_KEYUP;
|
||||
if( (InputKeyStateTable[VK_MENU] & 0x80) && (
|
||||
(VKey == VK_MENU) || (VKey == VK_CONTROL) ||
|
||||
!(InputKeyStateTable[VK_CONTROL] & 0x80))) {
|
||||
if( TrackSysKey == VK_MENU || /* <ALT>-down/<ALT>-up sequence */
|
||||
(VKey != VK_MENU)) /* <ALT>-down...<something else>-up */
|
||||
message = WM_SYSKEYUP;
|
||||
TrackSysKey = 0;
|
||||
}
|
||||
InputKeyStateTable[VKey] &= ~0x80;
|
||||
keylp.lp1.previous = 1;
|
||||
keylp.lp1.transition = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
keylp.lp1.previous = (InputKeyStateTable[VKey] & 0x80) != 0;
|
||||
keylp.lp1.transition = 0;
|
||||
if (!(InputKeyStateTable[VKey] & 0x80)) InputKeyStateTable[VKey] ^= 0x01;
|
||||
InputKeyStateTable[VKey] |= 0x80;
|
||||
AsyncKeyStateTable[VKey] |= 0x80;
|
||||
|
||||
message = WM_KEYDOWN;
|
||||
if( (InputKeyStateTable[VK_MENU] & 0x80) &&
|
||||
!(InputKeyStateTable[VK_CONTROL] & 0x80)) {
|
||||
message = WM_SYSKEYDOWN;
|
||||
TrackSysKey = VKey;
|
||||
}
|
||||
}
|
||||
|
||||
keylp.lp1.context = (InputKeyStateTable[VK_MENU] & 0x80) != 0; /* 1 if alt */
|
||||
|
||||
if( plParam) *plParam = keylp.lp2;
|
||||
if( pwParam) *pwParam = VKey;
|
||||
return message;
|
||||
}
|
||||
|
||||
/****************************** end copy input.c ****************************/
|
||||
|
||||
/*
|
||||
* . prepare the keyevents for SendInputs
|
||||
* . calculate the "expected" messages
|
||||
* . Send the events to our window
|
||||
* . retrieve the messages from the input queue
|
||||
* . verify
|
||||
*/
|
||||
void do_test( HWND hwnd, int seqnr, KEV td[] )
|
||||
{
|
||||
HMODULE module;
|
||||
INPUT inputs[MAXKEYEVENTS];
|
||||
KMSG expmsg[MAXKEYEVENTS];
|
||||
MSG msg;
|
||||
char buf[100];
|
||||
UINT evtctr=0;
|
||||
int kmctr, i;
|
||||
|
||||
module = GetModuleHandleA("user32");
|
||||
if (!module) return;
|
||||
ptr_SendInput = (void *)GetProcAddress(module, "SendInput");
|
||||
if (!ptr_SendInput) return;
|
||||
|
||||
buf[0]='\0';
|
||||
TrackSysKey=0; /* see input.c */
|
||||
for( i = 0; i < MAXKEYEVENTS; i++) {
|
||||
ADDTOINPUTS(td[i])
|
||||
strcat(buf, getdesc[td[i]]);
|
||||
if(td[i])
|
||||
expmsg[i].message = KbdMessage(td[i], &(expmsg[i].wParam), &(expmsg[i].lParam)); /* see queue_kbd_event() */
|
||||
else
|
||||
expmsg[i].message = 0;
|
||||
}
|
||||
for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++)
|
||||
;
|
||||
assert( evtctr <= MAXKEYEVENTS );
|
||||
assert( evtctr == ptr_SendInput(evtctr, &inputs[0], sizeof(INPUT)));
|
||||
i = 0;
|
||||
trace("======== key stroke sequence #%d: %s =============\n",
|
||||
seqnr + 1, buf);
|
||||
while( PeekMessage(&msg,hwnd,WM_KEYFIRST,WM_KEYLAST,PM_REMOVE) ) {
|
||||
trace("message[%d] %-15s wParam %04x lParam %08lx time %lx\n", i,
|
||||
MSGNAME[msg.message - WM_KEYFIRST], msg.wParam, msg.lParam, msg.time);
|
||||
if( i < kmctr ) {
|
||||
ok( msg.message == expmsg[i].message &&
|
||||
msg.wParam == expmsg[i].wParam &&
|
||||
msg.lParam == expmsg[i].lParam,
|
||||
"wrong message! expected:\n"
|
||||
"message[%d] %-15s wParam %04x lParam %08lx\n",i,
|
||||
MSGNAME[(expmsg[i]).message - WM_KEYFIRST],
|
||||
expmsg[i].wParam, expmsg[i].lParam );
|
||||
}
|
||||
i++;
|
||||
}
|
||||
trace("%d messages retrieved\n", i);
|
||||
ok( i == kmctr, "message count is wrong: got %d expected: %d\n", i, kmctr);
|
||||
}
|
||||
|
||||
/* test all combinations of the specified key events */
|
||||
void TestASet( HWND hWnd, int nrkev, KEV kevdwn[], KEV kevup[] )
|
||||
{
|
||||
int i,j,k,l,m,n;
|
||||
static int count=0;
|
||||
KEV kbuf[MAXKEYEVENTS];
|
||||
assert( nrkev==2 || nrkev==3);
|
||||
for(i=0;i<MAXKEYEVENTS;i++) kbuf[i]=0;
|
||||
/* two keys involved gives 4 test cases */
|
||||
if(nrkev==2) {
|
||||
for(i=0;i<nrkev;i++) {
|
||||
for(j=0;j<nrkev;j++) {
|
||||
kbuf[0] = kevdwn[i];
|
||||
kbuf[1] = kevdwn[1-i];
|
||||
kbuf[2] = kevup[j];
|
||||
kbuf[3] = kevup[1-j];
|
||||
do_test( hWnd, count++, kbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* three keys involved gives 36 test cases */
|
||||
if(nrkev==3){
|
||||
for(i=0;i<nrkev;i++){
|
||||
for(j=0;j<nrkev;j++){
|
||||
if(j==i) continue;
|
||||
for(k=0;k<nrkev;k++){
|
||||
if(k==i || k==j) continue;
|
||||
for(l=0;l<nrkev;l++){
|
||||
for(m=0;m<nrkev;m++){
|
||||
if(m==l) continue;
|
||||
for(n=0;n<nrkev;n++){
|
||||
if(n==l ||n==m) continue;
|
||||
kbuf[0] = kevdwn[i];
|
||||
kbuf[1] = kevdwn[j];
|
||||
kbuf[2] = kevdwn[k];
|
||||
kbuf[3] = kevup[l];
|
||||
kbuf[4] = kevup[m];
|
||||
kbuf[5] = kevup[n];
|
||||
do_test( hWnd, count++, kbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* test each set specified in the global testkeyset array */
|
||||
void TestSysKeys( HWND hWnd)
|
||||
{
|
||||
int i;
|
||||
for(i=0; testkeyset[i].nrkev;i++)
|
||||
TestASet( hWnd, testkeyset[i].nrkev, testkeyset[i].keydwn,
|
||||
testkeyset[i].keyup);
|
||||
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_SETFOCUS:
|
||||
/* window has focus, now do the test */
|
||||
if( hWnd == hWndTest) TestSysKeys( hWnd);
|
||||
/* finished :-) */
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage( 0 );
|
||||
break;
|
||||
|
||||
default:
|
||||
return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
START_TEST(input)
|
||||
{
|
||||
MSG msg;
|
||||
WNDCLASSA wclass;
|
||||
HANDLE hInstance = GetModuleHandleA( NULL );
|
||||
|
||||
wclass.lpszClassName = "InputSysKeyTestClass";
|
||||
wclass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wclass.lpfnWndProc = (WNDPROC)WndProc;
|
||||
wclass.hInstance = hInstance;
|
||||
wclass.hIcon = LoadIconA( 0, (LPSTR)IDI_APPLICATION );
|
||||
wclass.hCursor = LoadCursorA( NULL, IDC_ARROW);
|
||||
wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1);
|
||||
wclass.lpszMenuName = 0;
|
||||
wclass.cbClsExtra = 0;
|
||||
wclass.cbWndExtra = 0;
|
||||
assert (RegisterClassA( &wclass ));
|
||||
/* create the test window that will receive the keystrokes */
|
||||
assert ( hWndTest = CreateWindowA( wclass.lpszClassName, "InputSysKeyTest",
|
||||
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100,
|
||||
NULL, NULL, hInstance, NULL) );
|
||||
ShowWindow( hWndTest, SW_SHOW);
|
||||
UpdateWindow( hWndTest);
|
||||
/* message loop */
|
||||
while( GetMessageA( &msg, 0, 0, 0 )) {
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessageA( &msg );
|
||||
}
|
||||
}
|
|
@ -1,173 +0,0 @@
|
|||
/* Unit test suite for list boxes.
|
||||
*
|
||||
* Copyright 2003 Ferenc Wagner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#ifdef VISIBLE
|
||||
#define WAIT Sleep (1000)
|
||||
#define REDRAW RedrawWindow (handle, NULL, 0, RDW_UPDATENOW)
|
||||
#else
|
||||
#define WAIT
|
||||
#define REDRAW
|
||||
#endif
|
||||
|
||||
HWND
|
||||
create_listbox (DWORD add_style)
|
||||
{
|
||||
HWND handle=CreateWindow ("LISTBOX", "TestList",
|
||||
(LBS_STANDARD & ~LBS_SORT) | add_style,
|
||||
0, 0, 100, 100,
|
||||
NULL, NULL, NULL, 0);
|
||||
|
||||
assert (handle);
|
||||
SendMessage (handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) "First added");
|
||||
SendMessage (handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) "Second added");
|
||||
SendMessage (handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) "Third added");
|
||||
|
||||
#ifdef VISIBLE
|
||||
ShowWindow (handle, SW_SHOW);
|
||||
#endif
|
||||
REDRAW;
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
struct listbox_prop {
|
||||
DWORD add_style;
|
||||
};
|
||||
|
||||
struct listbox_stat {
|
||||
int selected, anchor, caret, selcount;
|
||||
};
|
||||
|
||||
struct listbox_test {
|
||||
struct listbox_prop prop;
|
||||
struct listbox_stat init, init_todo;
|
||||
struct listbox_stat click, click_todo;
|
||||
struct listbox_stat step, step_todo;
|
||||
};
|
||||
|
||||
void
|
||||
listbox_query (HWND handle, struct listbox_stat *results)
|
||||
{
|
||||
results->selected = SendMessage (handle, LB_GETCURSEL, 0, 0);
|
||||
results->anchor = SendMessage (handle, LB_GETANCHORINDEX, 0, 0);
|
||||
results->caret = SendMessage (handle, LB_GETCARETINDEX, 0, 0);
|
||||
results->selcount = SendMessage (handle, LB_GETSELCOUNT, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
buttonpress (HWND handle, WORD x, WORD y)
|
||||
{
|
||||
LPARAM lp=x+(y<<16);
|
||||
|
||||
WAIT;
|
||||
SendMessage (handle, WM_LBUTTONDOWN, (WPARAM) MK_LBUTTON, lp);
|
||||
SendMessage (handle, WM_LBUTTONUP , (WPARAM) 0 , lp);
|
||||
REDRAW;
|
||||
}
|
||||
|
||||
void
|
||||
keypress (HWND handle, WPARAM keycode, BYTE scancode, BOOL extended)
|
||||
{
|
||||
LPARAM lp=1+(scancode<<16)+(extended?KEYEVENTF_EXTENDEDKEY:0);
|
||||
|
||||
WAIT;
|
||||
SendMessage (handle, WM_KEYDOWN, keycode, lp);
|
||||
SendMessage (handle, WM_KEYUP , keycode, lp | 0xc000000);
|
||||
REDRAW;
|
||||
}
|
||||
|
||||
#define listbox_field_ok(t, s, f, got) \
|
||||
ok (t.s.f==got.f, "style %#x, step " #s ", field " #f \
|
||||
": expected %d, got %d\n", (unsigned int)t.prop.add_style, \
|
||||
t.s.f, got.f)
|
||||
|
||||
#define listbox_todo_field_ok(t, s, f, got) \
|
||||
if (t.s##_todo.f) todo_wine { listbox_field_ok(t, s, f, got); } \
|
||||
else listbox_field_ok(t, s, f, got)
|
||||
|
||||
#define listbox_ok(t, s, got) \
|
||||
listbox_todo_field_ok(t, s, selected, got); \
|
||||
listbox_todo_field_ok(t, s, anchor, got); \
|
||||
listbox_todo_field_ok(t, s, caret, got); \
|
||||
listbox_todo_field_ok(t, s, selcount, got)
|
||||
|
||||
void
|
||||
check (const struct listbox_test test)
|
||||
{
|
||||
struct listbox_stat answer;
|
||||
HWND hLB=create_listbox (test.prop.add_style);
|
||||
RECT second_item;
|
||||
|
||||
listbox_query (hLB, &answer);
|
||||
listbox_ok (test, init, answer);
|
||||
|
||||
SendMessage (hLB, LB_GETITEMRECT, (WPARAM) 1, (LPARAM) &second_item);
|
||||
buttonpress(hLB, (WORD)second_item.left, (WORD)second_item.top);
|
||||
|
||||
listbox_query (hLB, &answer);
|
||||
listbox_ok (test, click, answer);
|
||||
|
||||
keypress (hLB, VK_DOWN, 0x50, TRUE);
|
||||
|
||||
listbox_query (hLB, &answer);
|
||||
listbox_ok (test, step, answer);
|
||||
|
||||
WAIT;
|
||||
DestroyWindow (hLB);
|
||||
}
|
||||
|
||||
START_TEST(listbox)
|
||||
{
|
||||
const struct listbox_test SS =
|
||||
/* {add_style} */
|
||||
{{0},
|
||||
{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
|
||||
{ 1, 1, 1, LB_ERR}, {0,1,0,0},
|
||||
{ 2, 2, 2, LB_ERR}, {0,1,0,0}};
|
||||
/* {selected, anchor, caret, selcount}{TODO fields} */
|
||||
const struct listbox_test SS_NS =
|
||||
{{LBS_NOSEL},
|
||||
{LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0},
|
||||
{ 1, 1, 1, LB_ERR}, {1,1,0,0},
|
||||
{ 2, 2, 2, LB_ERR}, {1,1,1,0}};
|
||||
const struct listbox_test MS =
|
||||
{{LBS_MULTIPLESEL},
|
||||
{ 0, LB_ERR, 0, 0}, {0,0,0,0},
|
||||
{ 1, 1, 1, 1}, {0,1,0,0},
|
||||
{ 2, 1, 2, 1}, {0,1,0,1}};
|
||||
const struct listbox_test MS_NS =
|
||||
{{LBS_MULTIPLESEL | LBS_NOSEL},
|
||||
{LB_ERR, LB_ERR, 0, LB_ERR}, {1,0,0,1},
|
||||
{ 1, 1, 1, LB_ERR}, {0,1,0,1},
|
||||
{ 2, 2, 2, LB_ERR}, {0,1,0,1}};
|
||||
|
||||
trace (" Testing single selection...\n");
|
||||
check (SS);
|
||||
trace (" ... with NOSEL\n");
|
||||
check (SS_NS);
|
||||
trace (" Testing multiple selection...\n");
|
||||
check (MS);
|
||||
trace (" ... with NOSEL\n");
|
||||
check (MS_NS);
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
# $Id: makefile,v 1.4 2004/09/10 23:30:45 sedwards Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
# require os code to explicitly request A/W version of structs/functions
|
||||
TARGET_CFLAGS += -D_DISABLE_TIDENTS -D__USE_W32API
|
||||
|
||||
TARGET_NAME = user32_test
|
||||
|
||||
TARGET_SDKLIBS = gdi32.a user32.a ntdll.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
testlist.o \
|
||||
class.o \
|
||||
dde.o \
|
||||
dialog.o \
|
||||
listbox.o \
|
||||
msg.o \
|
||||
resource.o \
|
||||
sysparams.o \
|
||||
win.o \
|
||||
wsprintf.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
File diff suppressed because it is too large
Load diff
|
@ -1,59 +0,0 @@
|
|||
/* Unit test suite for resources.
|
||||
*
|
||||
* Copyright 2004 Ferenc Wagner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
void
|
||||
test_LoadStringA (void)
|
||||
{
|
||||
HINSTANCE hInst = GetModuleHandle (NULL);
|
||||
static const char str[] = "String resource"; /* same in resource.rc */
|
||||
char buf[128];
|
||||
struct string_test {
|
||||
int bufsiz;
|
||||
int expected;
|
||||
};
|
||||
struct string_test tests[] = {{sizeof buf, sizeof str - 1},
|
||||
{sizeof str, sizeof str - 1},
|
||||
{sizeof str - 1, sizeof str - 2}};
|
||||
int i;
|
||||
|
||||
assert (sizeof str < sizeof buf);
|
||||
for (i = 0; i < sizeof tests / sizeof tests[0]; i++) {
|
||||
const int bufsiz = tests[i].bufsiz;
|
||||
const int expected = tests[i].expected;
|
||||
const int len = LoadStringA (hInst, 0, buf, bufsiz);
|
||||
|
||||
ok (len == expected, "bufsiz=%d: got %d, expected %d\n",
|
||||
bufsiz, len, expected);
|
||||
ok (!memcmp (buf, str, len),
|
||||
"bufsiz=%d: got '%s', expected '%.*s'\n",
|
||||
bufsiz, buf, len, str);
|
||||
ok (buf[len] == 0, "bufsiz=%d: NUL termination missing\n",
|
||||
bufsiz);
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(resource)
|
||||
{
|
||||
test_LoadStringA ();
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,42 +0,0 @@
|
|||
/* Automatically generated file; DO NOT EDIT!! */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
extern void func_class(void);
|
||||
extern void func_dde(void);
|
||||
extern void func_dialog(void);
|
||||
//extern void func_input(void);
|
||||
extern void func_listbox(void);
|
||||
extern void func_msg(void);
|
||||
extern void func_resource(void);
|
||||
extern void func_sysparams(void);
|
||||
extern void func_win(void);
|
||||
extern void func_wsprintf(void);
|
||||
|
||||
struct test
|
||||
{
|
||||
const char *name;
|
||||
void (*func)(void);
|
||||
};
|
||||
|
||||
static const struct test winetest_testlist[] =
|
||||
{
|
||||
{ "class", func_class },
|
||||
{ "dde", func_dde },
|
||||
{ "dialog", func_dialog },
|
||||
//{ "input", func_input },
|
||||
{ "listbox", func_listbox },
|
||||
{ "msg", func_msg },
|
||||
{ "resource", func_resource },
|
||||
{ "sysparams", func_sysparams },
|
||||
{ "win", func_win },
|
||||
{ "wsprintf", func_wsprintf },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
#define WINETEST_WANT_MAIN
|
||||
#include "wine/test.h"
|
File diff suppressed because it is too large
Load diff
|
@ -1,57 +0,0 @@
|
|||
/* Unit test suite for the wsprintf functions
|
||||
*
|
||||
* Copyright 2002 Bill Medland
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
|
||||
static void wsprintfATest(void)
|
||||
{
|
||||
char buf[25];
|
||||
int rc;
|
||||
|
||||
rc=wsprintfA(buf, "%010ld", -1);
|
||||
ok(rc == 10, "wsPrintfA length failure: rc=%d error=%ld\n",rc,GetLastError());
|
||||
ok((lstrcmpA(buf, "-000000001") == 0),
|
||||
"wsprintfA zero padded negative value failure: buf=[%s]\n",buf);
|
||||
}
|
||||
|
||||
static void wsprintfWTest(void)
|
||||
{
|
||||
static const WCHAR fmt[] = {'%','0','1','0','l','d','\0'};
|
||||
static const WCHAR target[] = {'-','0','0','0','0','0','0','0','0','1', '\0'};
|
||||
WCHAR buf[25];
|
||||
int rc;
|
||||
|
||||
rc=wsprintfW(buf, fmt, -1);
|
||||
if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
||||
return;
|
||||
ok(rc == 10, "wsPrintfW length failure: rc=%d error=%ld\n",rc,GetLastError());
|
||||
ok((lstrcmpW(buf, target) == 0),
|
||||
"wsprintfW zero padded negative value failure\n");
|
||||
}
|
||||
|
||||
START_TEST(wsprintf)
|
||||
{
|
||||
wsprintfATest();
|
||||
wsprintfWTest();
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: Makefile,v 1.7 2003/11/14 17:13:22 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = console
|
||||
|
||||
TARGET_NAME = vmtest
|
||||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a
|
||||
|
||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||
|
||||
TARGET_CFLAGS = -Wall -Werror
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
||||
include $(TOOLS_PATH)/helper.mk
|
||||
|
||||
# EOF
|
|
@ -1,55 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
PVOID Base;
|
||||
PVOID Ret;
|
||||
|
||||
Base = VirtualAlloc(NULL,
|
||||
1048576,
|
||||
MEM_RESERVE,
|
||||
PAGE_READWRITE);
|
||||
if (Base == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 1\n");
|
||||
}
|
||||
|
||||
Ret = VirtualAlloc(Base + 4096,
|
||||
4096,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
if (Ret == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 2\n");
|
||||
}
|
||||
|
||||
Ret = VirtualAlloc(Base + 12288,
|
||||
4096,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
if (Ret == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 3\n");
|
||||
}
|
||||
|
||||
Ret = VirtualAlloc(Base + 20480,
|
||||
4096,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
if (Ret == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 4\n");
|
||||
}
|
||||
|
||||
Ret = VirtualAlloc(Base + 4096,
|
||||
28672,
|
||||
MEM_RESERVE,
|
||||
PAGE_READWRITE);
|
||||
if (Ret == NULL)
|
||||
{
|
||||
printf("VirtualAlloc failed 5\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
*.o
|
||||
*.d
|
||||
*.exe
|
||||
*.coff
|
||||
*.sym
|
||||
*.map
|
|
@ -1,23 +0,0 @@
|
|||
# $Id: makefile,v 1.5 2003/11/14 17:13:22 weiden Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
TARGET_NORC = yes
|
||||
|
||||
TARGET_TYPE = program
|
||||
|
||||
TARGET_APPTYPE = windows
|
||||
|
||||
TARGET_NAME = winhello
|
||||
|
||||
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
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue