Modal or Modeless


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Modal or Modeless

  1. #1
    Gary Staunton Guest

    Modal or Modeless


    Is there an API that can determine how a form has been loaded?

    IE: Form1.Show vbModal

    On Form1 a Command button that would be clickable and tell you that the form
    was loaded Moadlly or Modeless?

    Gary

    Share on Google+

  2. #2
    Dan Appleman Guest

    Re: Modal or Modeless

    I don't know of any magical way to know that a form was created modally or
    modeless. However, it's easy enough to keep track of this in your own
    application. Just add a property to the form that you set before showing it to
    indicate what mode you used when you called the Show command.

    Dan


    Gary Staunton wrote:

    > Is there an API that can determine how a form has been loaded?
    >
    > IE: Form1.Show vbModal
    >
    > On Form1 a Command button that would be clickable and tell you that the form
    > was loaded Moadlly or Modeless?
    >
    > Gary


    Share on Google+

  3. #3
    Gary Staunton Guest

    Re: Modal or Modeless


    Thanks for the info Dan.

    I just thought that there would be a simple API call as Windows does know
    if the form is loaded either way.

    Gary


    Dan Appleman <dan@desaware.com> wrote:
    >I don't know of any magical way to know that a form was created modally

    or
    >modeless. However, it's easy enough to keep track of this in your own
    >application. Just add a property to the form that you set before showing

    it to
    >indicate what mode you used when you called the Show command.
    >
    >Dan
    >
    >
    >Gary Staunton wrote:
    >
    >> Is there an API that can determine how a form has been loaded?
    >>
    >> IE: Form1.Show vbModal
    >>
    >> On Form1 a Command button that would be clickable and tell you that the

    form
    >> was loaded Moadlly or Modeless?
    >>
    >> Gary

    >


    Share on Google+

  4. #4
    Dan Appleman Guest

    Re: Modal or Modeless

    You would think so, wouldn't you?

    Sometimes things don't make a whole lot of sense:-)

    Dan


    Gary Staunton wrote:

    > Thanks for the info Dan.
    >
    > I just thought that there would be a simple API call as Windows does know
    > if the form is loaded either way.
    >
    > Gary
    >
    > Dan Appleman <dan@desaware.com> wrote:
    > >I don't know of any magical way to know that a form was created modally

    > or
    > >modeless. However, it's easy enough to keep track of this in your own
    > >application. Just add a property to the form that you set before showing

    > it to
    > >indicate what mode you used when you called the Show command.
    > >
    > >Dan
    > >
    > >
    > >Gary Staunton wrote:
    > >
    > >> Is there an API that can determine how a form has been loaded?
    > >>
    > >> IE: Form1.Show vbModal
    > >>
    > >> On Form1 a Command button that would be clickable and tell you that the

    > form
    > >> was loaded Moadlly or Modeless?
    > >>
    > >> Gary

    > >


    Share on Google+

  5. #5
    Phil Weber Guest

    Re: Modal or Modeless

    > I just thought that there would be a simple API call as
    > Windows does know if the form is loaded either way.


    Gary: I don't think Windows does know. If you use Spy++ to examine the
    properties of a modal window, you'll find that there's nothing to
    distinguish it from a non-modal one. I'm pretty sure that when you show a
    form modally, Windows simply disables all other top-level windows in the
    application.

    An alternative solution, which avoids the need to explicitly set a property
    before showing the form, is to create a drop-in replacement for the .Show
    method (e.g., .ShowForm) and call it instead of the standard method:

    Public Sub ShowForm(Optional Modal As _
    FormShowConstants = vbModeless, _
    Optional OwnerForm As Object)

    ' Save modality in module-level variable
    m_bModal = CBool(Modal)
    ' Show the form
    If OwnerForm Is Nothing Then
    Me.Show Modal
    Else
    Me.Show Modal, OwnerForm
    End If

    End Sub

    ---
    Phil Weber


    Share on Google+

  6. #6
    Matthew Cromer Guest

    Re: Modal or Modeless


    "Phil Weber" <pweber@teleport.com> wrote:
    > > I just thought that there would be a simple API call as
    > > Windows does know if the form is loaded either way.

    >
    >Gary: I don't think Windows does know. If you use Spy++ to examine the
    >properties of a modal window, you'll find that there's nothing to
    >distinguish it from a non-modal one. I'm pretty sure that when you show

    a
    >form modally, Windows simply disables all other top-level windows in the
    >application.


    Windows must know, because when the form is unloaded the other windows become
    enabled again.

    Or else VB knows, and VB is the one showing the window modally by telling
    windows to disable the other forms in the App.

    Matthew Cromer

    Share on Google+

Similar Threads

  1. modeless to modal form
    By Shiva Prasad in forum VB Classic
    Replies: 0
    Last Post: 01-10-2002, 09:54 AM
  2. modeless to modal form
    By Shiva Prasad in forum VB Classic
    Replies: 0
    Last Post: 01-10-2002, 09:54 AM
  3. Modal / Modeless problem
    By Hans Larsen in forum Web
    Replies: 0
    Last Post: 03-16-2001, 01:31 PM
  4. SHBrowseForFolder - modal
    By LThib in forum VB Classic
    Replies: 0
    Last Post: 11-13-2000, 04:52 PM
  5. SHBrowseForFolder - modal
    By LThib in forum VB Classic
    Replies: 0
    Last Post: 11-13-2000, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center