开发者

c# Maximize Window from System Tray

I am having trouble trying to bring my application window to the fro开发者_JS百科nt (i.e on top of all other windows). I want the user to be able to double click the notifyIcon in the system tray, and If the application already has a window open for it to be bought to the front. I have tried using the following two P/inovkes but neither seem to work consistently. Does anybody have any idea how to bring a window to the front/top?

[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

[DllImport("user32.dll")]
tatic extern bool SetForegroundWindow(IntPtr hWnd);

ShowWindowAsync(ADProcess.MainWindowHandle, SW_RESTORE);
SetForegroundWindow(ADProcess.MainWindowHandle);


Given the little info you have provided the best guess I can make is that you have a timing issue with the call to ShowWindowAsync which runs asynchronously followed by the call to SetForgroundWindow.

Have you tried using ShowWindow to see if that works correctly?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