![]() |
Languages »
C# »
Windows Forms
Intermediate
Synchronizing the Active State of multiple formsBy Rui LopesAssembly with classes for synchronizing the active state of multiple forms |
C#, Windows, .NET 1.0, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

This article is an adapted port to C# of my other article. The code of this article implements some forms that synchronize the active state with the owner form.
Features implemented:
I will base these examples in the source-code of the demo application included in this article.
Add a reference to the assembly Rgl.Windows.Forms.dll in your solution.
If you are implementing a dialog box or frame window derive your class from
Rgl.Windows.Forms.Form, or else, derive your class from
Rgl.Windows.Forms.FloatingForm (i.e. if your form will be a toolbar or
a toolwindow).
public class Form1 : Rgl.Windows.Forms.Formor
public class FloatingForm1 : Rgl.Windows.Forms.FloatingForm
For sample usage refer to the demo application and source-code.
Properties
ForceActive (Read-Only)
true when this Form is being draw in the active state.
SyncActive (Read-Write)
true if this Form will synchronize the active state with owner Form.
KeepAllwaysVisible (Read-Write)
true if this Form will stay visible when application is deactivated.
Helper methods
SetVisible
Visible property of the Form because when we set it
to true the Form is also activated; by using this method we can specify if we want
to activate the form or not.
Virtual methods (to override if needed)
OnForceActiveChanged
ForceActive property is changed.
OnCreateFloatingForms
OnLoad method or
event handler (read more about this in the BaseForm.cs file).
The key for synchronizing the active state of a form lies on the WM_NCACTIVATE
message. By handling or sending this message we can force the painting of a form in the active
or inactive state.
The automated hiding of a form is archived by handling the WM_ACTIVATEAPP
message.
The other two important messages that need to be handled are WM_ACTIVATE and
WM_SHOWWINDOW (handled by overriding OnVisibleChanged); you can find
information about them in the source code and in the
MSDN library.
To finish, I just want to say that when implementing this assembly I have run into some "strange" problems, read all about them in the source-code.
Do you have any question or comments? Contact me!
| You must Sign In to use this message board. | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 14 Mar 2002 Editor: Andrew Peace |
Copyright 2002 by Rui Lopes Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |