Stefan Dösinger : user32: Destroying the current cursor results in an error.
Alexandre Julliard
julliard at winehq.org
Fri Nov 30 07:56:22 CST 2007
Module: wine
Branch: master
Commit: abf524031081d6f8c5fb37da722e3f295d753176
URL: http://source.winehq.org/git/wine.git/?a=commit;h=abf524031081d6f8c5fb37da722e3f295d753176
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Thu Nov 29 00:08:35 2007 +0100
user32: Destroying the current cursor results in an error.
---
dlls/user32/cursoricon.c | 2 +-
dlls/user32/tests/cursoricon.c | 47 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index d528bee..8a2a005 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -1347,7 +1347,7 @@ WORD WINAPI DestroyIcon32( HGLOBAL16 handle, UINT16 flags )
if ( get_user_thread_info()->cursor == HICON_32(handle) )
{
WARN_(cursor)("Destroying active cursor!\n" );
- SetCursor( 0 );
+ return FALSE;
}
/* Try shared cursor/icon first */
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
index 84b9fe3..9858e32 100644
--- a/dlls/user32/tests/cursoricon.c
+++ b/dlls/user32/tests/cursoricon.c
@@ -373,6 +373,52 @@ static void test_CreateIcon(void)
DeleteObject(hbmColor);
}
+static void test_DestroyCursor(void)
+{
+ static const BYTE bmp_bits[4096];
+ ICONINFO cursorInfo;
+ HCURSOR cursor, cursor2;
+ BOOL ret;
+ DWORD error;
+ UINT display_bpp;
+ HDC hdc;
+
+ hdc = GetDC(0);
+ display_bpp = GetDeviceCaps(hdc, BITSPIXEL);
+ ReleaseDC(0, hdc);
+
+ cursorInfo.fIcon = FALSE;
+ cursorInfo.xHotspot = 0;
+ cursorInfo.yHotspot = 0;
+ cursorInfo.hbmMask = CreateBitmap(32, 32, 1, 1, bmp_bits);
+ cursorInfo.hbmColor = CreateBitmap(32, 32, 1, display_bpp, bmp_bits);
+
+ cursor = CreateIconIndirect(&cursorInfo);
+ ok(cursor != NULL, "CreateIconIndirect returned %p\n", cursor);
+ if(!cursor) {
+ return;
+ }
+ SetCursor(cursor);
+
+ SetLastError(0xdeadbeef);
+ ret = DestroyCursor(cursor);
+ ok(!ret, "DestroyCursor on the active cursor succeeded\n");
+ error = GetLastError();
+ ok(error == 0xdeadbeef, "Last error: %u\n", error);
+
+ cursor2 = GetCursor();
+ ok(cursor2 == cursor, "Active was set to %p when trying to destroy it\n", cursor2);
+
+ SetCursor(NULL);
+
+ /* Trying to destroy the cursor properly fails now for some reason with ERROR_INVALID_CURSOR_HANDLE */
+ ret = DestroyCursor(cursor);
+ /* ok(ret, "DestroyCursor failed, GetLastError=%d\n", GetLastError()); */
+
+ DeleteObject(cursorInfo.hbmMask);
+ DeleteObject(cursorInfo.hbmColor);
+}
+
START_TEST(cursoricon)
{
test_CopyImage_Bitmap(1);
@@ -382,4 +428,5 @@ START_TEST(cursoricon)
test_CopyImage_Bitmap(24);
test_CopyImage_Bitmap(32);
test_CreateIcon();
+ test_DestroyCursor();
}
More information about the wine-cvs
mailing list