focus woes while making a caption control for splitcontainer!

G

giddy

hi ,

I made a simple little caption control , i want to put it in a split
container so it looks a litte like the VS windows.

Problem is , i cant get it to the correct Inactive/Active colour!

Apparently , the splitcontainerPanel ContainsFocus even after it has
lost focus , atleast thats what you'd think after you run the code!

Thanks so much

Gideon

heres *part* of the code:
public class Caption : UserControl
{
public Caption()
{
InitializeComponent();
this.Dock = DockStyle.Top;
this.BackColor = SystemColors.GradientInactiveCaption;
}
private Label lblCaption;//i use this for the caption text
private Label lblMinimize;//this is for the minimize button
//events
private readonly object MininizeClickedEventLock = new
object();
private EventHandler MininizeClickedEvent;

protected override void OnLoad(EventArgs e)
{
Parent.GotFocus += new EventHandler(Parent_GotFocus);
Parent.LostFocus += new EventHandler(Parent_LostFocus);
base.OnLoad(e);
}
protected override void OnClick(EventArgs e)
{
Parent.Focus();
base.OnClick(e);
}
private void Parent_LostFocus(object sender, EventArgs e)
{
if (!Parent.ContainsFocus)
{
this.BackColor = SystemColors.GradientInactiveCaption;
}
}
private void Parent_GotFocus(object sender, EventArgs e)
{
this.BackColor = SystemColors.GradientActiveCaption;
}
private void lblCaption_Click(object sender, EventArgs e)
{
OnClick(EventArgs.Empty);
}
}
 
G

giddy

Nevermind , i got the answer. Seems i had to attach the GotFocus/
LostFocus handlers to all the panels child controls

Gideon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top