Solved

Word as a Child in a MDI application

Posted on 2000-02-24
8
271 Views
Last Modified: 2010-05-02
Hello!
I need some help on a tough case I'm working on.
I have an MDI application, and I would like to use Word2000 as the text editor of the application. And here is the tough part: I want word to act like a child-form of the MDI-form. Is this possible? I have tryed to use the OLE container. But I was not satisfied with that, because I had to double-click it to activate it.
0
Comment
Question by:Olli083097
8 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 2553705
If you use the OLE container, you can open the document in the container using:

OLE1.DoVerb vbOLEShow

In the form_load event for example.
0
 

Author Comment

by:Olli083097
ID: 2553755
TimCottee:
Well, but this is not exactly what I want... I need the Word-menubar, toolboxes/-lines and so forth...

Bu tmost of all I would like to solve the problem without using a VB-childform...

-Olli
0
 
LVL 28

Expert Comment

by:Ark
ID: 2553806
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:ravisayal
ID: 2553969
Here is a code that will make the MS-Word the Child Window of ur application window But U will have too look for other API functions  as well if U want to make it perfect. I am using MDI-FORM dbl Click event here U can use whatever U want.



Option Explicit

Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long ' hMenu
Private Declare Function SetMenu Lib "user32" (ByVal hWnd As Long, ByVal hmenu As Long) As Long 'C BOOL
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long


Private Sub MDIForm_DblClick()
Dim lng_wrdwindow As Long, lng_mywindow As Long, i As Long, lng_wrdmenu, j
Dim str_windowname As String

str_windowname = "Microsoft Word - Document1"
lng_wrdwindow = FindWindow(vbNullString, str_windowname)
lng_mywindow = Me.hWnd
i = SetParent(lng_wrdwindow, lng_mywindow)
i = MoveWindow(lng_wrdwindow, 5, 10, (Me.ScaleWidth / Screen.TwipsPerPixelX) - 10, (Me.ScaleHeight / Screen.TwipsPerPixelY) - 10, -1&)
lng_wrdmenu = GetMenu(lng_wrdwindow)
j = SetMenu(lng_mywindow, lng_wrdmenu)

' the settting of menu doesnot work in case simple
' menus only not with Coolbars that Ms Word uses,
' but I wont say it is impossible, I havent tried it yet

End Sub


0
 
LVL 1

Accepted Solution

by:
jelliott720 earned 200 total points
ID: 2554068
The best example I've seen of doing this is called Office Framer, which can be found at :

(http://support.microsoft.com/download/support/mslfiles/OFramer.exe)


Hope this helps..
0
 

Author Comment

by:Olli083097
ID: 2557129
jelliott720:
Awesome!!! Thanx man, this really helped! Just what I needed!

all:
Thanx for trying!

BTW: the GetWindowRect API reads the  rect of the entire MDIForm, I need the rect of only the worspace in it. What can I do about this?
0
 
LVL 28

Expert Comment

by:Ark
ID: 2557189
Hi
Workspace is child of MDIForm, Child windows are actually childs of workspace. So, use this
hWork = GetWindow(MDIForm1.hwnd, GW_CHILD)
GetWindowRect hWork, rc

Good luck
0
 

Author Comment

by:Olli083097
ID: 2557538
Ark:
Thanks, it worked!

All:
I have been tweaking on this for a few hours now, and it's getting really nice. But I still have a problem:
I have the Word window as a child (not maximized). When I click on the Word titlebar to move it, it jumps away form the mouse pointer... How do I fix this?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question