all groups > visual studio .net ide > march 2004 >
You're in the

visual studio .net ide

group:

Getting parent IWin32Window when implementing ComponentDesigner verbs


Getting parent IWin32Window when implementing ComponentDesigner verbs Stephen Walch
3/10/2004 1:54:12 PM
visual studio .net ide:
I am implementing a ComponentDesigner so I can add design-time verbs for my
component and I can not figure out how to get a handle to the VS.NET window.
The reason I want this is so I can pass it to commands like
Dialog.ShowModal(owner) and MessageBox.Show(owner). Also I would like to
control positioning of my dialogs relative to the VS.NET form designer. Any
advise?

RE: Getting parent IWin32Window when implementing ComponentDesigner verbs v-garych NO[at]SPAM online.microsoft.com
3/11/2004 5:19:16 AM
Hi Stephen,

Thanks for posting in the community.

[quoted text, click to view]
form designer...

Based on my research, there seems no way to get the windows of VS.NET and
form designer from the FormDocumentDesigner object, for the reason that
some corresponding properties are private .
However if you can access the DTE object, I think maybe you can retrieve
the DTE.MainWindow and Windows's properties from it.

[quoted text, click to view]

The Dialog or the MessageBox which driven by the design-time verbs is the
modal dialog of the main window of the VS.NET windows, so passing somewhat
handle to the Dialog.ShowModal(owner) would be invalid.


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Re: Getting parent IWin32Window when implementing ComponentDesigner verbs Stephen Walch
3/11/2004 8:04:26 AM
DTE.MainWindow looks promising. DTE.MainWindow.HWnd is an integer, but I
can not figure out how to get an IWin32Window from that.

Thanks again.

[quoted text, click to view]

Re: Getting parent IWin32Window when implementing ComponentDesigner verbs v-garych NO[at]SPAM online.microsoft.com
3/12/2004 7:50:31 AM
Hi Stephen,

Thanks for your quickly response!

[quoted text, click to view]

yes, the DET object is a COM object, it has no IWin32Window stuff, and I
think it seems the VS.NET IDE has no such IWin32Window wrapper either.


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Re: Getting parent IWin32Window when implementing ComponentDesigner verbs a-sammok NO[at]SPAM online.microsoft.com
3/19/2004 12:17:44 AM
You can try using WIN32 functions and import it like below. see example
belows:

I don't know what language you use. I try this in C#. It works fine.

Add the following to your class:
using System.Runtime.InteropServices;

[DllImport("User32.DLL")]
static extern uint GetForegroundWindow();

[DllImport("User32.DLL")]
static extern int MessageBox(
uint hWnd, // handle to owner window
String lpText, // text in message box
String lpCaption, // message box title
uint uType // message box style
);

MessageBox(GetForegroundWindow(), "MyDiag","myCaption", 0);


Please let me know if this is something you looking for. Thanks!

Thank you for choosing the MSDN Managed Newsgroups,

Sam Mok
Microsoft Developer Support

This posting is provided AS IS with no warranties, and confers no rights.
Re: Getting parent IWin32Window when implementing ComponentDesigner verbs a-sammok NO[at]SPAM online.microsoft.com
3/19/2004 3:18:19 PM
Below is just an example, you can get handle to windows in Z-order using
platform SDK e.g. GetWindow and GetParent() functions.

========== Previous suggestions ==================

You can try using WIN32 functions and import it like below. see example
belows:

I don't know what language you use. I try this in C#. It works fine.

Add the following to your class:
using System.Runtime.InteropServices;

[DllImport("User32.DLL")]
static extern uint GetForegroundWindow();

[DllImport("User32.DLL")]
static extern int MessageBox(
uint hWnd, // handle to owner window
String lpText, // text in message box
String lpCaption, // message box title
uint uType // message box style
);

MessageBox(GetForegroundWindow(), "MyDiag","myCaption", 0);


Please let me know if this is something you looking for. Thanks!

Thank you for choosing the MSDN Managed Newsgroups,

Sam Mok
Microsoft Developer Support

This posting is provided “AS IS” with no warranties, and confers no rights.
AddThis Social Bookmark Button