Results 1 to 4 of 4

Thread: [RESOLVED] Textbox Behavioral bug with MDI(child) Forms.

  1. #1

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Resolved [RESOLVED] Textbox Behavioral bug with MDI(child) Forms.

    So I've just discovered the little "bug" - I hope, when adding forms to another form. If the form in question behind added to another form contains a textbox. Then that textbox will behave in a no way normal fashion. It seems it has no response with the mouse. Yet keyboard interactions are normal. For example, using the mouse your unable to move the caret around or select any text at all. Simply you can double click - which highlights all the text, or clicking once which gives the textbox control focus, just the caret remains unchanged(to the far left most position).


    This topic was difficult to locate through google, so I've tried some research before posting this. All examples I found were C++ and no one seemed to understand the OP's question.


    Mine is how can I work around this? I've tried all suggestions I've found so far but none have worked. At this point I'm thinking my ONLY suggestion is to create my own textbox control, as I've already created a collection of controls, wouldn't hurt to add textbox to the list. But this would be time consuming and a lot more work. I'm not even sure if this would fix the problem if the problem is internal..


    ...any suggestions???

    Code that produces the "bug"
    vbnet Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_Load( ByVal sender As System.Object,  ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Dim nForm As New Windows.Forms.Form()
    5.         Dim nTextBox As New Windows.Forms.TextBox()
    6.  
    7.         nTextBox.Location = New Point(0, 0)
    8.         nTextBox.Size = New Size(158, 20)
    9.         nTextBox.Text = "Sample text"
    10.  
    11.         nForm.TopLevel = False
    12.         nForm.Controls.Add(nTextBox)
    13.         Me.Controls.Add(nForm)
    14.         nForm.BringToFront()
    15.         nForm.Show()
    16.     End Sub
    17.  
    18. End Class
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  2. #2

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: Textbox Behavioral bug with MDI(child) Forms.

    Ugh I know my friend hates this, but I solved my own problem before someone could help or come up with their own solution..

    So the solution? Well I always say "When all else fails, API it!" This is another case I had to resort to that.. I found when setting the forms TopLevel = False was there when the bug arose. So I had to avoid having to change that value while still being able to add the form to a parenting form. The answer: SetParent api.

    Here's a quick snippit code that demonstrates:
    vbnet Code:
    1. Public Class Form1
    2.  
    3.     Friend Declare Function SetParent Lib "user32" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
    4.  
    5.     Private Sub Form1_Load( ByVal sender As System.Object,  ByVal e As System.EventArgs) Handles MyBase.Load
    6.         Dim nForm As New Windows.Forms.Form()
    7.         Dim nTextBox As New Windows.Forms.TextBox()
    8.  
    9.         nTextBox.Location = New Point(0, 0)
    10.         nTextBox.Size = New Size(158, 20)
    11.         nTextBox.Text = "Sample text"
    12.  
    13.         SetParent(nForm.Handle, Me.Handle)
    14.         nForm.Show()
    15.     End Sub
    16.  
    17. End Class

    The result is a form within the parent from, whom contains normal funtioning textbox controls
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,466

    Re: [RESOLVED] Textbox Behavioral bug with MDI(child) Forms.

    you can do the same thing with the form's mdiParent property

  4. #4

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: [RESOLVED] Textbox Behavioral bug with MDI(child) Forms.

    Quote Originally Posted by .paul. View Post
    you can do the same thing with the form's mdiParent property
    That was actually one of my many attempts. Still unsuccessful for mainly two reasons. All MDI child forms wont show over top controls, and I cannot set the mdiParent property to a panel, which is what I'm using to house my child forms.
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

Tags for this Thread

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