المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Show a modeless form from an app with no main form?



C# Programming
01-20-2010, 01:40 PM
Copying an example I found, I have a Windows application with no main form that just manages a NotifyIcon in the tray with its small context menu functions. As such, its Main has Application.Run() instead of Application.Run(someform). That part works fine.

Now I need it to conditionally show/hide a form. There are no user interaction controls on the form (it's display only) and the "default" condition is to have the form hidden. If I use Form.ShowDialog(), the form appears, but blocks the user interaction that is associated with the NotifyIcon.ContextMenu and I have no way to remove it. If I use Form.Show() to keep the user interaction with NotifyIcon functional, the form appears but none of its contained controls render and it forever shows the Wait cursor.

After much fruitless searching for a threading issue (even though InvokeRequired is always false), I came across a clue that it might instead be a message pump issue. This makes some sense (since I can fully show and hide the form if I do it within the ContextMenu event handlers), but I can't find enough info to compose a candidate solution.

How do I get this form to complete its rendering without making it modal?