 |
|
 |
i apply this cotrol into my mutiThread App.however ,i come across the following problems even if i use Criticalsection to lock the scroller control in the thread Proc.
-----------------------------------------------------------------------
AfxAssertFailedLine(const char * 0x0044631c _szAfxTempl, int 254) line 39 + 20 bytes
CArray<int,int>::GetAt(int 1) line 254 + 61 bytes
CScrollLink::DrawScrollingText(CDC * 0x00126d68 {hDC=0x9901104a attrib=0x9901104a}) line 268 + 22 bytes
-----------------------------------------------------------------
can u help with work it out?
|
|
|
|
 |
|
 |
Hi,
I am by far no expert in MFC or ATL, even C++. But I have, with some very hard work, managed to adapt one tutorial of creating a toolbar, in ATL, to the application I needed. Now, reading this amazing tutorial by Weiye Chen, I can see that it is in MFC. So I am confused if it is possible to use it directly with an ATL project, or I would need to adapt the code...
For example, the message maps in ATL are diferente than MFC, as well as the list of parameter passade by OnPaint, etc...
Can anyone point me in the right direction? What do I need to adapt?
Thanks a lot for everyone that writes to CP. You have no idea how you guys help us beginners!!!
|
|
|
|
 |
|
 |
hello, this is really a nice work, thank you very much!
but here i have a little suggestion(or may be improvement)for this work.
that is, sometimes when change the size of the control dynamically, the interval between the new added text and the prior, also change to be larger or smaller than the macro SCROLLALLOWANCE we set.so i modify some parts of your code in the method AddOnNewScrollingText() as belows:
void CScrollLink::AddOnNewScrollingText(void)
{
...
// Set starting position in pixels for scrolling
// pTextFrame->m_iXOffSets.Add(m_oTextArea.right); <-this is your orginal code
int lEnd = pTextFrame->m_iXOffSets.GetAt(pTextFrame->m_iXOffSets.GetSize() - 1) + pTextFrame->m_szTextSize.cx + SCROLLALLOWANCE; <- added by me
pTextFrame->m_iXOffSets.Add(lEnd); <- added by me
// Add new text frame index into array
m_iTextFramesScrolling.Add(iIndex);
...
}
now it can be works rightly when we change size of the control,the interval remain equal to the SCROLLALLOWANCE.
is this right?any ideas?
china, ice_lei.
|
|
|
|
 |
|
 |
Hello,
Thank you for your good.
I have a question.
When the text is scrolling, the text data is redrawing.
By the way, the scrolling text is displayed like flicking text.
How can I display more smoothly ?
Thanks.
|
|
|
|
 |
|
 |
I change the SETTIMER(,x,)but when x=20 ,the speed is slow,x=15 or 10 ,the rate dosn't change.why?
how to change the scrollrate
您是中国人吗?我发现它在滚动的时候有些闪,如何解决这个问题呢?就是降低rate?另外默认的滚动速度太快了,怎么慢一些呢?
|
|
|
|
 |
|
 |
The x value is actually in milliseconds. It determines the intervale between each timer callback. So you can't really see a difference with values of 10 - 20.
Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
 |
|
 |
i want to creat the control in my program , not only to draw it on the dialog window. Can i use the 'creat' method? i have tried but failed .what can i do ?thank u
|
|
|
|
 |
|
 |
First thing you need to amend is to put this extra line in CScrollLink::CreateTextFonts(...) function as shown below:void CScrollLink::CreateTextFonts(void)
{
CFont* pFont = GetFont();
if(pFont == NULL)
return;
LOGFONT lfLogFont;
.
.
}When you call Create(...), be sure to use the SS_NOTIFY flag. However, i still couldn't figure out how to set the font as according to the parent window with this method of creation.
Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
 |
|
 |
Hi! I was wondering, has anyone patched this to have support for transparent texts as well as halts and vertical scroll drops.
Ex. Text scrolls, get to approx middle of the scroll control, and delays for a certain amount of time ?
Thanks.
|
|
|
|
 |
|
 |
right to left scroll ?
regards
wael
|
|
|
|
 |
|
 |
Yes.
Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
 |
|
 |
how do i implement right to left to this ticker
thanx
|
|
|
|
 |
|
 |
I don't quite get what u mean. It is already a right to left scroll.
Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
 |
|
 |
sorry ,
i mean left to right
thanks for reply
|
|
|
|
 |
|
 |
Kawasi wrote:
How to make lower scroll speed?
You want the text text to scroll faster of slower? If you want it faster, you can set the SCROLLSPEED to 2 or 3. If you want it slower, you can increase the SCROLLRATE.
Kawasi wrote:
How to eliminate surrounding line out of static text?
I don't get what u mean.
Weiye Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
 |
|
 |
