Click here to Skip to main content
15,914,016 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questiontoolbar cutoff at the right end in MDI Pin
engilela8-Dec-08 2:51
engilela8-Dec-08 2:51 
QuestionHelp with Visual Studio C++ 2008 Pin
Member 18628468-Dec-08 2:37
Member 18628468-Dec-08 2:37 
AnswerRe: Help with Visual Studio C++ 2008 Pin
Hamid_RT8-Dec-08 2:39
Hamid_RT8-Dec-08 2:39 
AnswerRe: Help with Visual Studio C++ 2008 Pin
David Crow8-Dec-08 2:54
David Crow8-Dec-08 2:54 
QuestionScroll Bar Position control Pin
Member 46517418-Dec-08 2:11
Member 46517418-Dec-08 2:11 
AnswerRe: Scroll Bar Position control Pin
Graham Shanks8-Dec-08 11:54
Graham Shanks8-Dec-08 11:54 
GeneralRe: Scroll Bar Position control Pin
ramnathrn8-Dec-08 19:47
ramnathrn8-Dec-08 19:47 
GeneralRe: Scroll Bar Position control Pin
Graham Shanks9-Dec-08 3:53
Graham Shanks9-Dec-08 3:53 
OK, things are a lot clearer now, thanks. I was assuming that you were using the CRichEditCtrl from MFC, but you are actually using RichTextBox from the .Net framework library

What I think you want to do is:

a) Before appending the message to the RichTextBox get the current length of the text from the TextLength property. This is the char index of the last character of the last message

b) Calculate the line number of this position using GetLineFromCharIndex

c) Append the text

d) Calculate the line number that you want at the bottom of the display from the number calculated in b) plus the number of lines in the display

e) Calculate the char index of the beginning of the line calculated in d) using the GetFirstCharIndexFromLine

f) Set the caret to begining of the line calculated above using the Select method

g) Scroll the caret to the bottom of the display using the ScrollToCaret() method

The following code should do it (note I have not tested this yet)

int line = myRichTextBox.GetLineFromCharIndex(myRichTextBox.TextLength);
myRichTextBox.SetText(concat_string);
int pos = myRichTextBox.GetFirstCharIndexFromLine(line + NumberOfLinesInRichTextBox(myRichTextBox));
myRichTextBox.Select(pos, pos);
myRichTextBox.ScrollToCaret();


As in a previous answer[^] the function NumberOfLinesInRichTextBox could either return a constant value determined by experiment or calculate the number of visible lines in the RichTextBox using Text Metrics.

Apologies for not having time at the moment to test this out, but I hope I've given you enough of a steer to allow you to get this working

Graham

Librarians rule, Ook!

Questionhow to show icons or bitmaps on popup menu and how to display bitmaps or icons on status bar for DIALOG BASED APPLICATION? Pin
puppya8-Dec-08 1:46
puppya8-Dec-08 1:46 
AnswerRe: how to show icons or bitmaps on popup menu and how to display bitmaps or icons on status bar for DIALOG BASED APPLICATION? Pin
Hamid_RT8-Dec-08 2:32
Hamid_RT8-Dec-08 2:32 
GeneralRe: how to show icons or bitmaps on popup menu and how to display bitmaps or icons on status bar for DIALOG BASED APPLICATION? Pin
puppya8-Dec-08 17:05
puppya8-Dec-08 17:05 
GeneralRe: how to show icons or bitmaps on popup menu and how to display bitmaps or icons on status bar for DIALOG BASED APPLICATION? Pin
puppya8-Dec-08 17:22
puppya8-Dec-08 17:22 
GeneralRe: how to show icons or bitmaps on popup menu and how to display bitmaps or icons on status bar for DIALOG BASED APPLICATION? Pin
Chandrasekharan P8-Dec-08 18:47
Chandrasekharan P8-Dec-08 18:47 
GeneralRe: how to show icons or bitmaps on popup menu and how to display bitmaps or icons on status bar for DIALOG BASED APPLICATION? Pin
Hamid_RT9-Dec-08 7:16
Hamid_RT9-Dec-08 7:16 
GeneralRe: how to show icons or bitmaps on popup menu and how to display bitmaps or icons on status bar for DIALOG BASED APPLICATION? Pin
puppya9-Dec-08 17:27
puppya9-Dec-08 17:27 
GeneralRe: how to show icons or bitmaps on popup menu and how to display bitmaps or icons on status bar for DIALOG BASED APPLICATION? Pin
Hamid_RT9-Dec-08 20:12
Hamid_RT9-Dec-08 20:12 
GeneralRe: how to show icons or bitmaps on popup menu and how to display bitmaps or icons on status bar for DIALOG BASED APPLICATION? Pin
puppya9-Dec-08 20:16
puppya9-Dec-08 20:16 
Questioninterrupting std::getline Pin
manustone8-Dec-08 1:01
manustone8-Dec-08 1:01 
AnswerRe: interrupting std::getline Pin
Randor 8-Dec-08 2:09
professional Randor 8-Dec-08 2:09 
GeneralRe: interrupting std::getline Pin
manustone8-Dec-08 3:02
manustone8-Dec-08 3:02 
Questionback ground picture Pin
hrishiS8-Dec-08 0:18
hrishiS8-Dec-08 0:18 
AnswerRe: back ground picture Pin
Rajesh R Subramanian8-Dec-08 0:20
professionalRajesh R Subramanian8-Dec-08 0:20 
AnswerRe: back ground picture Pin
Hamid_RT8-Dec-08 2:25
Hamid_RT8-Dec-08 2:25 
QuestionSet the Font of Tree Control Pin
brucewayn7-Dec-08 23:38
brucewayn7-Dec-08 23:38 
AnswerRe: Set the Font of Tree Control Pin
Iain Clarke, Warrior Programmer8-Dec-08 0:12
Iain Clarke, Warrior Programmer8-Dec-08 0:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.