Results 1 to 7 of 7

Thread: show modeless form from dll

  1. #1

    Thread Starter
    Hyperactive Member Scott Penner's Avatar
    Join Date
    Dec 2000
    Location
    Mountain View
    Posts
    327

    Unhappy

    Hey,

    Is there a way to show a modeless form from an ActiveX dll that stays on top of the main application's form?

    I can't pass the main form as a parameter to the wrapper class for displaying the form. And, If I try to pass the form as an object and then use this object to be the parent of the form I'm trying to display, I get an error saying that this object cannot be the parent of the form I'm trying to load...

    any ideas?
    -scott
    he he he

  2. #2
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796
    You could try using the 'SetWindowPos' API call to force the window to stay on top.

  3. #3

    Thread Starter
    Hyperactive Member Scott Penner's Avatar
    Join Date
    Dec 2000
    Location
    Mountain View
    Posts
    327

    Unhappy this works but not for me

    Thanks,
    That was a good idea. I tried this with two forms in the same project and it worked great. Unfortunately, when showing this form from the dll I no longer get a form Deactivate event!?
    So, this is what I did, but it's not working from the dll.

    Code:
    Private Sub Form_Deactivate()
       ' Force this form to the top of the window list
       ' Emulates modeless form operation with main app's form as parent
       Debug.Print "frmPartSetup Deactivated"
       SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE
    
    End Sub
    Any more ideas?
    -scott
    he he he

  4. #4
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277
    I'm looking for a way to display a form from a DLL and make it vbModal of the main form that it was called from, but i haven't been able to figure it out either.
    ~Peter


  5. #5

    Thread Starter
    Hyperactive Member Scott Penner's Avatar
    Join Date
    Dec 2000
    Location
    Mountain View
    Posts
    327

    Unhappy this one works

    I had this working...
    If you show the form modally, it should automatically be modal to the main application because the dll is in the same process as the calling form.
    That's how I had my app running, but I now need to show the form while allowing the user to access the underlying form as well.
    -scott
    he he he

  6. #6
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Smile Tell me,

    Why did you put the API call in the form_deactivate event?

    It seems like you are using it to 'Rescue' your form when it gets deactivated but why not call immediately after the form.Show method?

  7. #7

    Thread Starter
    Hyperactive Member Scott Penner's Avatar
    Join Date
    Dec 2000
    Location
    Mountain View
    Posts
    327

    trying to do something different

    Well,
    I was passing a class into the form at startup, so I made a Display method to receive the class and show the form. It didn't work to call the SetWindowPos in this method, so I tried other things, albeit some squirrelly things.

    Anyway, to make a long story short, I simplified the way I displayed the form and everything works.

    Thanks for the help,
    -scott
    he he he

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