Results 1 to 2 of 2

Thread: Application modal form

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574

    Application modal form

    How can a form make itself application modal from within itself without having the caller to make is Modal. I mean if say frmBox has to be modal, I could say from within another form, say frmHouse the following code:

    Inside frmHouse

    frmBox.Show vbModal, Me

    or I could use the SetParent API and set the form as the top most using SetWindowPos with SWP_TOPMOST or whatever that constant is. Once again setting the form to be topmost only makes it topmost throught out the system meaning even if I minimized all the other forms of my application, this baby would remain on top and would not minimize.

    I want that frmHouse does not have to bother about showing this baby frmBox as modal. It just calls some method which takes care of displaying frmBox and making it modal, positioning and sizing it and initializing its variables and other stuff.

    To clear up the ambiguity, if you find some, in my question, my question is simply,

    "From within a form, how do I make the same form application modal?"

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I think you have misunderstood what a modal form means, it's not the same as making a form TopMost. When you show a modal form no code in other forms may run (except Timer event code and they will only run if you have compiled the project to a native exe). If a modal form is shown you can't minimize and other forms until the modal form has been unloaded. Furthermore if you load a modal form you can't load and show any other forms if they aren't loaded as modal as well.

    If you don't want your users to be able to minimize a form simply set the MinButton property to False. If you want to keep a form in memory don't unload it but rather hide it.

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