I have a TileItem in a tilecontrol (DevExpress). On click this method is fired
private void tileItem1_ItemClick_1(object sender, DevExpress.XtraEditors.TileItemEventArgs e)
{
if (GetForegroundWindow() == Process.GetCurrentProcess().MainWindowHandle)
{
MessageBox.Show("It is focused!");
//do some magic here
}
else
{
MessageBox.Show("It is not focused!");
this.Activate();
}
}
My problem is that even if my form is not focused, it will think that it is focused and always triger the first condition of the if statement. I want to activate the window when the tileitem is clicked IF the window is not focused. Isn't this the proper way to do it? What i am thinking is that the method is triggered after the mouse is released so the window has already taken focus by that time. If this is the problem then which is the solution to achieve what i am trying to do?
Thanks is advance.
Aucun commentaire:
Enregistrer un commentaire