From 07d2bba441dcf65c2a2c43fcb5a854029af4c538 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Tue, 27 May 2003 20:51:39 +0000 Subject: [PATCH] - Added icontest (contributed by Tim Jobling). svn path=/trunk/; revision=4782 --- reactos/apps/tests/icontest/.cvsignore | 5 + reactos/apps/tests/icontest/icon.ico | Bin 0 -> 766 bytes reactos/apps/tests/icontest/icontest.c | 144 ++++++++++++++++++++++++ reactos/apps/tests/icontest/icontest.rc | 5 + reactos/apps/tests/icontest/makefile | 19 ++++ reactos/apps/tests/icontest/resource.h | 1 + 6 files changed, 174 insertions(+) create mode 100644 reactos/apps/tests/icontest/.cvsignore create mode 100644 reactos/apps/tests/icontest/icon.ico create mode 100644 reactos/apps/tests/icontest/icontest.c create mode 100644 reactos/apps/tests/icontest/icontest.rc create mode 100644 reactos/apps/tests/icontest/makefile create mode 100644 reactos/apps/tests/icontest/resource.h diff --git a/reactos/apps/tests/icontest/.cvsignore b/reactos/apps/tests/icontest/.cvsignore new file mode 100644 index 00000000000..7e878167e8e --- /dev/null +++ b/reactos/apps/tests/icontest/.cvsignore @@ -0,0 +1,5 @@ +*.o +*.d +*.exe +*.coff +*.sym diff --git a/reactos/apps/tests/icontest/icon.ico b/reactos/apps/tests/icontest/icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..746b9be45a057fa2c0111e079955a733c655d4e5 GIT binary patch literal 766 zcmZ{iv2uej5JZ=d88S9APLcn%QsOz)*{@oMAe>gRuof_QZ+nnN<^C^zT3p{YL8!w!v!|~LxQ1AyP zTijSt@0`ov%z|(n$B7$5Nm|&@I?n!n=t?gHs2{FFmjV#mm7D@%+dF#z{2`)z1p*mF zX9mcQ&I}Ntc;Z&}iaTK{s9)D6RtM(^)l$45H^U!VIq~}xW61qF`~a6P;P?rgsLPF4 qB)GC@$f<%l@X{O=W0#7$593vx6@Xm20R?*ea{OajUp8X31aqG$e literal 0 HcmV?d00001 diff --git a/reactos/apps/tests/icontest/icontest.c b/reactos/apps/tests/icontest/icontest.c new file mode 100644 index 00000000000..2d0fe0da242 --- /dev/null +++ b/reactos/apps/tests/icontest/icontest.c @@ -0,0 +1,144 @@ +#include +#include "resource.h" + +const char titleDrwIco[] = "DrawIcon Output"; +const char titleMask[] = "Mask(AND image)"; +const char titleXor[] = "XOR(color image)"; +const char file[] = "Icon from file:"; +const char res[] = "Icon from Resorce:"; + +HFONT tf; +HINSTANCE hInst; + +LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM); + +int WINAPI +WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) +{ + hInst = hInstance; + WNDCLASS wc; + MSG msg; + HWND hWnd; + + wc.lpszClassName = "IconTestClass"; + wc.lpfnWndProc = MainWndProc; + wc.style = CS_VREDRAW | CS_HREDRAW; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH); + wc.lpszMenuName = NULL; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + if (RegisterClass(&wc) == 0) + { + DbgPrint("RegisterClass failed (last error 0x%X)\n", GetLastError()); + return(1); + } + + hWnd = CreateWindow("IconTestClass", + "Icon Test", + WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL, + CW_USEDEFAULT, + CW_USEDEFAULT, + 455, + 320, + NULL, + NULL, + hInstance, + NULL); + if (hWnd == NULL) + { + DbgPrint("CreateWindow failed (last error 0x%X)\n", GetLastError()); + return(1); + } + + tf = CreateFontA(14,0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE, + ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons"); + + ShowWindow(hWnd, nCmdShow); + + while(GetMessage(&msg, NULL, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return msg.wParam; +} + +LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + PAINTSTRUCT ps; + HDC hDC; + HICON hIcon; + HGDIOBJ hOld; + HDC hMemDC; + ICONINFO iconinfo; + HBITMAP hMaskBitmap; + HBITMAP hColorBitmap; + + switch(msg) + { + case WM_PAINT: + hDC = BeginPaint(hWnd, &ps); + SelectObject(hDC, tf); + SetBkMode(hDC, TRANSPARENT); + + TextOut(hDC, 160, 10, file, strlen(file)); + TextOut(hDC, 15, 85, titleDrwIco, strlen(titleDrwIco)); + TextOut(hDC, 160, 85, titleMask, strlen(titleMask)); + TextOut(hDC, 300, 85, titleXor, strlen(titleXor)); + + hIcon = LoadImage(NULL, "icon.ICO", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE|LR_LOADFROMFILE); + DrawIcon(hDC,50,50,hIcon); + + hMemDC = CreateCompatibleDC(hDC); + GetIconInfo(hIcon, &iconinfo); + DestroyIcon(hIcon); + + hOld = SelectObject(hMemDC, iconinfo.hbmMask); + BitBlt(hDC, 200, 50, 32, 32, hMemDC, 0, 0, SRCCOPY); + SelectObject(hMemDC, iconinfo.hbmColor); + BitBlt(hDC, 350, 50, 32, 32, hMemDC, 0, 0, SRCCOPY); + + DeleteObject(iconinfo.hbmMask); + DeleteObject(iconinfo.hbmColor); + + SelectObject(hMemDC, hOld); + + TextOut(hDC, 145, 150, res, strlen(res)); + TextOut(hDC, 15, 225, titleDrwIco, strlen(titleDrwIco)); + TextOut(hDC, 160, 225, titleMask, strlen(titleMask)); + TextOut(hDC, 300, 225, titleXor, strlen(titleXor)); + + hIcon = LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); + DrawIcon(hDC,50,190,hIcon); + + GetIconInfo(hIcon, &iconinfo); + DestroyIcon(hIcon); + + hOld = SelectObject(hMemDC, iconinfo.hbmMask); + BitBlt(hDC, 200, 190, 32, 32, hMemDC, 0, 0, SRCCOPY); + SelectObject(hMemDC, iconinfo.hbmColor); + BitBlt(hDC, 350, 190, 32, 32, hMemDC, 0, 0, SRCCOPY); + + DeleteObject(iconinfo.hbmMask); + DeleteObject(iconinfo.hbmColor); + DeleteObject(hMemDC); + EndPaint(hWnd, &ps); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + default: + return DefWindowProc(hWnd, msg, wParam, lParam); + } + return 0; +} diff --git a/reactos/apps/tests/icontest/icontest.rc b/reactos/apps/tests/icontest/icontest.rc new file mode 100644 index 00000000000..d5642bb4249 --- /dev/null +++ b/reactos/apps/tests/icontest/icontest.rc @@ -0,0 +1,5 @@ +#include +#include +#include "resource.h" + +IDI_ICON ICON DISCARDABLE "ICON.ICO" diff --git a/reactos/apps/tests/icontest/makefile b/reactos/apps/tests/icontest/makefile new file mode 100644 index 00000000000..de02a8aa57b --- /dev/null +++ b/reactos/apps/tests/icontest/makefile @@ -0,0 +1,19 @@ +PATH_TO_TOP = ../../.. + +TARGET_NORC = no + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = icontest + +TARGET_SDKLIBS = ntdll.a kernel32.a gdi32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/reactos/apps/tests/icontest/resource.h b/reactos/apps/tests/icontest/resource.h new file mode 100644 index 00000000000..5d9eb75e1c4 --- /dev/null +++ b/reactos/apps/tests/icontest/resource.h @@ -0,0 +1 @@ +#define IDI_ICON 101