HRGN CreateWindowRgnFromImage( DWORD width, DWORD height, void* pData, DWORD TransColor ) { HRGN hWndRgn = CreateRectRgn( 0, 0, width, height ); DWORD* p = (DWORD*)pData; HRGN hTempRgn = NULL; for( int j = width - 1; j >= 0; --j ) { for( int i = 0; i < height; ++i ) { if( *p++ == TransColor ) { hTempRgn = CreateRectRgn( i, j, i + 1, j + 1 ); CombineRgn( hWndRgn, hWndRgn, hTempRgn, RGN_XOR ); DeleteObject( hTempRgn ); } } } return hWndRgn; }