Solved

Scrolling text in CDialogBar

Posted on 2001-07-03
21
282 Views
Last Modified: 2013-11-20
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
Comment
Question by:janiv
  • 9
  • 6
  • 3
  • +3
21 Comments
 
LVL 2

Accepted Solution

by:
MadYugoslav earned 118 total points
ID: 6248124
Is message text ?
Where do you want to display message (in some control) ?
0
 

Author Comment

by:janiv
ID: 6248479
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
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6248501
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:janiv
ID: 6249596
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
 
LVL 9

Assisted Solution

by:BeyondWu
BeyondWu earned 117 total points
ID: 6250976
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6251588
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
 

Author Comment

by:janiv
ID: 6251616
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
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6251711
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
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6252044
Is it OK ?
0
 

Author Comment

by:janiv
ID: 6252941
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
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6254456
And what about original question ?
0
 

Author Comment

by:janiv
ID: 6262064
It is the same problem ...
Nothing has been changed but my explanation ...
0
 

Author Comment

by:janiv
ID: 6273828
How do U call DrawText ?
How do U set the timer ?
A little bit help is needed ...
10x,
Janiv Ratson
0
 

Author Comment

by:janiv
ID: 6273976
Ho Such function: SetOutputFont(pDC, Height);
0
 
LVL 12

Expert Comment

by:migel
ID: 6286919
0
 

Author Comment

by:janiv
ID: 6288834
Yes I did, it is not what I'm looking for ...
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6744332
hi janiv,
Are you still seeking help with this Question?

-- Dan
0
 

Author Comment

by:janiv
ID: 6746905
Yes, I still looking for help.
10x,
J
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6748106
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 6762188
hi janiv,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9490234
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand data scrubbing tool 13 32
deburging in oracle form 12 99
fizzArray2 challenge 1 81
either24  challenge 19 97
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question