Programmatic MouseEnter and MouseLeave

G

Guest

I need to programmatically add an invisible control to my form that will
enable me to trigger MouseEnter and MouseLeave code relative to the control
area.

Is this possible to add the control and the triggers without the use of the
Form Designer? How?

My Form Design window is won't let me add any more controls so that is why I
need to do this programmatically. After two years of coding on this project
it blows up even if I look cross-eyed at it. :blush:(

I really need to programmatically add the invisible control with associated
MouseEnter and Leave triggers to complete my project.

Thanks!

Bob
 
P

PlatinumBay

Bob,

Wow, I think you may have bigger problems that just an invisible control.

I wrote a little test app to repeatedly add button controls to a form. The
app errors out (Win32Exception: Error creating window handle) at 9964
controls.

You must have a lot of controls if the designer won't let you add more.

You might want to look at componetizing controls into user controls, more of
an OO approach.

Also, why do you need an invisible control to handle the triggers, you could
add the logic to the form itself to detect those events, and determine if it
is in a specific area.

Hope this helps,


Steve
 
G

Guest

Than ks Cor,

I tried programmatically making a listbox but it does not show up. :blush:(

Here is the code I tried...

'MyListBox
Dim MyListBox As New ListBox

'
MyListBox.AllowDrop = True
MyListBox.Items.AddRange(New Object() {"A", "B", "C", "D"})
MyListBox.Location = New System.Drawing.Point(232, 176)
MyListBox.Name = "MyListBoxH2"
MyListBox.Size = New System.Drawing.Size(56, 17)
MyListBox.TabIndex = 100
MyListBox.BringToFront()
MyListBox.Visible = True
MyListBox.Enabled = True
MyListBox.ItemHeight = 13
Controls.Add(MyListBox)

Thanks!
Bob
 
G

Guest

Than ks Cor,

I tried programmatically making a listbox but it does not show up. :blush:(

Here is the code I tried...

'MyListBox
Dim MyListBox As New ListBox

'
MyListBox.AllowDrop = True
MyListBox.Items.AddRange(New Object() {"A", "B", "C", "D"})
MyListBox.Location = New System.Drawing.Point(232, 176)
MyListBox.Name = "MyListBox"
MyListBox.Size = New System.Drawing.Size(56, 17)
MyListBox.TabIndex = 100
MyListBox.BringToFront()
MyListBox.Visible = True
MyListBox.Enabled = True
MyListBox.ItemHeight = 13
Controls.Add(MyListBox)

Thanks!
Bob
 
B

BobAchgill

Mike,
Also, why do you need an invisible control to handle the triggers, you could
add the logic to the form itself to detect those events, and determine if it
is in a specific area.

Thanks, I added the logic using mousemove on the form and it works
great!

Wow, I think you may have bigger problems that just an invisible control.

I wrote a little test app to repeatedly add button controls to a form. The
app errors out (Win32Exception: Error creating window handle) at 9964
controls.

Well, I don't think it is because of too many controls that my design
window crumps. And even when I so much as move a control on the
window it crumps. Got any ideas how to debug why the designer would
be so ill?

Bob
 
C

Cor Ligthert [MVP]

Bob,

This shows in the left beneath corner a listbox, are you sure your form is
large enough?

Private Sub Form1_Load(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'MyListBox
Dim MyListBox As New ListBox

'
MyListBox.AllowDrop = True
MyListBox.Items.AddRange(New Object() {"A", "B", "C", "D"})
MyListBox.Location = New System.Drawing.Point(232, 176)
MyListBox.Name = "MyListBox"
MyListBox.Size = New System.Drawing.Size(56, 17)
MyListBox.TabIndex = 100
MyListBox.BringToFront()
MyListBox.Visible = True
MyListBox.Enabled = True
MyListBox.ItemHeight = 13
Controls.Add(MyListBox)
End Sub

Cor
 
G

Guest

Cor,

My form was big enough... but the list box was hiding under something else
on the form. Thanks!

Hey, now I am trying to programmatically add a Flash control to my form that
already has some Flash controls. (so I know the references are right) I
tried to follow what you showed me for adding a control programmatically but
it does not work. Do you see anything I may be missing... I had to comment
out the one line ...

'AxShockwaveFlash10.OcxState = ...

because the "Resources.GetObject" was saying GetObject is not a member of
Resources.

Here is the code...

'AxShockwaveFlash10
Dim AxShockwaveFlash10 = New AxShockwaveFlashObjects.AxShockwaveFlash
'
AxShockwaveFlash10.Enabled = True
AxShockwaveFlash10.Location = New System.Drawing.Point(100, 100)
AxShockwaveFlash10.Name = "AxShockwaveFlash10"
'AxShockwaveFlash10.OcxState =
CType(Resources.GetObject("AxShockwaveFlash10.OcxState"),
System.Windows.Forms.AxHost.State)
AxShockwaveFlash10.Size = New System.Drawing.Size(152, 144)
'AxShockwaveFlash10.TabIndex = 29

Controls.Add(AxShockwaveFlash10)

AxShockwaveFlash10.Movie = strCurDir + "\MyFlash.swf"
AxShockwaveFlash10.Play()
AxShockwaveFlash10.Loop = True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top