Solved

Word as a Child in a MDI application

Posted on 2000-02-24
8
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

740 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