views:

60

answers:

1

Is it possible in .Net (or thru pinvoke) to determine if a windows form is obstructed from view (i.e. other windows have been moved over top of it, so it cannot be seen)? What I am doing is checking if the form is minimized, then flashing the window on the taskbar if it is. However the problem is if it is NOT minimized, but just moved to the background, I also want to notify the user by flashing the window on the taskbar. I do not want to move the window to the foreground automatically (even without activation). I want them to click on it to maximize and/or show the form. Ideas?

Here's some code:

                    // See if we already have a conversation going with this person
                    var frm = theApp.GetConversationByUID(fromuid);
                    if (frm == null)
                    {
                        frm = theApp.NewConversation(fromuid, fromname);
                    }
                    else
                    {
                        bool withinView = frm.WindowState != FormWindowState.Minimized;
                        if (withinView)
                        {
                            // Determine if window is just obstructed
                            //TODO
                        }

                        // If the conversation window is not within view, then flash it
                        if (!withinView)
                        {
                            FlashWindow.Flash(frm);
                        }
                    }

+1  A: 

Try this code.

SLaks
Tergiver's code is correct, long overdue for an answer mark. Fixed.
Hans Passant