Results 1 to 8 of 8

Thread: [RESOLVED] Asociate a customized scrollbar with a multiline texfield

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    49

    Resolved [RESOLVED] Asociate a customized scrollbar with a multiline texfield

    Hello

    I'm really desperate with this problem.

    I'm doing a completely customized interface with visual basic and windows forms, but now, I am blocked with this problem.

    As I am customizing all the interface, I also want to draw my own scrollbars in a multiline textfield, but I don't know how to do it. I have try many things, but I'm completely lost.

    Does anybody know how can I do this?

    I supose that I could use GDI+ to draw my own buttons over the scrollbar but this is not a acceptable solution for me. I mean, if I could draw overriding the onPaint method of the Scroll, it would be perfect, but I don't want to overpaint.

    As I hadn't been able to do this, I have chose another solution. I thought: "Hey! I could draw only two buttons (two arrows) and tell the textfield something like line_up/line_down, or a method like this, but i haven't found a method that could do something similar.

    This last solution it would be perfect too, but.... I don't know hoy to implement it.

    As you can see (or read), I am really desperate with this problem.

    I would be pleased if someone could give me a hand.

    Thanks in advance

  2. #2

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    49

    Re: Asociate a customized scrollbar with a multiline texfield

    So, no one knows the answer?

    I'll continue doing some research. If I find the answer I'll post it here, so anybody could learn how to do it....

    Don't wait for me awake

    Regards

  3. #3
    Lively Member
    Join Date
    Jul 2007
    Posts
    85

    Re: Asociate a customized scrollbar with a multiline texfield

    You can just use the SendMessage API to send scroll up / scroll down messages to the textbox foom whatever sort of custom scroll interface you would like to make.

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    49

    Re: Asociate a customized scrollbar with a multiline texfield

    I don't know what is that API, but I'll do some research about it. Thanks a lot, Nihilistic Mystic

  5. #5
    Lively Member
    Join Date
    Jul 2007
    Posts
    85

    Re: Asociate a customized scrollbar with a multiline texfield

    Here is an example I put together, try it out.

    vb.net Code:
    1. 'API Definition, Constants and Enum
    2. <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    3.    Shared Function SendMessage( _
    4.          ByVal hWnd As IntPtr, _
    5.          ByVal Msg As UInteger, _
    6.          ByVal wParam As IntPtr, _
    7.          ByVal lParam As IntPtr) As IntPtr
    8.     End Function
    9.     Const WM_VSCROLL As UInteger = &H115
    10.     Const WM_HSCROLL As UInteger = &H114
    11.     Enum ScrollBarCommands
    12.         SB_LINEUP = 0
    13.         SB_LINELEFT = 0
    14.         SB_LINEDOWN = 1
    15.         SB_LINERIGHT = 1
    16.         SB_PAGEUP = 2
    17.         SB_PAGELEFT = 2
    18.         SB_PAGEDOWN = 3
    19.         SB_PAGERIGHT = 3
    20.         SB_THUMBPOSITION = 4
    21.         SB_THUMBTRACK = 5
    22.         SB_TOP = 6
    23.         SB_LEFT = 6
    24.         SB_BOTTOM = 7
    25.         SB_RIGHT = 7
    26.     End Enum
    27.  
    28. 'Usage Examples
    29.    'Scroll TextBox1 Down
    30.   SendMessage(TextBox1.Handle, WM_VSCROLL, ScrollBarCommands.SB_LINEDOWN, IntPtr.Zero)
    31.    'Scroll Textbox1 Up
    32.   SendMessage(TextBox1.Handle, WM_VSCROLL, ScrollBarCommands.SB_LINEUP, IntPtr.Zero)

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    49

    Re: Asociate a customized scrollbar with a multiline texfield

    Thanks again, Nihilistic Mystic. Here, at my home, I don't have Visual Studio, so I'll try tomorrow at work.

  7. #7

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    49

    Re: Asociate a customized scrollbar with a multiline texfield

    Wow!! I have tried at last the code that Nihilistic Mystic gave me, and it has worked perfectly.

    Thanks again for your answer, Nihilistic Mystic

  8. #8
    Lively Member
    Join Date
    Jul 2007
    Posts
    85

    Re: [RESOLVED] Asociate a customized scrollbar with a multiline texfield

    You are very welcome, glad I could help.

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