实现内容:
类似于微信关掉后台右边会有图标在
然后接口给我发消息了就立马弹窗出来在中间
求指教!
把C# Winforms桌面程序最小化到托盘?请参考:
当你接收到消息时,进行类似如下的操作(还原窗体状态即可):
勾选【File】【BuildingSettings】【PlayerSettings】【ResulotionandPresentation】【RuninBackground】。
然后在update中加入:
if(XX){
ShowWindow(FindWindow(null,"XXX"), 1);
}
//把XXX换成你的窗口标题
//把XX换成你定义的收到消息
在与update同级的位置加入:
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("User32.dll", EntryPoint = "FindWindow")]
public extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
在start里加入:
ShowWindow(FindWindow(null,"XXX"), 0);
这样,运行时会隐藏窗口(并隐藏任务栏图标),收到消息后显示。
如果你不希望隐藏任务栏,那么把0改成2。