Results 1 to 7 of 7

Thread: Loading forms...

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Spain
    Posts
    8
    I've made an app with lot of forms. When I go from one form to another. I make this:
    -------------
    Load Form1
    Form1.show vbmodal
    -------------
    Making this I go from form1 to form2.
    My problem is that in my app I should be able to go from any form to any other form. Then, it's possible that when I go from form1 to form2, form2 can be loaded and visible, yet. I have a run-time error:
    ----------------
    Run-time error: 400
    The form is already visible. It can't be loaded in modal way
    ---------------
    How can I validate if form2 is already loaded?. Which is teh best way to go from one form to other?.
    Any solutions will be gretaly apreciatted.

    Nauj

  2. #2
    Lively Member Ishamel's Avatar
    Join Date
    Nov 1999
    Location
    Edinburgh, Scotland
    Posts
    112
    Do you need to open each form as Modal??

    You would probably get away with implementing this code.

    Code:
    'Show the appropriate form
    Form2.Show
    
    'Hide the current form
    Me.Hide
    If the specified form isn't loaded when the Show method is invoked, Visual Basic automatically loads it.

  3. #3
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    If the forms don't truly need to be modal and you have a number of forms, you may want to consider using MDI and making each form a MDI child. Then you can have 1 menu and/or toolbar drive the rest of your app.
    Wade

  4. #4
    Member
    Join Date
    Jun 2002
    Location
    NY
    Posts
    60
    is there any way to make a MDI child form MODAL? or act like modal?

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    disable all other mdi childs
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    Two things that I have used.

    One is to have each form set a state, the value of the state is passed to a routine which handles showing the form. In this case, every line of the sort Form.show is in one single SUB, and therefore, the state of the form can be maintained. Each place where you have Form.show, you can replace it with a call to the routine that shows the form, and it can take appropriate action.

    A problem with showing a form from another form which can show the first form, etc. Is that each Form.show vbModal means that the current routine is halted while execution is transferred to the newly shown form. Each such action uses some stack space. If you can have form1 show Form2 modally, and form2 then show form 1 modally, you can exhaust the stack and crash the computer.

    Having a central dispatch for showing forms can remove that problem since each form can be hidden from a central location.

    A second thing I have done is to make an array of forms. Keep track of the last one shown, and show the next one next time. That doesn't seem to be what you are trying to do, but I could be wrong.

    A third idea is to maintain a global array for the state of the forms. This can be simply boolean. During the Load event for each form, set the array slot for that form to True. During the Unload Event, set the array slot to False. Then you can check the status of the form before showing it.

  7. #7
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    You could try to use SetTopWindow API call...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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