Народ, помогите разобраться с WTL. У меня есть класс который мне надо переписать с использованием WTL. Не знаю как это сделать | Код | #pragma once #include "widget.h" #include ".\Thread.h"
class CrawlLine : public Widget, Thread { public: CrawlLine(const ULONG& id); virtual ~CrawlLine(void); virtual void Paint(HDC& dc); virtual UINT Run();
virtual void Update(void); private: CString _text; ULONG _pointer; };
|
а это cpp файл: | Код | #include "StdAfx.h" #include ".\crawlline.h" #include "stddef.h" #include "strsafe.h"
CrawlLine::CrawlLine(const ULONG& id) :Widget(id), _pointer(0) { _text = "BATON ROUGE, La., Sept. 20 - Hurricane conditions were predicted this morning for Florida's southern coast and the Keys as Tropical Storm Rita moved in a northwest direction, posing a new threat to the battered Gulf Coast."; Start(); }
CrawlLine::~CrawlLine(void) { Terminate(); Wait(); }
UINT CrawlLine::Run() { for (;;) { SleepClever(20); if (m_bTerminate) return 0; Update(); } return 0; };
void CrawlLine::Update(void) { ++_pointer; Invalidate(FALSE); }
void CrawlLine::Paint(HDC& dc) { SIZE sz;
Widget::Paint(dc); int old_mode = ::SetBkMode(dc, TRANSPARENT);
::GetTextExtentPoint32(dc, _text, _text.GetLength(), &sz); _pointer %= (_rc.right - _rc.left) + sz.cx;
RECT tmpRect;
tmpRect.left = _rc.right - _pointer; tmpRect.right = _rc.right - 3; tmpRect.top = _rc.top; tmpRect.bottom = _rc.bottom; //::SetBkColor(dc,RGB(256, 0, 0));
Rectangle(dc, _rc.left - 3, _rc.top, _rc.right, _rc.bottom); COLORREF old_textColor = ::SetTextColor(dc, RGB(180, 216, 160)); //COLORREF old_textColor = ::SetTextColor(dc, RGB(0, 0, 0));
::DrawText(dc, _text, strlen(_text), &tmpRect, DT_LEFT|DT_VCENTER); ::SetTextColor(dc, old_textColor); ::SetBkMode(dc, old_mode); }
|
|