Main from should redraw another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Spockman
    New Member
    • Mar 2008
    • 5

    Main from should redraw another

    Hi Guys!

    I stuck in this problem quiet awhile. I have a MainForm in my application. It contains a second one as a member. If both a visible I have a problem to redraw the second one.
    eg: MainForm and SecondForm is open and I move another window over the SecondForm. After that I click on the MainForm it will get the Focus and it will be redrawn. But the SecondForm stays behind.

    I tried the following:
    Using the OnActivation or OnEnter of my MainForm to redraw my Second doesn't work. (I got a appropriate result but my MainForm lost the focus and that should be the case)
    I tried to paint the SecondForm in OnPaint of MainForm but that doesn't work either.

    What is the right solution for this problem. Two Threads? an Mdi solution?

    greetings Stefan
  • maheshmrk22
    New Member
    • Dec 2007
    • 23

    #2
    Hi,

    As if you will be able to put some code then it will be easier to understand the fact. But as you mentioned above i think, MDI one will be better option and under that you would be able to set properties of child form.

    Thanks
    Mahesh






    Originally posted by Spockman
    Hi Guys!

    I stuck in this problem quiet awhile. I have a MainForm in my application. It contains a second one as a member. If both a visible I have a problem to redraw the second one.
    eg: MainForm and SecondForm is open and I move another window over the SecondForm. After that I click on the MainForm it will get the Focus and it will be redrawn. But the SecondForm stays behind.

    I tried the following:
    Using the OnActivation or OnEnter of my MainForm to redraw my Second doesn't work. (I got a appropriate result but my MainForm lost the focus and that should be the case)
    I tried to paint the SecondForm in OnPaint of MainForm but that doesn't work either.

    What is the right solution for this problem. Two Threads? an Mdi solution?

    greetings Stefan

    Comment

    • Spockman
      New Member
      • Mar 2008
      • 5

      #3
      Hi Mahesh!

      It's quite a simple problem. I want to create my own Media Player. And my MainForm is the Player itself and the Second form is my playlist.

      If I use the Mdi version should be the player the parent and the playlist the child or should I create a container mdi form for both?

      Posting the code needs a little bit of time because I have my stuff at home

      greetings
      Stefan

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        The forms (as well as all other controls) have an .Update() function that causes them to redraw themselves.
        Have you tried that?

        Comment

        • Spockman
          New Member
          • Mar 2008
          • 5

          #5
          Yes I tried that.

          Code:
          private void MainForm_Activated(object sender, System.EventArgs e)
          {
          playlist.Update();
          }
          but that won't work.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Well what do you mean by "won't work".
            Are you sure you are calling it at the correct times?

            Seems like you should be using the Enter event if you want it to fire everytime the form becomes selected?

            Comment

            • Spockman
              New Member
              • Mar 2008
              • 5

              #7
              So I implement the Mdi way, but there are some new problems now.

              Is it possible to to make the mdi form invisible and show only the child forms?

              And the second problem is that my Player form has a menu and it will appear in mdi form but it should stay at the child form

              It won't work was that if both forms are open and I move eg a editor window over the second form and I activate the main form the main form is fully visible but the second one is hidden behind the editor window

              regards Stefan

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                Ahh ok, so it's a focus issue.
                Yeah, the MDI way should work for you.

                Comment

                • Spockman
                  New Member
                  • Mar 2008
                  • 5

                  #9
                  I found the best and easiest solution for my problem!

                  I have to set the owner of second form and than all problems are fixed

                  But thanks for your help

                  greetings Stefan

                  Comment

                  Working...