Results 1 to 2 of 2

Thread: Setparent Word to Modal Form

  1. #1

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Question Setparent Word to Modal Form

    Hi everyone!!!

    Why is Setparent not working on modal forms but works perfect with modeless forms?

    Here is my code on module.

    Code:
    Public Sub GrabMicrosoftWord(ByVal wName As String)
    Dim MicWord As Long
                   
        MicWord = FindWindow(vbNullString, wName & ".doc - Microsoft Word")
            If MicWord = 0 Then
                Exit Sub
            Else
                SetParent MicWord, Form1.hwnd
            End If
    
    End Sub
    I call it like.

    Code:
    Form1.Show vbModal
    GrabMicrosoftWord (wName)
    vbmodal won't trigger SetParent. What is the workaround for this thanks?


    -zynder

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Setparent Word to Modal Form

    If you put a breakpoint on the GrabMicrosoftWord line, you will see that it does not get triggered. By showing your form modally, all lines of code that follow must wait til the modal form is either unloaded or hidden. It's not that it isn't working, the line of code is not being executed until your modal form closes.

    Try swapping the 2 lines. Better?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width