• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

Scrolling text in CDialogBar

Hi,
I have a dockable dialog bar, which contains a CDialog with IDC_STATIC.
I have a stack with many messages.
I want to scroll from left to right, message by message.
I want the first letter of each message to appear first(in the right most column of the Dialog bar), and the last letter to appear at the left most column of the window.
After the last letter appears in the left most column, I want the next message to appear from the right most column.

How do I do it ?
10x,
Janiv Ratson

More help:
Imagine I have a flight simulator, and the pilto has a CControlBar that appears for every message, and
display the current message.
If more than one message is sent, I should display them all. Each one in its turn (no way 2 strings
will be displayed togheter).
When there R no messages, the controlBar should dissappear.



I'd be glad 2 answer your questions about it.


0
janiv
Asked:
janiv
  • 9
  • 6
  • 3
  • +3
2 Solutions
 
MadYugoslavCommented:
Is message text ?
Where do you want to display message (in some control) ?
0
 
janivAuthor Commented:
Yes the message is a text message, inserted into IDC_STATIC !

I want to display message in the CDialog (my CMsgBoard:public CDialog class), which is a window inside my CSimControlBar (:public CControlBar).

0
 
MadYugoslavCommented:
First change IDC_STATIC id in something else for example in IDC_MESSAGE_TEXT. This is for enable accessing control window.
If You want messages to be scrolled automaticly Override Ontimer and install some timer in oninitdialog.
In ontimer function parse messages and use SetDlgItemText() to set message text in your control.

Post any comments if this is not what You want.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
janivAuthor Commented:
SetDlgItemText with what text ?
on the first frame I want only the first letter to appear ,
on the second 2 letters, on the fifth frame I wanna show 5 letters and so on ... (Scrolling)

How do I know how many scrolls to do ?
0
 
MadYugoslavCommented:
Make your CStatic text control to be right aligned.
Supose that your current message is in CString variable
with name Message.

Then your OnTimer function should stay:

void CMyDialog::OnTimer(UINT nIDEvent)
{
   if( nIDEvent == 0xFF )// Your timer event
   {
      CString Str;
      GetDlgItemText(IDC_TEXT, Str);
      int Curr=Str.GetLength();
      if( Curr < Message.GetLength() )
         SetDlgItemText(IDC_TEXT, Message.Left(Curr+1));
      else
         SetDlgItemText(IDC_TEXT, "");
   }
   else
      CDialog::OnTimer(nIDEvent);
}
0
 
janivAuthor Commented:
BeyondWu,
The example is fine...
But I need every string to appear from the begining, and not concatinating it.
Every string need to be fully scrolled (from left to right) before the next string appears.

MadYuqoslva, this is not what I'm looking for ...

More help:
Imagine I have a flight simulator, and the pilto has a CControlBar that appears for every message, and display the current message.
If more than one message is sent, I should display them all. Each one in its turn (no way 2 strings will be displayed togheter).
When there R no messages, the controlBar should dissappear.

I hope it's clearer now.
0
 
MadYugoslavCommented:
This is what You want (scroll for 10 logical units):
You need to somewhere save current x position (initial value is 0) CurrX.

// Function for draw text
int DrawText(CDC* pDC, int x, int y, const char* Str, int Len, int Height, BOOL DrawFlag)
{
   int DC=pDC->SaveDC();
   SetOutputFont(pDC, Height);
   pDC->SetTextColor(0);
   CSize Size=pDC->GetTextExtent(Str, Len);
   if( DrawFlag )
      pDC->TextOut(x, y, Str, Len);
   pDC->RestoreDC(DC);
   return(Size.cx);
}
void CMyDialog::OnTimer(UINT nIDEvent)
{
   if( nIDEvent = 0xFF )
   {
      CWnd* Win=GetDlgItem(IDC_TEXT);
      CDC* pDC=Win->GetDC();
      RECT Rect;
      Win->GetClientRect(&Rect);
      {
         pDC->BeginPath();
         pDC->Rectangle(&Rect);
         pDC->EndPath();
         pDC->SelectClipPath(RGN_COPY);
      }
      pDC->FillSolidRect(&Rect, RGB(255, 255, 255));
      int x=CurrX;
      int Size=DrawText(pDC, 0, 0, LPCTSTR(Message), Message.GetLength(), 20, FALSE);
      if( x < (Size+Rect.right) )
      {
         DrawText(pDC, Rect.right-x, 0, LPCTSTR(Message), Message.GetLength(), 20, TRUE);
         CurrX+=10;
      }
      else
         CurrX=0;
      Win->ReleaseDC(pDC);
   }
   else
      CDialog::OnTimer(nIDEvent);
}
0
 
MadYugoslavCommented:
Is it OK ?
0
 
janivAuthor Commented:
MadYugoslav, I'm sorry I wanna check it, but I have no clue how to use the timer mechanism.
Can U help me ?

Demo project will be gladly accepted.

Also, FYI , now I'm using ScrollWindow method for scrolling,
my problems are:

1. How to insert the first character from the right most column ?

2. How to know till when to scroll ?

3. How to return the window to the starting position ?
0
 
MadYugoslavCommented:
And what about original question ?
0
 
janivAuthor Commented:
It is the same problem ...
Nothing has been changed but my explanation ...
0
 
janivAuthor Commented:
How do U call DrawText ?
How do U set the timer ?
A little bit help is needed ...
10x,
Janiv Ratson
0
 
janivAuthor Commented:
Ho Such function: SetOutputFont(pDC, Height);
0
 
migelCommented:
0
 
janivAuthor Commented:
Yes I did, it is not what I'm looking for ...
0
 
DanRollinsCommented:
hi janiv,
Are you still seeking help with this Question?

-- Dan
0
 
janivAuthor Commented:
Yes, I still looking for help.
10x,
J
0
 
DanRollinsCommented:
Having read the full question and follow-up comments, I think you may have mis-stated the question.  When youi said:

>> I want to scroll from left to right, message by message

I think you really mean that you want the messages to scroll from right to left.

I can easily write that routine in one of two ways.  I think that the way that you described it would be awkward.  That is, if the first message started scrolling in from the right, one letter at-a-time, it would be tedious.  The user would need to wait quite a while in order to see the entire text.  You further explain that you want that first message to scroll all of the way off, until it has disappeared completely before starting the next (tedious) letter-by-letter scrolling -- again the user would need to twiddle his thumbs waiting for the meaning of the next message to be clear.

A more expected way to do it would be to place the first string entirely into view immediately.  Then delay for one or two seconds. The start scrolling it.  After the entire message is visible, it continues to scroll.  But rather than waiting until it is entirely off-screen, you could start scrolling in the next message onece the first message was, for instance, half-way across.

Your 'flight simulator' example reinforces my point.  A pilot would *not* want to wait a long time in order to understand the message.  THe piolot needs to see the full meaning of the message as soon as possible.  Here is an example message:

"Your heading is 143 by 234 at 600 Nautical miles per hour.  At this heading and rate you will collide into a mountain in 10 seconds."

By the time the full message is visible, the pilot is dead.

Is this specification clear?  Do you want to see program code that implements this the way that I have described?

-- Dan
0
 
DanRollinsCommented:
hi janiv,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
Roshan DavisCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: MadYugoslav, BeyondWu (points to be split)

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 9
  • 6
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now