Author: rharabien
Date: Wed Oct 19 16:17:32 2011
New Revision: 54199
URL:
http://svn.reactos.org/svn/reactos?rev=54199&view=rev
Log:
[USER32] - Simplify DrawCaret
Modified:
trunk/reactos/dll/win32/user32/windows/caret.c
Modified: trunk/reactos/dll/win32/user32/windows/caret.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/c…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/caret.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/caret.c [iso-8859-1] Wed Oct 19 16:17:32 2011
@@ -31,53 +31,56 @@
#include <user32.h>
#include <wine/debug.h>
+WINE_DEFAULT_DEBUG_CHANNEL(user32);
+
/* FUNCTIONS *****************************************************************/
void
DrawCaret(HWND hWnd,
PTHRDCARETINFO CaretInfo)
{
- HDC hDC, hComp;
+ HDC hdc, hdcMem;
+ HBITMAP hbmOld;
+ BOOL bDone = FALSE;
- hDC = GetDC(hWnd);
- if(hDC)
+ hdc = GetDC(hWnd);
+ if (!hdc)
{
- if(CaretInfo->Bitmap && GetBitmapDimensionEx(CaretInfo->Bitmap,
&CaretInfo->Size))
+ ERR("GetDC failed\n");
+ return;
+ }
+
+ if(CaretInfo->Bitmap && GetBitmapDimensionEx(CaretInfo->Bitmap,
&CaretInfo->Size))
+ {
+ hdcMem = CreateCompatibleDC(hdc);
+ if (hdcMem)
{
- hComp = CreateCompatibleDC(hDC);
- if(hComp)
- {
- SelectObject(hComp, CaretInfo->Bitmap);
- BitBlt(hDC,
- CaretInfo->Pos.x,
- CaretInfo->Pos.y,
- CaretInfo->Size.cx,
- CaretInfo->Size.cy,
- hComp,
- 0,
- 0,
- SRCINVERT);
- DeleteDC(hComp);
- }
- else
- PatBlt(hDC,
- CaretInfo->Pos.x,
- CaretInfo->Pos.y,
- CaretInfo->Size.cx,
- CaretInfo->Size.cy,
- DSTINVERT);
+ hbmOld = SelectObject(hdcMem, CaretInfo->Bitmap);
+ bDone = BitBlt(hdc,
+ CaretInfo->Pos.x,
+ CaretInfo->Pos.y,
+ CaretInfo->Size.cx,
+ CaretInfo->Size.cy,
+ hdcMem,
+ 0,
+ 0,
+ SRCINVERT);
+ SelectObject(hdcMem, hbmOld);
+ DeleteDC(hdcMem);
}
- else
- {
- PatBlt(hDC,
- CaretInfo->Pos.x,
- CaretInfo->Pos.y,
- CaretInfo->Size.cx,
- CaretInfo->Size.cy,
- DSTINVERT);
- }
- ReleaseDC(hWnd, hDC);
}
+
+ if (!bDone)
+ {
+ PatBlt(hdc,
+ CaretInfo->Pos.x,
+ CaretInfo->Pos.y,
+ CaretInfo->Size.cx,
+ CaretInfo->Size.cy,
+ DSTINVERT);
+ }
+
+ ReleaseDC(hWnd, hdc);
}