-
Dec 17th, 2011, 09:15 AM
#1
Thread Starter
Hyperactive Member
[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:
Public Class Form1 Private Sub Form1_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim nForm As New Windows.Forms.Form() Dim nTextBox As New Windows.Forms.TextBox() nTextBox.Location = New Point(0, 0) nTextBox.Size = New Size(158, 20) nTextBox.Text = "Sample text" nForm.TopLevel = False nForm.Controls.Add(nTextBox) Me.Controls.Add(nForm) nForm.BringToFront() nForm.Show() End Sub End Class
-
Dec 17th, 2011, 10:12 AM
#2
Thread Starter
Hyperactive Member
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:
Public Class Form1 Friend Declare Function SetParent Lib "user32" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer Private Sub Form1_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim nForm As New Windows.Forms.Form() Dim nTextBox As New Windows.Forms.TextBox() nTextBox.Location = New Point(0, 0) nTextBox.Size = New Size(158, 20) nTextBox.Text = "Sample text" SetParent(nForm.Handle, Me.Handle) nForm.Show() End Sub End Class
The result is a form within the parent from, whom contains normal funtioning textbox controls
-
Dec 17th, 2011, 10:49 AM
#3
Re: [RESOLVED] Textbox Behavioral bug with MDI(child) Forms.
you can do the same thing with the form's mdiParent property
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 17th, 2011, 01:33 PM
#4
Thread Starter
Hyperactive Member
Re: [RESOLVED] Textbox Behavioral bug with MDI(child) Forms.
Originally Posted by .paul.
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.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|