110,537
社区成员
发帖
与我相关
我的任务
分享
public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); //窗体置顶
public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); //取消窗体置顶
public const uint SWP_NOMOVE = 0x0002; //不调整窗体位置
public const uint SWP_NOSIZE = 0x0001; //不调整窗体大小
public static bool setTopChildWin()
{
IntPtr ChildWin = FindWindow(null, "MessageTip"); // 窗口类型WpfApplication1 窗口主题Tip
int childwin = (int)ChildWin;
if (childwin != 0)
{
SetWindowPos(ChildWin, MainWindow.HWND_TOPMOST, 0, 0, 0, 0, MainWindow.SWP_NOMOVE | MainWindow.SWP_NOSIZE);
return true;
}
return false;
}
private void timer_method()
{
if (_ckbtextstatus == true)
{
//查找窗口并置顶
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
new delegate_setTopChildWin(setTopChildWin));
if (_settop == false)
{
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
new delegate_messagetip(messagetip));
}
}
}
private delegate void delegate_setTopChildWin();
/// <summary>
/// 窗口置顶
/// </summary>
/// <returns></returns>
private void setTopChildWin()
{
IntPtr ChildWin = FindWindow(null, "MessageTip"); // 窗口类型WpfApplication1 窗口主题Tip
IntPtr ChildWin1 = FindWindow("TimeTipAPP", null);
IntPtr ChildWin2 = FindWindow("APPMessage", null);
int childwin = (int)ChildWin;
if (childwin != 0 && _messagewin!=null)
{
//SetWindowPos(ChildWin, MainWindow.HWND_TOPMOST, 0, 0, 0, 0, MainWindow.SWP_NOMOVE | MainWindow.SWP_NOSIZE);
_messagewin.Topmost = true;
_settop = true;
return ;
}
_settop = false;
return ;
}
/// <summary>
/// 提醒弹窗委托
/// </summary>
/// <returns></returns>
private delegate void delegate_messagetip();
private void messagetip()
{
_parentWin = Window.GetWindow(this);
_messagewin = new APPMessage(_textmessage);
_messagewin.Owner = _parentWin;
hide();
_messagewin.Show();
setTopChildWin();
}
主要在新弹出窗口移动并关闭后,定时器再次执行到 //查找窗口并置顶
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
new delegate_setTopChildWin(setTopChildWin));这个句就卡主了