Results 1 to 7 of 7

Thread: Forcing the caret to show

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    31

    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

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    31

    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

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Forcing the caret to show

    that wasn't the image i saw.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Forcing the caret to show

    i think the scroll bar is relative to the size of the console.buffer
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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()
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    31

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width