Windows.Form help

Z

Zac

Well, this is my first foray into Windows forms and I've hit a snag
already. I'm using a borderless form as a dialog box of sorts and I
have a web browser control inside of it. When the user clicks on a
link label, it pops up the the windowless form which will show some
information in the Web Browser. I've set a mouseleave event on the
form to hide it when leaving the borderless form to continue working
in the application.

The problem I'm having is when the mouse moves over the web browser
control in the borderless form, the form loses focus and the form is
hidden(makes sense as the mouse is leaving the form control and moving
into the browser control). How can I tie the web browser to the form
so the form knows not to close while the user is in the browser
control?

I've been looking for a day now, but can't seem to be able to type the
correct search terms in Google to find the info I need.

Thanks!
Zac
 
N

Nicholas Paldino [.NET/C# MVP]

Zac,

I would override the WndProc method and look for the WM_KILLFOCUS
message. In it, you will get the handle of the window that receives the
keyboard focus. You can pass that handle to the static FromHandle method on
the Control class to get the control that corresponds to that handle (or
nothing, if it is not a .NET control). Then, compare it to your WebBrowser
control. If they match, do not close the window, otherwise, close the
window.
 
Z

Zac

Zac,

I would override the WndProc method and look for the WM_KILLFOCUS
message. In it, you will get the handle of the window that receives the
keyboard focus. You can pass that handle to the static FromHandle method on
the Control class to get the control that corresponds to that handle (or
nothing, if it is not a .NET control). Then, compare it to your WebBrowser
control. If they match, do not close the window, otherwise, close the
window.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Well, this is my first foray into Windows forms and I've hit a snag
already. I'm using aborderlessform as adialogbox of sorts and I
have a web browser control inside of it. When the user clicks on a
link label, it pops up the the windowless form which will show some
information in the Web Browser. I've set a mouseleave event on the
form to hide it when leaving theborderlessform to continue working
in the application.
The problem I'm having is when the mouse moves over the web browser
control in theborderlessform, the form loses focus and the form is
hidden(makes sense as the mouse is leaving the form control and moving
into the browser control). How can I tie the web browser to the form
so the form knows not to close while the user is in the browser
control?
I've been looking for a day now, but can't seem to be able to type the
correct search terms in Google to find the info I need.
Thanks!
Zac

That makes me a little nervous, but I've seen it before. :) I'll see
if I can find some help on how to do that on google. Thank you for the
direction.
 

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