help on refresh

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • c0elh0
    New Member
    • Oct 2008
    • 3

    help on refresh

    Hello all, I'm new to this forum and to c# too, so there are some technical questions I'm not familiar to in c#.

    I'm building a program based on a FORM controled by another pc (like a server) with several tabs. In each tab I have different panels in wich I wan't to display some images, button, etc.

    The problem is, when i run the project, the components I added aren't displayed.

    This is probably a refresh/paint problem because when I create a MessageBox after the adding of the components (the program obviously freezze) and I can see the components. After clicking ok (in the messageBox), components simply dissapear and all I can see is the background color I added.

    If someone as any tip or direction to follow, I would be very greatful.
    Thanks
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Originally posted by c0elh0
    Hello all, I'm new to this forum and to c# too, so there are some technical questions I'm not familiar to in c#.

    I'm building a program based on a FORM controled by another pc (like a server) with several tabs. In each tab I have different panels in wich I wan't to display some images, button, etc.

    The problem is, when i run the project, the components I added aren't displayed.

    This is probably a refresh/paint problem because when I create a MessageBox after the adding of the components (the program obviously freezze) and I can see the components. After clicking ok (in the messageBox), components simply dissapear and all I can see is the background color I added.

    If someone as any tip or direction to follow, I would be very greatful.
    Thanks
    Welcome... What we could really use to help you out is some code from your project. Most likely would be the section where you are adding the controls and displaying the form.

    I'm also a little fuzzy on the part where you say that a FORM is being controlled by another PC. Is this a System.Windows. Forms object? Is it like the default "Form1" that is created when you make a new Windows Form project in Visual Studio? Or do you mean some other kind of form, like its a program running on another computer that shows a fill-in-the-blank kind of form?

    If it is a Forms object, in your project - then how exactly are you controlling it from another PC? Does the other PC raise events that this application is subscribed to, then taking action on? Is it some TCP/IP communication passing instructions?

    If you are seeing your controls when you halt the UI for the MessageBox, is it possible you have a loop constantly updating your controls, so you keep painting over them with your background (however you are doing that?)

    Maybe placing some breakpoints at the start of each method involved and stepping through (F-10 / F-11) will show the program going in unintended or unexpected directions or loops.

    Regards,
    tlhIn'toQ

    Comment

    • c0elh0
      New Member
      • Oct 2008
      • 3

      #3
      Hi, first of all thanks for replying my post.

      I'm also a little fuzzy on the part where you say that a FORM is being controlled by another PC. Is this a System.Windows. Forms object? Is it like the default "Form1" that is created when you make a new Windows Form project in Visual Studio? Or do you mean some other kind of form, like its a program running on another computer that shows a fill-in-the-blank kind of form?
      That's exactly like the "Form1" with Visual Studio. In that Form1 project a server is created and is accessed (not controlled..ups ) by another pc, that client pc accesses the different tabs.

      Code:
      PhotoTab = System.Windows.Form.TabPage();
      panel1 = System.Windows.Form.Panel();
      ...
      //
      // PhotoTab
      //
      this.PhotoTab.BackColor = System.Drawing.Color.Black;
      this.PhotoTab.Controls.Add(this.webBrowserPhoto);
      this.PhotoTab.Controls.Add(this.panel1);
      this.PhotoTab.Location = new System.Drawing.Point(4, 22);
      this.PhotoTab.Name = "PhotoTab";
      this.PhotoTab.Padding = new System.Windows.Forms.Padding(3);
      this.PhotoTab.Size = new System.Drawing.Size(1432, 874);
      this.PhotoTab.TabIndex = 2;
      this.PhotoTab.Text = "Photo";
      //
      // panel1
      //
      this.panel1.Controls.Add(this.btnCapture);
      this.panel1.Controls.Add(this.pictureBox1);
      this.panel1.Controls.Add(this.PhotoBackground);
      this.panel1.Location = new System.Drawing.Point(323, 6);
      this.panel1.Name = "panel1";
      this.panel1.Size = new System.Drawing.Size(944, 750);
      this.panel1.TabIndex = 23;
      this.panel1.BringToFront();
      (Most of this code (if not all) was generated by VS...)

      If you are seeing your controls when you halt the UI for the MessageBox, is it possible you have a loop constantly updating your controls, so you keep painting over them with your background (however you are doing that?)
      Don't think so because I already removed the background color but components aren't displayed like before.

      I will try the breakpoints system but when exactly is the refresh/paint occur in the program sequence? Do they occur automatically? Or do I have to call them in certain situations?

      Best regards and thanks a lot
      c0elh0

      Comment

      • c0elh0
        New Member
        • Oct 2008
        • 3

        #4
        oh my god!!!

        I solved it... I just had to override the OnPaint() method and write
        base.Paint(e) .

        Thanks anyway for your time tlhintoq.

        c0elh0

        Comment

        Working...