Kawasi wrote:
I want image background in static text area.
You can paint your image in the OnPaint of CScrollLink. However, you will see the the text background isn't set as tranparent. You can set it as transparent, but you will see the text smurge. As a result, you need to invalidate the area of the text everytime it moves to a new location. In the current design, doing that will causing flickering.
I believe using double buffering might be able to solve this problem or you can check out this article:
http://www.codeproject.com/staticctrl/ticker.asp[^]
Weiye Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
 |
|
 |
Hi,
I really like this class, nice and smooth. Good work!
I just have one question. I've been trying to make the background truly transparent to scroll over a skinned dialog. I've tried the OnCtlColor() NULL_BRUSH trick, SetWindowLayerAttributes WS_EX_LAYERED, InvalidateRect(&oInvalidateArea,FALSE), returning false on WM_ERASEBKGND, and anything else I could think of.
By simply calling SetBkMode(TRANSPARENT) instead of (OPAQUE), the background is transparent, but the text smears, and an UpdateWindow() after the Invalidate() doesn't appear to help.
Any ideas?
Thanks,
Don
|
|
|
|
 |
|
 |
One thing I forgot to mention...
I think it would be possible to draw the text on a DC in memory and create a transparent mask with a CreateBitmap and tell TransparentBlt to use m_clrBackground, and then copy it back to the screen dc. In this case, images could also be added into the banner and repeatadly blitted back onto the screen producing the scrolling effect, but that would basically be rewriting your scrolling methods. This is the same technique used in a scrolling credits class on CP but hyperlinks weren't included and it would've taken some work to make it scroll horizontally.
How difficult do you think it would be to incorporate this?
Thanks again,
Don
|
|
|
|
 |
|
 |
Yes, the text will smear when u set the background mode to transparent. You will need to tell the parent window to invalidate the area under the text by adding these lines in the DrawScrollingText(...) function, before the DrawText(...) code.
CRect oParentDrawingArea = oDrawingArea;
ClientToScreen(&oParentDrawingArea);
GetParent()->ScreenToClient(&oParentDrawingArea);
GetParent()->InvalidateRect(&oParentDrawingArea, FALSE);
However, this is not very effective and brings new problems when the text is being hovered.
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
 |
|
 |
I need to modify the font size being scrolled. I have added a new LOGFONT variable with cusotm parameters, but its not working. Do I need to change some other code for font size variations.
LOGFONT lmyLogFont;
memset(&lmyLogFont, 0, sizeof(LOGFONT));
lmyLogFont.lfHeight = 20 ;
strcpy(lmyLogFont.lfFaceName, "Arial");
Regards
Rizi
|
|
|
|
 |
|
 |
You should be able to do that by modifying/adding code in CreateTextFonts(). e.g.
void CScrollLink::CreateTextFonts(void)
{
CFont* pFont = GetFont();
LOGFONT lfLogFont;
pFont->GetLogFont(&lfLogFont);
lfLogFont.lfWeight = FW_BOLD;
lfLogFont.lfHeight = 20;
m_oNormalFont.CreateFontIndirect(&lfLogFont);
lfLogFont.lfUnderline = TRUE;
m_oUnderlinedFont.CreateFontIndirect(&lfLogFont);
}
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
 |
|
 |
Ok, so I have added the ScrollLink.h and ScrollLink.cpp to my project and declared CScrollLink myScroll. Then I made a static text with the ID "ID_NEW" and add DDX_Control(pDX, IDC_NEW, myScroll); in the DoDataExchange member. Now when I add myScroll.AddScrollText(sName, sURL); and myScroll.StartScrolling(); everything works ok (the text starts scrolling). BUT I need to add a static text manualy (not with ClassWizard) with the Create method (something like myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(40,40,200,100),this,IDC_NEW);) The problem appears when I try to link the IDC_NEW ID to the variable CScrollLink myStatic in DoDataExchange member( DDX_Control(pDX, IDC_NEW, myScroll);) It gives me a debug assertion failed error when I compile the program. So how to link the IDC_NEW to the myStatic variable without ClassWizard ?? Thanks.
|
|
|
|
 |
|
 |
Hello, add in the bold statements in CreateTextFonts() :
void CScrollLink::CreateTextFonts(void)
{
CFont* pFont = GetFont();
if (pFont == NULL)
return;
.
.
}
Weiye, Chen
When pursuing your dreams, don't forget to enjoy your life...
|
|
|
|
 |
|
 |
The debug assertion failed error is not caused by pFont, but because I did not put in in the .rc file something like
LTEXT "some text",IDC_NEW,19,43,18,8.
This static text that I want is placed on a coolbar that I create (something like the band where explorer has the back and forward buttons) wich is not a dialog box or a toolbar. That means I can't edit it with the resource editor.
So my problem is how to link the IDC_NEW to the myScroll object avoiding somehow the resource editor.
|
|
|
|
 |
|
 |
Commenting every single line of code is a bit (just a bit) exaggerated.
Just like the most famous one:
int i = 0; //Declare variable i of type integer with an initial value of 0
|
|
|
|
 |