Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2007

Tip: Looking for answers? Try searching our database.

Event for activating "title" bar in WPF

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 24 Jul 2007 21:42 GMT
Hi,

I am wondering what event is raised if Window title is activated (i.e. if it
is inactive window title is by default grey and if it is activated it is
blue) in WPF. Activated event does not work :-( and I have tried many other
events and no luck :-(.

Please, help.

Thank you :-).
Scott M. - 24 Jul 2007 22:57 GMT
I wouldn't think it has anything to do with the title bar.  It is is a
matter of the form being active or having the focus.

> Hi,
>
[quoted text clipped - 8 lines]
>
> Thank you :-).
Linda Liu [MSFT] - 25 Jul 2007 03:03 GMT
Hi John,

When a window in a WPF Windows application is activated, the Activated
event of the window is raised. On the contrary, when the window is
deactivated, the Deactivated event of the window is fired.

The following is a sampe of handling the Activated and Deactivated event of
a window.

public partial class Window1 : System.Windows.Window
{
       public Window1()
       {
            InitializeComponent();
            this.Activated += new EventHandler(Window1_Activated);
            this.Deactivated += new EventHandler(Window1_Deactivated);
        }
         void Window1_Deactivated(object sender, EventArgs e)
       {
           Console.WriteLine("deactivated");
       }

       void Window1_Activated(object sender, EventArgs e)
       {
           Console.WriteLine("activated");
       }
}

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
John - 25 Jul 2007 08:48 GMT
Hi Linda,

Thank you for reply.
My issue is :
I have background thread which creates and displays "notification" window
(similar windows as Outlook notification of new e mail) every 2 minutes.
If my notification window is displayed it does not have focus. Focus remains
on application which has been active before displaying notification window -
e.g. if you are typing in Word and you receive e-mail - Outlook displays
notification window - but you can continue to type in Word (because
notification window is only displayed but has no input focus, etc.) so Word
does not lost focus - but there is also other window - Outlook notification
window (which is visible but has no focus).

In above case my notification window has IsActive=true but it has no "focus"
because focus is still e.g. in Word application. If I wanted to type into my
notification window, I should need to click it - so title bar of notification
window is changed from "grey" to "blue" - and then it is really focused and
activated and can receive input. But IsFocus is still false no matter window
is focused ... .

So is there any event or something which is raised when title bar changes
color from grye to blue (I am writing still about change of title bar color
because evidently IsFocus is not showing values I should expect) ?

Many thanks.

> Hi John,
>
[quoted text clipped - 50 lines]
>  
> This posting is provided "AS IS" with no warranties, and confers no rights.
Linda Liu [MSFT] - 25 Jul 2007 11:26 GMT
Hi John,

Thank you for your prompt response and detailed explanation.

You have mentioned the notification window is shown but without activated
and focused. How do you do that?

If possible, could you please send me a simple sample project?

To get my actual email address, remove 'online' from my displayed email
address.

Thank you for your cooperation!

Sincerely,
Linda Liu
Microsoft Online Community Support
Linda Liu [MSFT] - 27 Jul 2007 10:00 GMT
Hi John,

How about the problem now?

If the problem is still not solved, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support
John - 27 Jul 2007 20:22 GMT
Hi Linda :-),

I have sent you mail with my stripped project. (I was out of office ;-) )

Many thanks :-).

> Hi John,
>
[quoted text clipped - 7 lines]
> Linda Liu
> Microsoft Online Community Support
Linda Liu [MSFT] - 30 Jul 2007 07:19 GMT
Hi John,

Thank you for your sample project!

In WPF there are two main concepts that pertain to focus: keyboard focus
and logical focus. Keyboard focus refers to the element that receives
keyboard input and logical focus refers to the element in a focus scope
that has focus.

When a window is shown and activated, it contains the keyboard focus. When
we click the title bar of the window by the mouse, the window will get the
keyboard focus and the GotKeyboardFocus event will be raised.

For more information on focus in WPF, you may refer to the following
document:

http://msdn2.microsoft.com/en-us/library/aa969768.aspx

For your practice, I suggest you listen to the window's GotKeyboardFocus
event to get notified when the user click the title bar of the window.

Please try it out and let me know the result.

Sincerely,
Linda Liu
Microsoft Online Community Support
John - 30 Jul 2007 21:42 GMT
Thanks Linda

> Hi John,
>
[quoted text clipped - 22 lines]
> Linda Liu
> Microsoft Online Community Support

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.