.net - Why doesn't Word "come to front" when we activate it? -
our winforms application interacts ms word , run code when document generated , want show in word in front of our application:
[setup w word interop object] w.visible = true w.activate()
when rolled out xp machines running office 2007 works intended.
on win7 machines running office 2010 document loads behind our application , flashes on taskbar.
any ideas?
i stumbled upon similar problem recently. .net program called com application, on win7 neither show in taskbar nor on desktop @ all. wasn't able track down cause of this, wrote following function work around issue:
[system.runtime.interopservices.dllimport("user32.dll")] private static extern bool setforegroundwindow(intptr hwnd); private static void bringapptofront() { foreach (var p in system.diagnostics.process.getprocesses().where(p => p.processname == "cominstancename")) { if (p.mainwindowhandle.toint32() != 0) setforegroundwindow(p.mainwindowhandle); } }
Comments
Post a Comment