customlist.cpp File Reference

(r1785/r1082)

#include "camtypes.h"
#include "customlist.h"

Go to the source code of this file.

Functions

HBITMAP CreateScreenCompatibleBitmap (INT32 width, INT32 height)
void EnableDescendants (HWND hWnd, BOOL enable)
BOOL SetBitmapBkgToSystem (HBITMAP hBitmap)


Function Documentation

HBITMAP CreateScreenCompatibleBitmap INT32  width,
INT32  height
 

Definition at line 367 of file customlist.cpp.

00368 {
00369     HDC hProbeDC = ::CreateCompatibleDC(NULL); // device context used to probe the current screen mode
00370     ERROR3IF(hProbeDC == NULL, "Couldn't create probe DC");
00371     const BITMAP bitmapData = 
00372     { 
00373         0,
00374         width,
00375         height,
00376         width * GetDeviceCaps(hProbeDC, BITSPIXEL) * GetDeviceCaps(hProbeDC, PLANES) / 8 ,
00377         GetDeviceCaps(hProbeDC, PLANES),
00378         GetDeviceCaps(hProbeDC, BITSPIXEL),
00379         0L
00380     };
00381     DeleteDC(hProbeDC);
00382     return CreateBitmapIndirect(&bitmapData);
00383 }

void EnableDescendants HWND  hWnd,
BOOL  enable
 

Definition at line 474 of file customlist.cpp.

00475 {
00476     // walk through HWNDs to avoid creating temporary CWnd objects
00477     // unless we need to call this function recursively
00478     for (HWND hWndChild = ::GetTopWindow(hWnd); hWndChild != NULL;
00479         hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT))
00480     {
00481         CWnd* pWnd = CWnd::FromHandlePermanent(hWndChild);
00482         if (pWnd != NULL)
00483         {
00484             pWnd->EnableWindow(enable);
00485             pWnd->RedrawWindow();
00486         }
00487         if (::GetTopWindow(hWndChild) != NULL)
00488         {
00489             // send to child windows after parent
00490             EnableDescendants(hWndChild,enable);
00491         }
00492     }
00493 }

BOOL SetBitmapBkgToSystem HBITMAP  hBitmap  ) 
 

Definition at line 517 of file customlist.cpp.

00518 {
00519     BITMAP bitmap;
00520     HDC hBitmapDC = CreateCompatibleDC(NULL);
00521     if (!GetObject(hBitmap, sizeof(bitmap), &bitmap) || !hBitmapDC)
00522     {
00523         ERROR2RAW("Non-fatal GDI error");
00524         return(FALSE);
00525     }
00526     SelectObject(hBitmapDC, hBitmap);
00527     // We make the assumption that the pixel in the lower right corner has the background colour 
00528     DWORD currentBkColour = (DWORD) GetPixel(hBitmapDC, bitmap.bmWidth - 1, bitmap.bmHeight -1); 
00529     DWORD sysBkColour = GetSysColor(COLOR_3DFACE);
00530     for (INT32 i = 0; i < bitmap.bmWidth; i++)
00531     {
00532         for (INT32 j = 0; j < bitmap.bmHeight; j++)
00533         {
00534             if ((DWORD) GetPixel(hBitmapDC, i, j) == currentBkColour)
00535                 SetPixelV(hBitmapDC, i, j, (COLORREF) sysBkColour);
00536         }
00537     }
00538     DeleteDC(hBitmapDC);
00539     return TRUE;
00540 }


Generated on Sat Nov 10 03:49:29 2007 for Camelot by  doxygen 1.4.4