none
Flickerting the MDI background Image

    Question

  • Hi,

    I have a MDI c#.net 2008 application.

    I used a bmp image as the back ground image for my MDI parent form, but when ever I navigate from text box to text box on the child form of this MDI parent form, the back ground image of the MDI form is flickering. and also, in the design time, the back ground image is not showing, it shows only the standard Dark gray color.

    Does anybody know, how I could avoid this?

    Thank you,
    Sunday, January 03, 2010 5:02 AM

Answers

  • maybe zip solution(exclude obj and bin folder), and put on free file hosting site.
    • Marked as answer by AbdullaNa Thursday, January 07, 2010 1:25 AM
    Wednesday, January 06, 2010 1:11 PM

All replies

  • Set Form.DoubleBuffered property to true.


    With best regards, Yasser Zamani
    Sunday, January 03, 2010 6:05 AM
  • Assalamu alaikum Yasser,

    Thank you for your answer, but sorry to say that, it is not working.

    I set the DoubleBuffered property of frmMDI to True but did not work, then i tried with both Parent and Child form with setting the same property, but still the problem exist.

    It happens, when ever a control is losing its focus from the child form (eg. moving focus from one textbox to another text box on the child form).

    At the time of Navigation on the child form, the MDI background Image is flickerting.

    Any Idea?

    Thank you,
    Abdulla.
    Sunday, January 03, 2010 8:58 AM
  • Hi,

    Could you create a reproduced sample project for us? I tested a project in terms of your description and the problem didn't happen here.

    Thanks
    Binze
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, January 05, 2010 8:50 AM
  • Hi,

    Please see the steps below to create the sample. (I created a sample, I did not see any option to attach the project in this forum - Sorry)

    1) Create a C# Windows Project, Form1 will be created by default.
    2) Add an MDIParent Form to the Project.
    3) Create a nice background in the power point (1024*768 resolution, Please use light colors like light green).
    4) Set MDI Parent BackgroundImage Property to this Image.
    5) Set MDI Parent BackgroundImageLayout to Stretch.
    6) Set WindowState Property of the MDI Parent Form to Maximized.
    7) Add a command button to the MDI Form to call the child form Form1.
    8) Add three textboxes to the form Form1.
    9) Write the following code in the click event of the command button in MDIParent Form .

          Form1 oForm1 = new Form1();
          oForm1.MdiParent = this;
          oForm1.Show();
    10) Run the application.
    11) Click on the Command button and the Child form should be appeared.
    12) Press TAB to navigate from textbox to textbox and observe the background image of the MDI.
    13) For the first navigation, You will see the page is flickering.

    Please note that, this problem exists only when you navigate for the first time. Afterwards it works fine.

    If you want to test this again, please stop the application and re-run and again try to navigate from textbox.

    Please let me know, incase of any clarification.
    Please also let me know, if there is a way to send the sample application across to you.

    Thank you,
    Abdulla.

    Tuesday, January 05, 2010 4:26 PM
  • Hi,

    Please see the steps below to create the sample. (I created a sample, I did not see any option to attach the project in this forum - Sorry)

    1) Create a C# Windows Project, Form1 will be created by default.
    2) Add an MDIParent Form to the Project.
    3) Create a nice background in the power point (1024*768 resolution, Please use light colors like light green).
    4) Set MDI Parent BackgroundImage Property to this Image.
    5) Set MDI Parent BackgroundImageLayout to Stretch.
    6) Set WindowState Property of the MDI Parent Form to Maximized.
    7) Add a command button to the MDI Form to call the child form Form1.
    8) Add three textboxes to the form Form1.
    9) Write the following code in the click event of the command button in MDIParent Form .

          Form1 oForm1 = new
     Form1();
          oForm1.MdiParent = this
    ;
          oForm1.Show();
    
    10) Run the application.
    11) Click on the Command button and the Child form should be appeared.
    12) Press TAB to navigate from textbox to textbox and observe the background image of the MDI.
    13) For the first navigation, You will see the page is flickering.

    Please note that, this problem exists only when you navigate for the first time. Afterwards it works fine.

    If you want to test this again, please stop the application and re-run and again try to navigate from textbox.

    Please let me know, incase of any clarification.
    Please also let me know, if there is a way to send the sample application across to you.

    Thank you,
    Abdulla.


    I followed the steps and found tabbing between text boxes working OK.
    Tuesday, January 05, 2010 4:40 PM
  • Hi,

    I have done the same already and also didn't find the problem.

    Thanks
    Binze
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, January 06, 2010 3:49 AM
  • Hi,

    Thank you for testing the project.

    But, still I am facing the same issue, Is there any way to send my sample project to you?

    Thank you,
    Abdulla.

    Wednesday, January 06, 2010 8:50 AM
  • Hi,

    Thank you for testing the project.

    But, still I am facing the same issue, Is there any way to send my sample project to you?

    Thank you,
    Abdulla.

    Wednesday, January 06, 2010 8:50 AM
  • maybe zip solution(exclude obj and bin folder), and put on free file hosting site.
    • Marked as answer by AbdullaNa Thursday, January 07, 2010 1:25 AM
    Wednesday, January 06, 2010 1:11 PM
  • Hi


    I have uploaded my project (without obj and bin folders) to a free file hosting website.

    Please find the link below. (after clicking the below link, just click on 'Click here to Start download..' link.

    http://www.mediafire.com/?yvzzmt2onnm


    Please let me know, if you find this project works fine.

    Thank you,
    Abdulla.
    Thursday, January 07, 2010 1:24 AM
  • Hi. I had similar problems writing an MDI application recently. I solved them by using the Paint event of the MdiClient object on the MDI Parent window. The MdiClient is created at runtime, so you need to attach the event during form load:

            public MainWindow()
            {
                foreach (Control ctl in this.Controls)
                {
                    if (ctl is MdiClient)
                    {
                        // Need to set the back colour by hand
                        ctl.BackColor = this.BackColor;
                        // Need to draw the logo in a Paint event, so it's behind the MDI Forms
                        ctl.Paint += new PaintEventHandler(MDIClient_Paint);
                    }
                }
            }
    
    
            private void MDIClient_Paint(object sender, PaintEventArgs e)
            {
                MdiClient o = (MdiClient)sender;
                int xoffset = (o.Width - picLogo.Image.Width) / 2;
                int yoffset = (o.Height - picLogo.Image.Height) / 2;
    
                e.Graphics.DrawImage(picLogo.Image, xoffset, yoffset);
            }
    picLogo is a PictureBox control placed on the form for convenience, with its Visible property set to false.

    Hope that helps.
    Thursday, January 07, 2010 2:31 PM
  • Hi Jim, Sorry for the late reply. Can you show me, How can I implement your code snippet in my project? I have provided a link in the previous reply where you can download my sample project(in zip format). Thank you, Abdulla.
    Thursday, January 14, 2010 4:28 AM
  • I'm not able to download and test your sample at the moment as I'm at work, but you should be able to modify your code easiliy:

    1) Add a PictureBox control to your MDI parent form. Set Visible = False and load your background image into it.

    2) Place the foreach code into the constructor for your form. (my form is called MainWindow).

    3) Add the MDIClient_Paint method to your form.

    That should get things working. Give it a try and let me know how you get on.

     

    Thursday, January 14, 2010 10:13 AM
  • Hi,

    Thank you for your response.

    I did the same, as what did you mention in your previous mail.

    But, still the issue exists. The MDI back ground image is flickering.

    I found one more issue, with the picture box on the MDI form. I have some command buttons on the MDI Form, picture box, hides these command buttons or sometimes aligment will go off becuase of the Picture box on the MDI form.

    Thank you,
    Abdulla.
    Thursday, January 14, 2010 3:58 PM