47 , m_direction(
LEFT), m_amount(6), m_delay(85)
48 , m_backColor(RGB(0, 0, 0)), m_withBackDraw(true)
61 if ( ::IsWindow(_super::GetSafeHwnd()) )
64 _super::GetClientRect(&rc);
65 m_clientSize = rc.Size() - m_margin - m_margin;
118 SetTimer(TIMERID_MARQUEE, m_delay, NULL);
139 m_withBackDraw = withBackDraw;
140 m_pDrawing = draw.
Clone();
141 if ( ! m_pDrawing.
IsNull() )
143 m_pDrawing->
GetSize(m_drawingSize);
166 void SetDrawingText(HFONT font, COLORREF textColor, LPCTSTR lpszText, DWORD style = DT_CENTER | DT_VCENTER,
int margin = 0)
168 CTextBkDrawer d(font, textColor, m_backColor, lpszText, style, margin);
184 virtual LRESULT
WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
189 TTRACE0(
"WM_ERASEBKGND\n");
192 TTRACE0(
"WM_PRINTCLIENT\n");
194 CDC* pDC = CDC::FromHandle(
reinterpret_cast<HDC
>(wParam));
199 TTRACE0(
"WM_PAINT\n");
206 TTRACE0(
"WM_ENABLE\n");
209 if ( wParam == TIMERID_MARQUEE )
211 if ( _super::IsWindowVisible() )
214 _super::RedrawWindow();
219 return _super::WindowProc(message, wParam, lParam);
229 _super::ModifyStyle(0, SS_OWNERDRAW);
230 _super::PreSubclassWindow();
231 SetTimer(TIMERID_MARQUEE, m_delay, NULL);
233 _super::GetClientRect(&rc);
234 m_clientSize = rc.Size() - m_margin - m_margin;
245 SetTimer(TIMERID_MARQUEE, m_delay, NULL);
250 void m_Draw(CDC* pDC)
252 if ( ! m_pDrawing.
IsNull() )
255 _super::GetClientRect(&rc);
256 pDC->IntersectClipRect(&rc);
257 CPoint po = m_drawPoint + m_margin;
258 if ( m_withBackDraw )
261 m_pDrawing->
Draw(*pDC, po.x, po.y);
262 pDC->ExcludeClipRect(CRect(po, m_drawingSize));
263 pDC->FillSolidRect(&rc, m_backColor);
268 pDC->FillSolidRect(&rc, m_backColor);
269 m_pDrawing->
Draw(*pDC, po.x, po.y);
280 switch ( m_direction )
283 m_drawPoint = CPoint(m_clientSize.cx + m_margin.cx, 0);
286 m_drawPoint = CPoint(-m_drawingSize.cx - m_margin.cx, 0);
289 m_drawPoint = CPoint(0, m_clientSize.cy + m_margin.cy);
292 m_drawPoint = CPoint(0, -m_drawingSize.cy - + m_margin.cy);
295 m_drawPoint = CPoint(0, 0);
296 KillTimer(TIMERID_MARQUEE);
301 int w = (m_clientSize.cx - m_drawingSize.cx);
302 int h = (m_clientSize.cy - m_drawingSize.cy);
303 switch ( m_direction )
306 m_drawPoint.x -= m_amount;
309 m_drawPoint.x += m_amount;
312 m_drawPoint.y -= m_amount;
315 m_drawPoint.y += m_amount;
320 switch ( m_direction )
323 if ( m_drawPoint.x < -m_drawingSize.cx )
325 m_drawPoint.x = m_clientSize.cx + m_margin.cx;
329 if ( m_drawPoint.x > m_clientSize.cx )
331 m_drawPoint.x = -m_drawingSize.cx - m_margin.cx;
335 if ( m_drawPoint.y < -m_drawingSize.cy )
337 m_drawPoint.y = m_clientSize.cy + m_margin.cy;
341 if ( m_drawPoint.y > m_clientSize.cy )
343 m_drawPoint.y = -m_drawingSize.cy - m_margin.cy;
350 bool isContinue =
true;
351 switch ( m_direction )
354 if ( m_drawPoint.x < 0 ) { m_drawPoint.x = 0; isContinue =
false; }
357 if ( m_drawPoint.x > w ) { m_drawPoint.x = w; isContinue =
false; }
360 if ( m_drawPoint.y < 0 ) { m_drawPoint.y = 0; isContinue =
false; }
363 if ( m_drawPoint.y > h ) { m_drawPoint.y = h; isContinue =
false; }
368 KillTimer(TIMERID_MARQUEE);
384 COLORREF m_backColor;
HWND GetSafeHwnd(void) const
[取得] ウィンドウハンドル取得.
bool IsNull(void) const
[確認] NULLチェック
bool AdjustSize(int margin=1, HWND hWnd=NULL)
[設定] サイズ調整.
void SetBackColor(COLORREF c)
[設定] 背景色設定.
void SetMode(EMode mode)
[設定] モード設定.
void SetDirection(EDirection d)
[設定] 方向設定.
void SetDrawingBitmap(CBitmapHandle bmp)
[設定] 描画情報設定.
void SetDrawingText(HFONT font, COLORREF textColor, LPCTSTR lpszText, DWORD style=DT_CENTER|DT_VCENTER, int margin=0)
[設定] 描画文字列設定.
void SetMargin(size_t cx, size_t cy)
[設定] マージン.
virtual void PreSubclassWindow(void)
[通知] subclassing/unsubclassing functions.
void SetSpeed(DWORD amount, DWORD delay)
[設定] 移動速度設定.
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
[通知] for processing Windows messages.
void SetDrawingObject(const IDrawable &draw, bool withBackDraw=true)
[設定] 描画情報設定.
CMarqueeStatic(void)
コンストラクタ
virtual bool GetSize(SIZE &_size) const =0
[取得] サイズ取得.
virtual IDrawable * Clone(void) const =0
[作成] クローン作成.
virtual void Draw(HDC dc, int x=0, int y=0) const =0
[描画] 描画.