24 m_hbrBackBrush = NULL;
27 m_bUpdateContent =
true;
35 ATLASSERT( m_hWnd == NULL);
39 if (m_hbrBackBrush != NULL)
41 ::DeleteObject (m_hbrBackBrush);
42 m_hbrBackBrush = NULL;
60 CWindowImpl<CColorBlob, CStatic>::SubclassWindow(hWnd);
75 if (m_hbrBackBrush != NULL)
77 ::DeleteObject (m_hbrBackBrush);
78 m_hbrBackBrush = NULL;
95 return(m_clrBackColor);
109 m_bDirtyColor =
true;
110 m_clrBackColor = value;
137 if (m_EdgeStyle != style)
140 m_bUpdateContent =
true;
152 m_bUpdateContent =
true;
163 void CColorBlob::UpdateBackBrush()
165 m_bDirtyColor =
false;
167 if (m_hbrBackBrush != NULL)
169 ::DeleteObject (m_hbrBackBrush);
170 m_hbrBackBrush = NULL;
173 m_hbrBackBrush = ::CreateSolidBrush (m_clrBackColor);
175 m_bUpdateContent =
true;
178 void CColorBlob::PrepareGDIStuff()
185 if (::IsWindow(m_hWnd))
187 if ((r.Width() > 0)&&(r.Height() > 0))
189 m_hCanvas.Create(r.Width(), r.Height(), 24, 0);
191 if (! m_hCanvas.IsNull())
194 HDC dc = ::GetDC(m_hWnd);
195 m_hMemDC = ::CreateCompatibleDC(dc);
197 if (m_hMemDC != NULL)
198 m_hOldMap = (HBITMAP)::SelectObject(m_hMemDC, (HBITMAP)m_hCanvas);
200 m_hCanvas.Destroy();;
202 ::ReleaseDC(m_hWnd, dc);
203 m_bUpdateContent =
true;
209 void CColorBlob::DestroyGDIStuff()
212 if (m_hMemDC != NULL)
214 if (m_hCanvas != NULL)
216 ::SelectObject(m_hMemDC, m_hOldMap);
221 ::DeleteDC(m_hMemDC);
227 void CColorBlob::DrawEdge(CRect r)
238 ::DrawEdge(m_hMemDC, r, EDGE_BUMP,BF_RECT );
241 ::DrawEdge(m_hMemDC, r, EDGE_ETCHED,BF_RECT );
244 ::DrawEdge(m_hMemDC, r, EDGE_RAISED,BF_RECT );
247 ::DrawEdge(m_hMemDC, r, EDGE_SUNKEN,BF_RECT);
250 ::DrawEdge(m_hMemDC, r, BDR_RAISEDOUTER,BF_RECT );
253 ::DrawEdge(m_hMemDC, r, BDR_SUNKENOUTER,BF_RECT);
264 BOOL CColorBlob::OnEraseBkgnd(CDCHandle dc)
269 LRESULT CColorBlob::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
274 bool do_end_paint =
false;
281 RECT update_rect{ 0 };
282 if (GetUpdateRect(&update_rect) != 0)
284 dc = BeginPaint(&ps);
292 if (m_bDirtyColor ==
true)
295 GetClientRect(&rect);
298 if ((m_hMemDC == NULL)||(m_hCanvas.IsNull()))
301 if ((m_hMemDC != NULL)&&( ! m_hCanvas.IsNull()))
304 if ((rect.Width() != m_hCanvas.GetWidth())||(rect.Height() != m_hCanvas.GetHeight()))
307 if (m_bUpdateContent)
309 m_bUpdateContent =
false;
311 ::FillRect(m_hMemDC, rect, m_hbrBackBrush);
312 ::SetBkColor(m_hMemDC, m_clrBackColor);
317 ::BitBlt (dc, 0, 0,rect.Width (), rect.Height (), m_hMemDC, 0, 0, SRCCOPY);
321 if (do_end_paint ==
true)
void SetEdgeStyle(CEdgeStyle style)
Specify a new edge style. A call to UpdateContent may be required to make the new color visible...
CEdgeStyle
Style of edge defining control boundaries.
BOOL OutlineRect(HDC HDestDC, const RECT &RDest)
Draw a rectangular outline with the current pen.
void SubclassStatic(HWND hWnd)
Subclass a control window and create the colored background brush.
void UpdateContent()
Wraps calls to Invalidate and UpdateWindow, updating the back buffer and blitting the new content to ...
void UnSubclassStatic()
Un-subclass the window and release GDI resources.
COLORREF GetBackColor() const
Default: COLOR_RED.
void SetBackColor(COLORREF value)
Specify a new background color. A call to UpdateContent may be required to make the new color visible...
CEdgeStyle GetEdgeStyle() const
Default: CEdgeStyle::esLine.