Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Windows Forms focus question

Reply
 
Old 02-22-2007   #1 (permalink)
lawndart


 
 

Windows Forms focus question

I'm playing around with .NET forms and such (no experience with them)
and I'm trying to pop open a dialog box in front of my current app
instead of behind it (this is on XP SP2), From the .Net Class Library
on TechNet it looks like I need to include an IWin32Window object that
references the app I want the window in front of. My code is:

[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[Windows.Forms.MessageBox]::Show([Windows.Forms.IWin32Window]::Handle,"Proceed?","Question",
[Windows.Forms.MessageBoxButtons]::YesNo)

I can do the same basic thing with some vbscript compiled into an exe,
but I'd really like to figure out .Net, and using it with powershell
is an excellent excuse. So what am I missing?

Lawndart


My System SpecsSystem Spec
Old 02-22-2007   #2 (permalink)
Marco Shaw


 
 

Re: Windows Forms focus question

> I'm playing around with .NET forms and such (no experience with them)
> and I'm trying to pop open a dialog box in front of my current app
> instead of behind it (this is on XP SP2), From the .Net Class Library
> on TechNet it looks like I need to include an IWin32Window object that
> references the app I want the window in front of. My code is:


I tried this out too a few months ago, and posted here...

I actually *think* there is an issue with XP here.

See also:
http://community.bartdesmet.net/blog...9/16/4429.aspx


My System SpecsSystem Spec
Old 02-22-2007   #3 (permalink)
RichS


 
 

Re: Windows Forms focus question

There's definitely an issue with dialog boxes from PowerShell on XP. Its
even mentioned as an issue in Bruce Payette's book
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Marco Shaw" wrote:

> > I'm playing around with .NET forms and such (no experience with them)
> > and I'm trying to pop open a dialog box in front of my current app
> > instead of behind it (this is on XP SP2), From the .Net Class Library
> > on TechNet it looks like I need to include an IWin32Window object that
> > references the app I want the window in front of. My code is:

>
> I tried this out too a few months ago, and posted here...
>
> I actually *think* there is an issue with XP here.
>
> See also:
> http://community.bartdesmet.net/blog...9/16/4429.aspx
>
>
>

My System SpecsSystem Spec
Old 02-22-2007   #4 (permalink)
lawndart


 
 

Re: Windows Forms focus question

Ah, well, glad it's not just me

This page: http://mow001.blogspot.com/2006/10/p...ction-gui.html
has a handy example of a cheat to make it focus properly.

Lawndart

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Windows Forms without ShowDialog? PowerShell
simulate continuous forms & subforms in a windows forms application .NET General
Windows Forms Editor PowerShell
Error with Windows.forms.form PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46