wwdLeft = (fWidth - wwdWidth) / 2;
wwdTop = (fHeight - wwdHeight) / 2;Windows里面不是你想置顶就置顶的,曾经有无数程序都想要把自己置顶,抢占用户桌面,于是Windows就定下来一套规矩。
简单地思考:如果有两个程序都想要把自己放在最前端,那么最后会是什么结果呢?
SetForegroundWindow function (Windows)
The system restricts which processes can set the foreground window A process can set the foreground window only if one of the following conditions is true:
The process is the foreground process
The process was started by the foreground process
The process received the last input event
There is no foreground process
The process is being debugged
The foreground process is not a Modern Application or the Start Screen
The foreground is not locked (see LockSetForegroundWindow)
The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo)
No menus are active创建窗口后,保存窗口对象,再次打开前,判断其是否已经存在,存在则将原来打开的窗口,置顶显示,否则,重新创建。
注意:WPF窗口CLOSE后并不会销毁自动销毁自身的资源,需要将保存的数据结构的reference置为null,以让clr释放内存
private void 最大化按钮(object sender, RoutedEventArgs e) {
WindowState = (thisWindowState == WindowStateNormal WindowStateMaximized : WindowStateNormal);
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)