Introduction
The CBitmapHandling
class was designed to calculate the contour points in a bitmap. It looks at the bitmap and finds pixel points different from white, it then places these start and stop pixel points in a Vertex of CPoint
class. When it has found the outline of the bitmap, it then generates a Windows region. If you use this region in your OnInitDialog
and then set the window region using SetWindowRgn(m_WinRgn, TRUE )
, your window will then be shaped like the outline.
Using the code
The code consists of a header file and a CPP file.
#include "BitMapHandling.h"
using namespace HandlingBitmaps;
BOOL CMyShapedWindowDlg::OnInitDialog()
{
CDialog::OnInitDialog();
VERIFY( SetWindowPos( NULL, 0, 0, m_nW,
m_nH, SWP_NOMOVE | SWP_NOOWNERZORDER ) );
CBitmapHandling bh;
bh.BitMapContourToWinRgn(&m_WinRgn, IDB_BITMAP);
VERIFY( SetWindowRgn(m_WinRgn , TRUE ) );
return TRUE;
}