Results 1 to 4 of 4

Thread: Custom Control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    Custom Control

    I want to create a custom control that has a cursor like a regular text box, I tried using a line and a timer that makes the line 'Blink', but that wasn't too reliable because I had to change the location and background in the timer... I guess I could do it, but I wanted to ask my question here.

    Basically what I am doing is creating a custom control to allow inputs as in fractions, sub/superscripts, etc.... The TextBox Control doesn't support text in that many locations. Just to give you an idea of what I am trying to do...

    VBNetDude - Thinking Programmatically
    By Silver Seal Software

    Don't forget to mark your thread as "Resolved" using the Thread Tools menu on top. And don't forget to rate the answers that help you the most!

  2. #2
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Custom Control

    I tried starting a 'math type editor' a long time ago as well, but gave up pretty quickly. I think it's a lot more complicated than you might think. You would almost certainly have to custom draw everything, basically creating a Textbox from scratch.

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Custom Control

    You can use the CreateCaret and ShowCaret Win32 API functions. This example creates a cursor in a PictureBox (you would normally always do the call in the GotFocus event).
    Code:
      Private Declare Function CreateCaret Lib "user32.dll" ( _
        ByVal hWnd As IntPtr, _
        ByVal hBitmap As IntPtr, _
        ByVal nWidth As Integer, _
        ByVal nHeight As Integer _
      ) As Boolean
    
      Private Declare Function ShowCaret Lib "user32.dll" ( _
        ByVal hWnd As IntPtr _
      ) As Integer
    
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CreateCaret(PictureBox1.Handle, IntPtr.Zero, 0, 12)
        ShowCaret(PictureBox1.Handle)
      End Sub

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2009
    Location
    Clive, IA in America!!!!
    Posts
    204

    Re: Custom Control

    Thanks.

    Now I want to 'write' text to my control. Would you create another control to function as a 'Fraction', one as a 'Square Root'...

    I tried just printing text to the control, but I wasn't able to retrieve the text.

    VBNetDude - Thinking Programmatically
    By Silver Seal Software

    Don't forget to mark your thread as "Resolved" using the Thread Tools menu on top. And don't forget to rate the answers that help you the most!

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