How To Get Parent Window

B

BradleyWard

Hello,

I am coding an Add-In in Project Professional 2007 and it involves several
dialogs.

The System.Windows.Forms.Form class that dialogs are derived from has a Show
and a ShowDialog method with various calling signatures. I want to use the
signature that starts with a IWin32Window owner parameter so that the dialog
will appear on screen in a position relative to the Project Professional
windows.

My question is, how do I find the IWin32Window value from the Project
Professional API?

Thanks

Brad
 
R

Rod Gill

The Application.Top and Application.Left properties already provide you with
what you want. Within that, the ActiveWindow.Left and .top further define
the screen. There shouldn't be any need to dive any deeper.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
B

Brad

Thanks for the quick reply, Rod, but this would seem to be a more complicated
approach than what I was hoping for.

What I was hoping for was this:

1. On my custom dialog, I simply set the forms StartPosition property to
CenterParent.

2. When I call the ShowDialog() method, I provide a pointer to the parent
screen, which would be a Project Professional screen. Bingo, I'm done... my
dialog pops up right in the middle of the Project Professionals screen.

I just need to find that pointer to the parent screen.

Brad
 
J

Jack Dahlgren

Actually, it may be the simplest way. Otherwise you can use the Windows API
and within that the easiest way is to use FindWindow.

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long

Then work from there.

-Jack Dahlgren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top