Forcing the caret to show
Hi,
I have console application embedded in a Panel on my Form. The problem is that the Vertical scrollbar of this application always stays at the top, and I would prefer that I was always able to see the caret (prompt) so I can see the latest info.
How do you force a Window to display the caret?
Do solutions give the option of the caret being at the top of the window or the bottom? I would prefer that the carat is at the bottom so I can see all the info immediately prior to the caret, as in this screenshot.
Thanks
Rock
Re: Forcing the caret to show
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For x As Integer = 0 To 100
RichTextBox1.AppendText("Test " & x.ToString & Environment.NewLine)
RichTextBox1.Select(RichTextBox1.TextLength, 0)
RichTextBox1.ScrollToCaret()
Next
RichTextBox1.AppendText("End" & Environment.NewLine)
RichTextBox1.Select()
End Sub
Re: Forcing the caret to show
Thanks dbasnet, but I am not using a RichTextBox, as I explained in my post it is a console application embedded in a Panel.
To get a console application to adjust the caret or scrollbar it will involve a call to one of the Windows APIs.
Rock
Re: Forcing the caret to show
that wasn't the image i saw.
Re: Forcing the caret to show
i think the scroll bar is relative to the size of the console.buffer
Re: Forcing the caret to show
Code:
'when the buffer is filled the scroll bar will be at the bottom
For z As Integer = 0 To Console.BufferHeight
Dim x As Integer = Console.CursorLeft
Dim y As Integer = Console.CursorTop
Console.WriteLine(x.ToString & y.ToString)
Next
Console.ReadLine()
Re: Forcing the caret to show
Thanks for trying to help dbasnet, but maybe my post is not as clear as I thought it was.
The image I posted was indeed a console application, it was in fact Console.exe - the replacement for cmd.exe. I have stripped off the TitleBar, MenuBar and ToolBar, and placed it inside a Panel by starting it as a process and using SetParent.
Console.exe was not created within my VB.NET application, it is an external exe file, and so it will not respond to Console.* commands. I thought that was clear from my description that it was embedded, but I apologise if that was not clear.
In order to manipulate this embedded exe window I believe I will need an API call (user32.dll), some of which I am already using for positioning and resizing, using the MoveWindow or SetWindowPos functions. I have not found yet a suitable API call that mimics ScrollToCaret, and that is what I am looking for.
Thank you for taking an interest,
Rock