CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2001
    Location
    Silicon Valley
    Posts
    113

    Exclamation problem with setting Top & Left of a form

    Colleagues,

    I’m doing some recreational programming. I'm trying to display a semi-transparent form (overlay) over a control. (The purpose of the overlay is to show that a control can be a target for drag & drop.) I’ve whipped-up a quick code to determine size and position of the overlay, and then display it. Here it is:

    Code:
            private void button1_Click(object sender, EventArgs e)
            {
                m_frmOverlay.Bounds = treeView1.RectangleToScreen(treeView1.ClientRectangle);
                m_frmOverlay.Show();
                m_frmOverlay.BringToFront();
            }
    In this code, new Bounds are set before Show(). Overlay form is displayed with default Top & Left (as set in the form designer), not the new Top & Left. Is it possible to set Top & Left before the form is shown ?
    If I change the code and set Bounds after Show(), overlay is displayed with correct top & left. Unfortunately, the overlay form still flickers for a moment at the default position. What would be a good way of getting rid of this flicker ?

    I'm using .NET 3.5 / VS 2008.

    Any suggestion, insight or reference is really appreciated!

    Cheers,
    - Nick
    Last edited by kender_a; January 23rd, 2011 at 04:21 PM.

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: problem with setting Top & Left of a form

    You need to set the StartPosition property to StartPosition.Manual before showing the form.

  3. #3
    Join Date
    May 2001
    Location
    Silicon Valley
    Posts
    113

    Resolved Re: problem with setting Top & Left of a form

    Quote Originally Posted by BigEd781 View Post
    You need to set the StartPosition property to StartPosition.Manual before showing the form.
    That solved my problem.
    Thank you, BigEd!

Tags for this Thread

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

Featured