|
-
Jun 29th, 2005, 10:00 AM
#1
Thread Starter
Member
Opening a child form from an office application [RESOLVED]
Hello. I have a routine for opening child forms from Visio. This is how I'm doing it:
frm is my form, and oVisio is my visio application
VB Code:
SetParent(frm.hWnd,oVisio.Window.WindowHandle32)
frm.Show
the problem is, if the visio window isn't maximized, the form doesn't appear in the center, but appears where the center would be IF it was maximized. my StartUpPosition is set to 1, which is center owner. What do i need to do to make it center to the current size of the application?
Thank you!
Last edited by Vhati; Jun 29th, 2005 at 05:09 PM.
Reason: Resolution
-
Jun 29th, 2005, 11:15 AM
#2
Re: Opening a child form from an office application
You could use the SetWindowPos API to position the child window where ever you want. Your forms startup position doesnt
matter, its the child windows positioning thats causing the issue. When Visio is started the child window is already positioned. Then
when you change the parenting it just adds the child windows handle to be a child window of your form.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 29th, 2005, 11:17 AM
#3
Thread Starter
Member
Re: Opening a child form from an office application
How do i find the width and height of the Visio window?
-
Jun 29th, 2005, 01:41 PM
#4
Re: Opening a child form from an office application
Oh, I just relaized that your setting a vb form as a child window of Visio and not the other way around.
You can get the window props probably from the oVisio.Window object. If not then you could use some APIs to get it - GetWindowPlacement, etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 29th, 2005, 05:09 PM
#5
Thread Starter
Member
Re: Opening a child form from an office application
Well i figured it out, if anyone is interested, here was the solution i came up with
VB Code:
'get the visio window rectangle
'get the visio window rectangle
Dim left As Long, top As Long, width As Long, height As Long
g_ovAppVisio.Window.GetWindowRect left, top, width, height
'get the form rectangle
Dim frmTop As Integer, frmLeft As Integer, frmWidth As Integer, frmHeight As Integer
Call GetWindowRect(frm.hWnd, Rect)
'do some minor calculations
frmWidth = Rect.right - Rect.left
frmHeight = Rect.bottom - Rect.top
frmLeft = width / 2 - frmWidth / 2
frmTop = height / 2 - frmHeight / 2
'move the form to the center
ret = SetWindowPos(frm.hWnd, 0, frmLeft, frmTop, frmWidth, frmHeight, 0)
frm.Show
Thanks for your suggestions!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|