Results 1 to 3 of 3

Thread: How do I keep a form in front and centered?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    West Monroe, Louisiana
    Posts
    33
    I'm new to VB, and I am stumped on this class assignment! Please help me!

    I am attempting to add a “Tip of the day” to a small text editor. My problem involves two forms: “frmMDI” and “frmTip.” What I want is for “frmMDI” to load and “frmTip” to THEN load in the FRONT of and in the CENTER of “frmMDI.”

    I first placed “frmTip.Show” as the last line in “Private Sub frmMDI_Load().” Both forms loaded, but “frmTip” loaded BEHIND “frmMDI” and could not be seen.

    I then changed “frmTip.Show” to “frmTip.Show vbmodal.” “frmTip” then loaded first and “frmMDI” waited until “frmTip” was closed before it finished loading.

    I then changed “frmTip.Show vbModal” back to “frmTip.Show” And made “frmTip” a MDI Child. “FrmMDI” now loads first and “frmTip” loads in the center as I want it to, but it quickly “snaps” to the upper left corner of “frmMDI.”

    QUESTION: How can I get “frmTip” to load and STAY in the front and center of “frmMDI?”

    Please Help!

    Wendy

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    You ALMOST got it right when you did this:

    frmTip.Show vbModal

    The problem is, the form frmMDI isn't shown yet (because the Load event isn't complete).
    So you have to show it manually:

    Show
    frmTip.Show vbModal


    Also, on frmTip set the StartUpPosition property to 1 - CenterOwner for it to show up in the middle.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    West Monroe, Louisiana
    Posts
    33
    Excellent!

    Thanks, Yonatan! It works perfect. I guess I learned a lot trying to figure this out for myself, but you sure made it easy and I won't forget how it's done. I owe you one.

    Thanks again!

    Wendy

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