mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
Testapps for NtUserDrawCaption. (I sent the patch to ros-dev for review)
svn path=/trunk/; revision=23137
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||
<group>
|
||||
<directory name="user32">
|
||||
<xi:include href="user32/user32.rbuild" />
|
||||
</directory>
|
||||
</group>
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright 2006 Saveliy Tretiakov
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "windows.h"
|
||||
#include "stdio.h"
|
||||
#include "resource.h"
|
||||
|
||||
WCHAR WndClass[] = L"capicon_class";
|
||||
|
||||
HINSTANCE hInst;
|
||||
INT testnum = 0;
|
||||
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd,
|
||||
UINT msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
HICON hIcon;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case WM_GETICON:
|
||||
if(testnum>2)
|
||||
{
|
||||
if(wParam == ICON_SMALL)
|
||||
hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON2SM));
|
||||
else if(wParam == ICON_BIG)
|
||||
hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON2BIG));
|
||||
else hIcon = (HICON)1;
|
||||
|
||||
if(!hIcon)
|
||||
{
|
||||
printf("LoadIcon() failed: %d\n", (INT)GetLastError());
|
||||
break;
|
||||
}
|
||||
|
||||
return (LRESULT)hIcon;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
INT main(INT argc, CHAR **argv)
|
||||
{
|
||||
HWND hWnd;
|
||||
MSG msg;
|
||||
WNDCLASSEX wcx;
|
||||
UINT result;
|
||||
|
||||
if(argc<2)
|
||||
{
|
||||
printf("DrawCaption icon test.\n");
|
||||
printf("USAGE: drawcap.exe <testnumber>\n\n");
|
||||
printf("Available tests:\n"
|
||||
"1. Class small icon\n"
|
||||
"2. Class big icon\n"
|
||||
"3. Class small icon + WM_GETICON\n"
|
||||
"4. Class big icon + WM_GETICON\n"
|
||||
"5. WM_GETICON only\n\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
testnum = atoi(argv[1]);
|
||||
if(testnum < 1 || testnum > 5)
|
||||
{
|
||||
printf("Unknown test %d\n", testnum);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hInst = GetModuleHandle(NULL);
|
||||
|
||||
memset(&wcx, 0, sizeof(wcx));
|
||||
wcx.cbSize = sizeof(wcx);
|
||||
wcx.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcx.lpfnWndProc = (WNDPROC) WndProc;
|
||||
wcx.hInstance = hInst;
|
||||
wcx.hbrBackground = (HBRUSH)COLOR_WINDOW;
|
||||
wcx.lpszClassName = WndClass;
|
||||
if(testnum<5)wcx.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON1BIG));
|
||||
if(testnum == 1 || testnum == 3)
|
||||
wcx.hIconSm = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON1SM));
|
||||
|
||||
if(!(result = RegisterClassEx(&wcx)))
|
||||
{
|
||||
printf("Shit! RegisterClassEx failed: %d\n",
|
||||
(int)GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(0,
|
||||
WndClass,
|
||||
L"DrawCaption icon test",
|
||||
WS_OVERLAPPED|WS_THICKFRAME|WS_SYSMENU,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
250,
|
||||
100,
|
||||
NULL,
|
||||
0,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
if(!hWnd)
|
||||
{
|
||||
printf("Shit! Can't create wnd!\n");
|
||||
UnregisterClass(WndClass, hInst);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
ShowWindow(hWnd, SW_SHOW);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0 ))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
UnregisterClass(WndClass, hInst);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS DrawCaption icon test\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "capicon\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "capicon.exe\0"
|
||||
#include <reactos/version.rc>
|
||||
|
||||
ID_ICON1BIG ICON res\icon1big.ico
|
||||
ID_ICON1SM ICON res\icon1sm.ico
|
||||
ID_ICON2BIG ICON res\icon2big.ico
|
||||
ID_ICON2SM ICON res\icon2sm.ico
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* Copyright 2006 Saveliy Tretiakov
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "windows.h"
|
||||
#include "resource.h"
|
||||
#include "stdio.h"
|
||||
|
||||
WCHAR CaptWndClass[] = L"captwnd_class";
|
||||
|
||||
HINSTANCE hInst;
|
||||
INT testnum = 0;
|
||||
|
||||
//BOOL STDCALL (*DrawCaptionTemp) (
|
||||
// HWND hwnd,
|
||||
// HDC hdc,
|
||||
// const RECT *rect,
|
||||
// HFONT hFont,
|
||||
// HICON hIcon,
|
||||
// LPCWSTR str,
|
||||
// UINT uFlags);
|
||||
|
||||
VOID CapTest(HWND hWnd,
|
||||
HDC hDc,
|
||||
LPRECT pR,
|
||||
WCHAR *Text,
|
||||
DWORD Flags,
|
||||
WCHAR *AddonStr,
|
||||
DWORD Addon)
|
||||
{
|
||||
WCHAR Buf[512];
|
||||
|
||||
lstrcpy(Buf, AddonStr);
|
||||
if(lstrlen(Buf))lstrcat(Buf, L" | ");
|
||||
lstrcat(Buf, Text);
|
||||
|
||||
DrawText( hDc, Buf, lstrlen(Buf), pR, DT_LEFT );
|
||||
|
||||
pR->top+=20;
|
||||
pR->bottom+=20;
|
||||
|
||||
if(!DrawCaption(hWnd, hDc, pR, Flags | Addon))
|
||||
{
|
||||
printf("PAINT: DrawCaption failed: %d\n", (int)GetLastError());
|
||||
}
|
||||
|
||||
pR->top+=30;
|
||||
pR->bottom+=30;
|
||||
}
|
||||
|
||||
VOID DrawCaptionTest(HWND hWnd, HDC hDc, WCHAR *AddonStr, DWORD Addon)
|
||||
{
|
||||
RECT Rect;
|
||||
GetClientRect(hWnd, &Rect);
|
||||
Rect.bottom = 30;
|
||||
Rect.left = 10;
|
||||
Rect.right-=10;
|
||||
Rect.top = 10;
|
||||
|
||||
CapTest(hWnd, hDc, &Rect, L"DC_TEXT:", DC_TEXT, AddonStr, Addon);
|
||||
|
||||
CapTest(hWnd, hDc, &Rect,
|
||||
L"DC_TEXT | DC_ACTIVE:",
|
||||
DC_TEXT | DC_ACTIVE,
|
||||
AddonStr, Addon);
|
||||
|
||||
CapTest(hWnd, hDc, &Rect,
|
||||
L"DC_TEXT | DC_ICON:" ,
|
||||
DC_TEXT | DC_ICON,
|
||||
AddonStr, Addon);
|
||||
|
||||
CapTest(hWnd, hDc, &Rect,
|
||||
L"DC_TEXT | DC_ACTIVE | DC_ICON:" ,
|
||||
DC_TEXT | DC_ACTIVE | DC_ICON,
|
||||
AddonStr, Addon);
|
||||
|
||||
CapTest(hWnd, hDc, &Rect,
|
||||
L"DC_TEXT | DC_INBUTTON:" ,
|
||||
DC_TEXT | DC_INBUTTON,
|
||||
AddonStr, Addon);
|
||||
|
||||
CapTest(hWnd, hDc, &Rect,
|
||||
L"DC_TEXT | DC_ACTIVE | DC_INBUTTON:" ,
|
||||
DC_TEXT | DC_ACTIVE | DC_INBUTTON,
|
||||
AddonStr, Addon);
|
||||
|
||||
CapTest(hWnd, hDc, &Rect,
|
||||
L"DC_TEXT | DC_ICON | DC_INBUTTON:" ,
|
||||
DC_TEXT | DC_ICON | DC_INBUTTON,
|
||||
AddonStr, Addon);
|
||||
|
||||
CapTest(hWnd, hDc, &Rect,
|
||||
L"DC_TEXT | DC_ACTIVE | DC_ICON | DC_INBUTTON:" ,
|
||||
DC_TEXT | DC_ACTIVE | DC_ICON | DC_INBUTTON,
|
||||
AddonStr, Addon);
|
||||
|
||||
}
|
||||
|
||||
LRESULT CALLBACK CaptWndProc(HWND hWnd,
|
||||
UINT msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
HDC hDc;
|
||||
PAINTSTRUCT Ps;
|
||||
|
||||
hDc = BeginPaint(hWnd, &Ps);
|
||||
SetBkMode( hDc, TRANSPARENT );
|
||||
|
||||
switch(testnum)
|
||||
{
|
||||
case 1:
|
||||
DrawCaptionTest(hWnd, hDc, L"", 0);
|
||||
break;
|
||||
case 2:
|
||||
DrawCaptionTest(hWnd, hDc, L"DC_GRADIENT", DC_GRADIENT);
|
||||
break;
|
||||
case 3:
|
||||
DrawCaptionTest(hWnd, hDc, L"DC_SMALLCAP", DC_SMALLCAP);
|
||||
break;
|
||||
case 4:
|
||||
DrawCaptionTest(hWnd, hDc, L"DC_BUTTONS", DC_BUTTONS);
|
||||
break;
|
||||
case 5:
|
||||
DrawCaptionTest(hWnd, hDc,
|
||||
L"DC_GRADIENT | DC_SMALLCAP",
|
||||
DC_GRADIENT | DC_SMALLCAP);
|
||||
break;
|
||||
case 6:
|
||||
DrawCaptionTest(hWnd, hDc,
|
||||
L"DC_GRADIENT | DC_BUTTONS",
|
||||
DC_GRADIENT | DC_BUTTONS);
|
||||
break;
|
||||
case 7:
|
||||
DrawCaptionTest(hWnd, hDc,
|
||||
L"DC_BUTTONS | DC_SMALLCAP",
|
||||
DC_BUTTONS | DC_SMALLCAP);
|
||||
break;
|
||||
case 8:
|
||||
DrawCaptionTest(hWnd, hDc,
|
||||
L"DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT",
|
||||
DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT);
|
||||
break;
|
||||
}
|
||||
|
||||
EndPaint(hWnd, &Ps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
INT main(INT argc, CHAR **argv)
|
||||
{
|
||||
HWND hWnd;
|
||||
MSG msg;
|
||||
WNDCLASSEX wcx;
|
||||
UINT result;
|
||||
HBRUSH hBr;
|
||||
//HMODULE hLib;
|
||||
|
||||
if(argc<2)
|
||||
{
|
||||
printf("DrawCaption testcode.\n");
|
||||
printf("USAGE: drawcap.exe <testnumber> [useicon]\n\n");
|
||||
printf("Available tests:\n"
|
||||
"1. DrawCaption test\n"
|
||||
"2. DrawCaption test + DC_GRADIENT\n"
|
||||
"3. DrawCaption test + DC_SMALLCAP\n"
|
||||
"4. DrawCaption test + DC_BUTTONS\n"
|
||||
"5. DrawCaption test + DC_GRADIENT | DC_SMALLCAP\n"
|
||||
"6. DrawCaption test + DC_GRADIENT | DC_BUTTONS\n"
|
||||
"7. DrawCaption test + DC_BUTTONS | DC_SMALLCAP\n"
|
||||
"8. DrawCaption test + DC_BUTTONS | DC_SMALLCAP | DC_GRADIENT\n\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
testnum = atoi(argv[1]);
|
||||
if(testnum < 1 || testnum > 8)
|
||||
{
|
||||
printf("Unknown test %d\n", testnum);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hInst = GetModuleHandle(NULL);
|
||||
|
||||
//hLib = LoadLibrary(L"user32");
|
||||
//if(!hLib)
|
||||
//{
|
||||
// printf("Shit! Can't load user32.dll\n");
|
||||
// return 1;
|
||||
//}
|
||||
|
||||
//DrawCaptionTemp = GetProcAddress(hLib, "DrawCaptionTempW");
|
||||
//if(!DrawCaptionTemp)
|
||||
//{
|
||||
// printf("Shit! Can't get DrawCaptionTemp address\n");
|
||||
// return 1;
|
||||
//}
|
||||
|
||||
hBr = CreateSolidBrush(RGB(255, 255, 255));
|
||||
if(!hBr)
|
||||
{
|
||||
printf("Shit! Can't create brush.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(&wcx, 0, sizeof(wcx));
|
||||
wcx.cbSize = sizeof(wcx);
|
||||
wcx.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcx.lpfnWndProc = (WNDPROC) CaptWndProc;
|
||||
wcx.hInstance = hInst;
|
||||
wcx.hbrBackground = hBr;
|
||||
wcx.lpszClassName = CaptWndClass;
|
||||
if(argc > 2) wcx.hIconSm = LoadIcon(hInst, MAKEINTRESOURCE(ID_ICON1SM));
|
||||
|
||||
if(!(result = RegisterClassEx(&wcx)))
|
||||
{
|
||||
printf("Shit! RegisterClassEx failed: %d\n",
|
||||
(int)GetLastError());
|
||||
DeleteObject(hBr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
hWnd = CreateWindowEx(0,
|
||||
CaptWndClass,
|
||||
L"DrawCaption test",
|
||||
WS_OVERLAPPED|WS_THICKFRAME|WS_SYSMENU,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
600,
|
||||
470,
|
||||
NULL,
|
||||
0,
|
||||
hInst,
|
||||
NULL);
|
||||
|
||||
if(!hWnd)
|
||||
{
|
||||
printf("Shit! Can't create wnd!\n");
|
||||
UnregisterClass(CaptWndClass, hInst);
|
||||
DeleteObject(hBr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
ShowWindow(hWnd, SW_SHOW);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
while(GetMessage(&msg, NULL, 0, 0 ))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
DeleteObject(hBr);
|
||||
UnregisterClass(CaptWndClass, hInst);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS DrawCaption test\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "drawcap\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "drawcap.exe\0"
|
||||
#include <reactos/version.rc>
|
||||
|
||||
ID_ICON1SM ICON res\icon1sm.ico
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<module name="drawcap" type="win32cui" installbase="system32" installname="drawcap.exe">
|
||||
<include base="drawcap">.</include>
|
||||
<define name="__USE_W32API" />
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<define name="_WIN32_IE">0x0500</define>
|
||||
<define name="_WIN32_WINNT">0x0600</define>
|
||||
<define name="WINVER">0x0600</define>
|
||||
<library>kernel32</library>
|
||||
<library>user32</library>
|
||||
<library>gdi32</library>
|
||||
<file>drawcap.c</file>
|
||||
<file>drawcap.rc</file>
|
||||
</module>
|
||||
|
||||
<module name="capicon" type="win32cui" installbase="system32" installname="capicon.exe">
|
||||
<include base="capicon">.</include>
|
||||
<define name="__USE_W32API" />
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<define name="_WIN32_IE">0x0500</define>
|
||||
<define name="_WIN32_WINNT">0x0600</define>
|
||||
<define name="WINVER">0x0600</define>
|
||||
<library>kernel32</library>
|
||||
<library>user32</library>
|
||||
<library>gdi32</library>
|
||||
<file>capicon.c</file>
|
||||
<file>capicon.rc</file>
|
||||
</module>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 318 B |
@@ -0,0 +1,10 @@
|
||||
#ifndef _CAPICON_RESOURCE_H
|
||||
#define _CAPICON_RESOURCE_H
|
||||
|
||||
#define ID_ICON1BIG 101
|
||||
#define ID_ICON1SM 102
|
||||
#define ID_ICON2BIG 103
|
||||
#define ID_ICON2SM 104
|
||||
|
||||
|
||||
#endif /* _CAPICON_RESOURCE_H */
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE project SYSTEM "tools/rbuild/project.dtd">
|
||||
<group>
|
||||
<directory name="drawcaption">
|
||||
<xi:include href="drawcaption/drawcaption.rbuild" />
|
||||
</directory>
|
||||
</group>
|
||||
Reference in New Issue
Block a user