mufik

I made a new control. It is a popup window. I need to hide this popup when user clicks to other part of the form. How is the best way to do this


Re: .NET Compact Framework pocket pc popup control

Stephen Hauck

You could do this in a lostfocus event on the popup or in the gotfocus event of the calling window.

I would try to code it in the gotfocus of the calling window myself but that can cause issues if you need to validate something on the popup before it closes.





Re: .NET Compact Framework pocket pc popup control

mufik

Yes, I know. On Lost Focus I hide this Popup, but Lost Focus fire only if I click on other button or textbox. So I wrote the hide method to Form Click event, but this is not still perfect.
If you try for example combo box, if you click on other button when the popup is shown, the button does not fire its event. But it is not enabled, so I do not know how to do this effect.




Re: .NET Compact Framework pocket pc popup control

Stephen Hauck

Instead of making it a seperate window you could make it a user control that you hide and show instead.

I will see if I can figure out your problem though.





Re: .NET Compact Framework pocket pc popup control

mufik

I'm sorry but I don't understand you. My popup is user control. I just like to do it in the same way like for example simple combox is (when popup is shown and you click on other button it doesn't fire any event, but the button is not disabled - it isn't grey. The click on other control only hides the popup)




Re: .NET Compact Framework pocket pc popup control

timg_msft

When you show your popup user control, set its "Capture" property to true.

Look at Mouse events. If you get a mouse-down event that is outside your control's client area, set "Capture" to false and hide your control.






Re: .NET Compact Framework pocket pc popup control

mufik

so should I check OnClick event of every control on Form




Re: .NET Compact Framework pocket pc popup control

timg_msft

no. you shouldn't be looking for click events. you should be looking for mouse (up or down) events only on your popup control. click events don't give you cursor location (where the click happened). Mouse events do.




Re: .NET Compact Framework pocket pc popup control

mufik

one last question. on my popup control is a scrollbar. If I set capture on control, when I click on scrollbar it does nothing. Is there a possibility to resolve this problem




Re: .NET Compact Framework pocket pc popup control

timg_msft

you would need to forward the mouse events your control is now receiving to the scroll bar.




Re: .NET Compact Framework pocket pc popup control

zbynda

I am mufik. I tried it but I do not know how to do it in the best way... can you help me please