Click here to Skip to main content
15,851,510 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm making a desktop app that pops up a notification window when I need to catch the user's attention.

The problem is there may be multiple notifications (running a foreach on a List containing the info to be presented) and the class I'm using isn't working for that.

I'm using Taskbar Notifier[^] as my popup, but internally it uses ShowWindow to display the form so I can't use ShowDialog to call it.

If I could use ShowDialog, the foreach on the List would wait until each popup was done displaying before going on to the next. As it is now, only the last popup is seen...they're all stacked on top of each other.

Anyway, is there any "external" way of modalizing a non-modal window?
Posted

After careful examination of the claas' source code, I figured out why he used ShowWindow to show the window. It takes parameters; one of which determines how the window is displayed.

In this case, "NOACTIVATE".

D'oh. I can do that another way using CreateParams.

I replaced the internal ShowWindow with ShowDialog, and all is right with the world now. (And changed the Hide() to Close() so the window actually closes when it disappears.)
 
Share this answer
 
It does not look to me that modalizing could help you, as far as I understand your situation. Modularizing is ShowDialog. And "only the last popup is seen" and "stacked on top of each other" are intrinsic attributes of modal behavior, without those the modal behavior should be considered abused (or not considered modal, whatever you prefer, but that kind of non-modal would be really ugly). By the way, "stacked on top of each other" is typical, but best avoided. Microsoft does a lot of it in legacy utilities, but goes out of it. And out of modal paradigm, if you could notice that.

So, I would think of modal-free UI design, which is quite possible. Ever thought about it? Compare C++ project in Visual Studio with C# projects. As C++ projects are more of the legacy, they have way more modal windows compared to C# — almost nothing is modal (I don't count standard file dialogs — they are tolerable).

—SA
 
Share this answer
 
Comments
GenJerDan 10-May-12 9:16am    
Whether "modal" is tyhe right term or not...don't know. But if I have three popups that need to be shown sequentially, the second has to wait for the first to finish, then it would pop up while the third waits. Then, after the second is done, the third can annoy the user. In a previous incarnation of the app, I used ShowDialog on the popup (which was just a regular form with some animation) and it worked fine because ShowDialog didn't return until it was done. This form uses ShowWindow (grrrrrr), so it "returns" immediately and the second and third appear before the previous one(s) are done. I'd have to go back to the old popup...if I can find the code...this one is SO much nicer.
Sergey Alexandrovich Kryukov 10-May-12 19:34pm    
True, what you describe is very annoying. Modal behavior means that you cannot activate any other window until you close the one on top. It can be application-modal (most usual), but some are system-modal (no window of any application cab be activated). This behavior should ether be used and not violated or not used at all.

Now, just one modal pop-up on top of some non-modal (usually main) windows is still tolerable, but anything on top of it is extremely annoying, even though it is often used, for example, in old Microsoft programs, like control panel applets. I would advice to avoid it by every means, no matter what. Better anything, but not this.

There are different paradigms for that. One is using no modal windows at all; having some always accessible controls in the main form, that's it. Control things by enable/disable, hide, etc. but keep everything non-modal and be able to activate focus at all times. Another example would be a wizard.

--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900