Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js
In some cases it's nice to have a window that not always looks the same (I mean rectangular). So I created this CWnd based window class which implements a transparent window. The transparency information is supplied by a mask bitmap.
So your InitInstance() function should look like this:
CRect rect(0, 0, 320, 150);
CTransparentWnd* pTWnd = new CTransparentWnd;
m_pMainWnd = pTWnd;
pFrame->CreateTransparent("Transparent Test", rect, IDB_MASK, IDB_BACK);
The mechanism this window is working with is to set a proper window-region. This window region is setup by the function SetupRegion(). The process is to load the specified monochrome mask bitmap and to check for each pixel if it is set or not. For each set pixel add this pixel's position to the window region. This is very slow, but only done once at startup. Therefore this window is not resizeable.
The code for the SetupRegion() function:
void CTransparentWnd::SetupRegion(CDC *pDC, unsigned short
CBitmap* pOldMemBmp = NULL;
int x, y;
CRgn m_Rgn, rgnTemp;
pOldMemBmp = memDC.SelectObject(&cBitmap);
m_Rgn.CreateRectRgn(0, 0, cRect.Width(), cRect.Height());
for(x=0; x<=cRect.Width(); x++)
for(y=0; y<=cRect.Height(); y++)
col = memDC.GetPixel(x, y);
if(col == 0)
rgnTemp.CreateRectRgn(x, y, x+1, y+1);
m_Rgn.CombineRgn(&m_Rgn, &rgnTemp, RGN_XOR);
if (pOldMemBmp) memDC.SelectObject(pOldMemBmp);
The next proble is to make this window moveable. There are two possibilities. You can override the ONNcHittest() function and redirect all HTCLIENT results to HTCAPTION result, or you only override the OnLButtonDown() function and send the correct hittest result to the framework.
void CTransparentWnd::OnLButtonDown(UINT nFlags, CPoint
PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x,point.y));
Now you can move the window by clicking anywere inside the window region.