Bad Flicker, TransparencyKey and ControlPaint.DrawReversibleFrame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rainer Queck

    Bad Flicker, TransparencyKey and ControlPaint.DrawReversibleFrame

    Hello NG,

    I had/have a bad flicker Problem with my Application.
    On starting some applications, while my app was running, the whole Display
    started to flicker. Even the desktop Icons!

    Looking for help on this issue, I ran over a anser Linda Liu [MSFT] at :


    where I found the following (quick and dirty )solution to the flicker
    problem which as describe is a bug in WinForms:

    "In addition, The quick and dirty way to avoid most flicker is to use a
    transparency key. Pick a color that won't affect your program such as lime
    green, or some other ugly color that is not used by anything on your form"

    Adding the transparency key to my form solved the flicker problem. No more
    flicker at all, BUT:
    In my app I am using the ControlPaint.Dr awReversibleFra m(..) method to draw
    a "rubberband ".

    Now, with the transparency key set, the rubber band is no longer visible!

    What can I do to get my rubber band back without having to live with the
    flicker?

    Thanks for help and hints!

    Regards
    Rainer Queck


  • Zhi-Xin Ye [MSFT]

    #2
    RE: Bad Flicker, TransparencyKey and ControlPaint.Dr awReversibleFra me

    Hello Rainer,

    I can reproduce this problem. When specify a TransparencyKey for the form,
    the form become a layered window, it seems that
    ControlPaint.Dr awReversibleFra me() method draws figures beneath the layered
    window. Anyway, you can call the Rectangle() API to draw the rubber band on
    the form, and call ControlPaint.Dr awReversibleFra me() method to draw rubber
    band outside the form.

    For example:

    private void MyDrawReversibl eRectangle(Poin t p1, Point p2)
    {
    Rectangle rc = new Rectangle();

    GDI32 gdi = new GDI32();
    gdi.DrawRectang le(this.CreateG raphics(), p1, p2);


    // Convert the points to screen coordinates.
    p1 = PointToScreen(p 1);
    p2 = PointToScreen(p 2);
    // Normalize the rectangle.
    if (p1.X < p2.X)
    {
    rc.X = p1.X;
    rc.Width = p2.X - p1.X;
    }
    else
    {
    rc.X = p2.X;
    rc.Width = p1.X - p2.X;
    }
    if (p1.Y < p2.Y)
    {
    rc.Y = p1.Y;
    rc.Height = p2.Y - p1.Y;
    }
    else
    {
    rc.Y = p2.Y;
    rc.Height = p1.Y - p2.Y;
    }
    // Draw the reversible frame.
    ControlPaint.Dr awReversibleFra me(rc,
    Color.Black, FrameStyle.Thic k);
    }


    The GDI32 class:


    public enum RasterOps
    {
    R2_BLACK = 1,
    R2_NOTMERGEPEN,
    R2_MASKNOTPEN,
    R2_NOTCOPYPEN,
    R2_MASKPENNOT,
    R2_NOT,
    R2_XORPEN,
    R2_NOTMASKPEN,
    R2_MASKPEN,
    R2_NOTXORPEN,
    R2_NOP,
    R2_MERGENOTPEN,
    R2_COPYPEN,
    R2_MERGEPENNOT,
    R2_MERGEPEN,
    R2_WHITE,
    R2_LAST
    }

    public enum BrushStyles
    {
    BS_SOLID = 0,
    BS_NULL = 1,
    BS_HATCHED = 2,
    BS_PATTERN = 3,
    BS_INDEXED = 4,
    BS_DIBPATTERN = 5,
    BS_DIBPATTERNPT = 6,
    BS_PATTERN8X8 = 7,
    BS_MONOPATTERN = 9
    }


    public enum PenStyles
    {
    PS_SOLID = 0,
    PS_DASH = 1,
    PS_DOT = 2,
    PS_DASHDOT = 3,
    PS_DASHDOTDOT = 4
    }

    class GDI32
    {
    [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
    private static extern bool Rectangle(IntPt r hdc, int X1, int Y1,
    int X2, int Y2);
    [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
    private static extern IntPtr CreatePen(PenSt yles enPenStyle, int
    nWidth, int crColor);
    [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
    private static extern IntPtr CreateSolidBrus h(BrushStyles
    enBrushStyle, int crColor);
    [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
    private static extern bool DeleteObject(In tPtr hObject);
    [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
    private static extern IntPtr SelectObject(In tPtr hdc, IntPtr
    hObject);
    [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
    private static extern int SetROP2(IntPtr hdc, int enDrawMode);

    protected Color borderColor;
    protected Color fillColor;
    protected int lineWidth;
    protected IntPtr hdc, oldBrush, oldPen, gdiPen, gdiBrush;
    protected BrushStyles brushStyle;
    protected PenStyles penStyle;

    public GDI32()
    {
    borderColor = Color.Transpare nt;
    fillColor = Color.White;
    lineWidth = 1;
    brushStyle = BrushStyles.BS_ NULL;
    penStyle = PenStyles.PS_SO LID;
    }

    public Color BrushColor
    {
    get { return fillColor; }
    set { fillColor = value; }
    }

    public BrushStyles BrushStyle
    {
    get { return brushStyle; }
    set { brushStyle = value; }
    }

    public Color PenColor
    {
    get { return borderColor; }
    set { borderColor = value; }
    }

    public PenStyles PenStyle
    {
    get { return penStyle; }
    set { penStyle = value; }
    }

    public int PenWidth
    {
    get { return lineWidth; }
    set { lineWidth = value; }
    }

    protected int GetRGBFromColor (Color fromColor)
    {
    return fromColor.ToArg b() & 0xFFFFFF;
    }

    public void DrawRectangle(G raphics g, Point p1, Point p2)
    {
    InitPenAndBrush (g);
    Rectangle(hdc, p1.X, p1.Y, p2.X, p2.Y);
    Dispose(g);
    }

    protected void InitPenAndBrush (Graphics g)
    {
    hdc = g.GetHdc();
    gdiPen = CreatePen(penSt yle, lineWidth,
    GetRGBFromColor (PenColor));
    gdiBrush = CreateSolidBrus h(brushStyle,
    GetRGBFromColor (fillColor));
    if (PenColor == Color.Transpare nt) SetROP2(hdc,
    (int)RasterOps. R2_XORPEN);
    oldPen = SelectObject(hd c, gdiPen);
    oldBrush = SelectObject(hd c, gdiBrush);
    }

    protected void Dispose(Graphic s g)
    {
    SelectObject(hd c, oldBrush);
    SelectObject(hd c, oldPen);
    DeleteObject(gd iPen);
    DeleteObject(gd iBrush);
    g.ReleaseHdc(hd c);
    g.Dispose();
    }
    }

    If you have any questions or concerns, please don't hesitate to let me know.

    Sincerely,
    Zhi-Xin Ye
    Microsoft Managed Newsgroup Support Team

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subs...#notifications.

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at

    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.

    Comment

    • Rainer Queck

      #3
      Re: Bad Flicker, TransparencyKey and ControlPaint.Dr awReversibleFra me

      Hello Zhi-Xin Ye,

      thank you very much for your answer.
      I have tried your code, but it does not work in my application if a
      Transparency key is set.
      With no TransparancyKey it works, but here also the DrawReversibleF rame
      works.

      In addition I found an other issue caused by a set TransparencyKey :
      In my application I implemented the possibillity to save screenshots to a
      jpg file.
      Now with the TransparencyKey set I don't get a screenshot of my application,
      but of every thing what is behind it.
      My app - for the screenshot - is INVISIBLE!

      To generate a screenshot I use the following code:

      Bitmap bm = new Bitmap(this.Wid th, this.Height);
      using (Graphics g = Graphics.FromIm age(bm))
      {
      g.CopyFromScree n(new Point(this.Left , this.Top), new Point(0, 0), new
      Size(bm.Width, bm.Height));
      string savePath = Path.Combine(my Prg.screenShotP ath,
      String.Format(" CTS_{0}.jpg", DateTime.Now.To String
      ("yyyyMMdd_HHmm ss")));
      if (!Directory.Exi sts(myPrg.scree nShotPath))
      {
      Directory.Creat eDirectory(myPr g.screenShotPat h);
      }
      bm.Save(savePat h, ImageFormat.Jpe g);
      }

      There is one more thing I would like to mention.
      With my current application, which does a lot of grafically painting I
      invested a lot of energy to keep it "managed". I would therefore appreciate
      a "managed" solution to the problems.

      Regards
      Rainer Queck


      "Zhi-Xin Ye [MSFT]" <v-zhye@online.mic rosoft.comschri eb im Newsbeitrag
      news:cucHWvNRJH A.3440@TK2MSFTN GHUB02.phx.gbl. ..
      Hello Rainer,
      >
      I can reproduce this problem. When specify a TransparencyKey for the form,
      the form become a layered window, it seems that
      ControlPaint.Dr awReversibleFra me() method draws figures beneath the
      layered
      window. Anyway, you can call the Rectangle() API to draw the rubber band
      on
      the form, and call ControlPaint.Dr awReversibleFra me() method to draw
      rubber
      band outside the form.
      >
      For example:
      >
      private void MyDrawReversibl eRectangle(Poin t p1, Point p2)
      {
      Rectangle rc = new Rectangle();
      >
      GDI32 gdi = new GDI32();
      gdi.DrawRectang le(this.CreateG raphics(), p1, p2);
      >
      >
      // Convert the points to screen coordinates.
      p1 = PointToScreen(p 1);
      p2 = PointToScreen(p 2);
      // Normalize the rectangle.
      if (p1.X < p2.X)
      {
      rc.X = p1.X;
      rc.Width = p2.X - p1.X;
      }
      else
      {
      rc.X = p2.X;
      rc.Width = p1.X - p2.X;
      }
      if (p1.Y < p2.Y)
      {
      rc.Y = p1.Y;
      rc.Height = p2.Y - p1.Y;
      }
      else
      {
      rc.Y = p2.Y;
      rc.Height = p1.Y - p2.Y;
      }
      // Draw the reversible frame.
      ControlPaint.Dr awReversibleFra me(rc,
      Color.Black, FrameStyle.Thic k);
      }
      >
      >
      The GDI32 class:
      >
      >
      public enum RasterOps
      {
      R2_BLACK = 1,
      R2_NOTMERGEPEN,
      R2_MASKNOTPEN,
      R2_NOTCOPYPEN,
      R2_MASKPENNOT,
      R2_NOT,
      R2_XORPEN,
      R2_NOTMASKPEN,
      R2_MASKPEN,
      R2_NOTXORPEN,
      R2_NOP,
      R2_MERGENOTPEN,
      R2_COPYPEN,
      R2_MERGEPENNOT,
      R2_MERGEPEN,
      R2_WHITE,
      R2_LAST
      }
      >
      public enum BrushStyles
      {
      BS_SOLID = 0,
      BS_NULL = 1,
      BS_HATCHED = 2,
      BS_PATTERN = 3,
      BS_INDEXED = 4,
      BS_DIBPATTERN = 5,
      BS_DIBPATTERNPT = 6,
      BS_PATTERN8X8 = 7,
      BS_MONOPATTERN = 9
      }
      >
      >
      public enum PenStyles
      {
      PS_SOLID = 0,
      PS_DASH = 1,
      PS_DOT = 2,
      PS_DASHDOT = 3,
      PS_DASHDOTDOT = 4
      }
      >
      class GDI32
      {
      [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
      private static extern bool Rectangle(IntPt r hdc, int X1, int Y1,
      int X2, int Y2);
      [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
      private static extern IntPtr CreatePen(PenSt yles enPenStyle, int
      nWidth, int crColor);
      [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
      private static extern IntPtr CreateSolidBrus h(BrushStyles
      enBrushStyle, int crColor);
      [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
      private static extern bool DeleteObject(In tPtr hObject);
      [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
      private static extern IntPtr SelectObject(In tPtr hdc, IntPtr
      hObject);
      [System.Runtime. InteropServices .DllImportAttri bute("gdi32.dll ")]
      private static extern int SetROP2(IntPtr hdc, int enDrawMode);
      >
      protected Color borderColor;
      protected Color fillColor;
      protected int lineWidth;
      protected IntPtr hdc, oldBrush, oldPen, gdiPen, gdiBrush;
      protected BrushStyles brushStyle;
      protected PenStyles penStyle;
      >
      public GDI32()
      {
      borderColor = Color.Transpare nt;
      fillColor = Color.White;
      lineWidth = 1;
      brushStyle = BrushStyles.BS_ NULL;
      penStyle = PenStyles.PS_SO LID;
      }
      >
      public Color BrushColor
      {
      get { return fillColor; }
      set { fillColor = value; }
      }
      >
      public BrushStyles BrushStyle
      {
      get { return brushStyle; }
      set { brushStyle = value; }
      }
      >
      public Color PenColor
      {
      get { return borderColor; }
      set { borderColor = value; }
      }
      >
      public PenStyles PenStyle
      {
      get { return penStyle; }
      set { penStyle = value; }
      }
      >
      public int PenWidth
      {
      get { return lineWidth; }
      set { lineWidth = value; }
      }
      >
      protected int GetRGBFromColor (Color fromColor)
      {
      return fromColor.ToArg b() & 0xFFFFFF;
      }
      >
      public void DrawRectangle(G raphics g, Point p1, Point p2)
      {
      InitPenAndBrush (g);
      Rectangle(hdc, p1.X, p1.Y, p2.X, p2.Y);
      Dispose(g);
      }
      >
      protected void InitPenAndBrush (Graphics g)
      {
      hdc = g.GetHdc();
      gdiPen = CreatePen(penSt yle, lineWidth,
      GetRGBFromColor (PenColor));
      gdiBrush = CreateSolidBrus h(brushStyle,
      GetRGBFromColor (fillColor));
      if (PenColor == Color.Transpare nt) SetROP2(hdc,
      (int)RasterOps. R2_XORPEN);
      oldPen = SelectObject(hd c, gdiPen);
      oldBrush = SelectObject(hd c, gdiBrush);
      }
      >
      protected void Dispose(Graphic s g)
      {
      SelectObject(hd c, oldBrush);
      SelectObject(hd c, oldPen);
      DeleteObject(gd iPen);
      DeleteObject(gd iBrush);
      g.ReleaseHdc(hd c);
      g.Dispose();
      }
      }
      >
      If you have any questions or concerns, please don't hesitate to let me
      know.
      >
      Sincerely,
      Zhi-Xin Ye
      Microsoft Managed Newsgroup Support Team
      >
      Delighting our customers is our #1 priority. We welcome your comments and
      suggestions about how we can improve the support we provide to you. Please
      feel free to let my manager know what you think of the level of service
      provided. You can send feedback directly to my manager at:
      msdnmg@microsof t.com.
      >
      =============== =============== =============== =====
      Get notification to my posts through email? Please refer to
      http://msdn.microsoft.com/en-us/subs...#notifications.
      >
      Note: MSDN Managed Newsgroup support offering is for non-urgent issues
      where an initial response from the community or a Microsoft Support
      Engineer within 2 business day is acceptable. Please note that each follow
      up response may take approximately 2 business days as the support
      professional working with you may need further investigation to reach the
      most efficient resolution. The offering is not appropriate for situations
      that require urgent, real-time or phone-based interactions. Issues of this
      nature are best handled working with a dedicated Microsoft Support
      Engineer
      by contacting Microsoft Customer Support Services (CSS) at

      =============== =============== =============== =====
      This posting is provided "AS IS" with no warranties, and confers no
      rights.
      >

      Comment

      • Zhi-Xin Ye [MSFT]

        #4
        Re: Bad Flicker, TransparencyKey and ControlPaint.Dr awReversibleFra me

        Hello Rainer,

        Have you tried other ways to avoid the flicker? For example the
        DoubleBuffer property or WS_EX_COMPOSITE D style. You can check the
        discussion in this thread:

        Flicker-free painting


        If only the TransparancyKey trick can kill the flicker on your application,
        a managed way to draw the rubber band on the form is to handle the Paint
        event(or override the OnPaint method) of the form, and call the
        Graphics.DrawRe ctangle() method to draw the rubber band on the form.
        However, for drawing rubber band outside the form, you can still use the
        ControlPaint.Dr awReversibleFra me() method.

        === Code Sample For Your Information ====

        public partial class Form1 : Form
        {
        public Form1()
        {
        InitializeCompo nent();
        this.Transparen cyKey = Color.SaddleBro wn;

        this.Load += new EventHandler(Fo rm1_Load);
        }

        void Form1_Load(obje ct sender, EventArgs e)
        {
        MouseDown += new MouseEventHandl er(MyMouseDown) ;
        MouseUp += new MouseEventHandl er(MyMouseUp);
        MouseMove += new MouseEventHandl er(MyMouseMove) ;
        bHaveMouse = false;
        }

        protected override void OnPaint(PaintEv entArgs e)
        {
        if (bHaveMouse)
        {
        using (Pen p = new Pen(Color.Black ))
        {
        p.DashStyle = System.Drawing. Drawing2D.DashS tyle.Dash;
        //Use the DrawRectangle() method to draw a rubber band
        on the form.
        e.Graphics.Draw Rectangle(p,
        ptOriginal.X, ptOriginal.Y,
        ptLast.X - ptOriginal.X, ptLast.Y - ptOriginal.Y);
        }
        }
        base.OnPaint(e) ;
        }

        Boolean bHaveMouse;
        Point ptOriginal = new Point();
        Point ptLast = new Point();

        // Called when the left mouse button is pressed.
        public void MyMouseDown(Obj ect sender, MouseEventArgs e)
        {
        // Make a note that we "have the mouse".
        bHaveMouse = true;
        // Store the "starting point" for this rubber-band rectangle.
        ptOriginal.X = e.X;
        ptOriginal.Y = e.Y;
        // Special value lets us know that no previous
        // rectangle needs to be erased.
        ptLast.X = -1;
        ptLast.Y = -1;

        }
        // Convert and normalize the points and draw the reversible frame.
        private void MyDrawReversibl eRectangle(Poin t p1, Point p2)
        {
        Rectangle rc = new Rectangle();

        // Convert the points to screen coordinates.
        p1 = PointToScreen(p 1);
        p2 = PointToScreen(p 2);
        // Normalize the rectangle.
        if (p1.X < p2.X)
        {
        rc.X = p1.X;
        rc.Width = p2.X - p1.X;
        }
        else
        {
        rc.X = p2.X;
        rc.Width = p1.X - p2.X;
        }
        if (p1.Y < p2.Y)
        {
        rc.Y = p1.Y;
        rc.Height = p2.Y - p1.Y;
        }
        else
        {
        rc.Y = p2.Y;
        rc.Height = p1.Y - p2.Y;
        }
        // Draw the reversible frame.
        ControlPaint.Dr awReversibleFra me(rc,
        Color.Black, FrameStyle.Dash ed);
        }
        // Called when the left mouse button is released.
        public void MyMouseUp(Objec t sender, MouseEventArgs e)
        {
        // Set internal flag to know we no longer "have the mouse".
        bHaveMouse = false;
        // If we have drawn previously, draw again in that spot
        // to remove the lines.
        if (ptLast.X != -1)
        {
        Point ptCurrent = new Point(e.X, e.Y);
        MyDrawReversibl eRectangle(ptOr iginal, ptLast);
        }
        // Set flags to know that there is no "previous" line to
        reverse.
        ptLast.X = -1;
        ptLast.Y = -1;
        ptOriginal.X = -1;
        ptOriginal.Y = -1;

        this.Invalidate ();
        }
        // Called when the mouse is moved.
        public void MyMouseMove(Obj ect sender, MouseEventArgs e)
        {
        Point ptCurrent = new Point(e.X, e.Y);
        // If we "have the mouse", then we draw our lines.
        if (bHaveMouse)
        {
        // If we have drawn previously, draw again in
        // that spot to remove the lines.
        if (ptLast.X != -1)
        {
        MyDrawReversibl eRectangle(ptOr iginal, ptLast);
        }
        // Update last point.
        ptLast = ptCurrent;
        // Draw new lines.
        MyDrawReversibl eRectangle(ptOr iginal, ptCurrent);

        this.Invalidate ();
        }
        }
        }

        =============== ==============

        For generating screenshots, you can call the Form.DrawToBitm ap() method
        instead, for example:

        private void button1_Click(o bject sender, EventArgs e)
        {
        Bitmap bmp = new Bitmap(this.Wid th, this.Height);
        this.DrawToBitm ap(bmp, new Rectangle(0, 0, this.Width,
        this.Height));
        bmp.Save(@"c:\t est.png");
        }

        For more discussion on the TransparencyKey and generating screenshot, you
        can read this thread:

        copyFromScreen - no alpha window captured


        Please try my suggestions, and feel free to let me know if you have any
        questions or concerns.

        Have a great day!

        Sincerely,
        Zhi-Xin Ye
        Microsoft Managed Newsgroup Support Team

        Delighting our customers is our #1 priority. We welcome your comments and
        suggestions about how we can improve the support we provide to you. Please
        feel free to let my manager know what you think of the level of service
        provided. You can send feedback directly to my manager at:
        msdnmg@microsof t.com.

        This posting is provided "AS IS" with no warranties, and confers no rights.




        Comment

        • Rainer Queck

          #5
          Re: Bad Flicker, TransparencyKey and ControlPaint.Dr awReversibleFra me

          Hello Zhi-Xin,

          some how I can't achieve a satisfying solution to my problem.I tried "2." but it did not bring the hoped for result.

          On "1." I am not so sure, on how to apply the DoubleBuffering .
          Could you please explainme a bit more detailed - or give me a link to a
          detailed explaination - how to apply the double buffering?

          Also I think, it might be a good idea to reproduce the problem with a
          separate "simple" applicaton and then try the steps you described to solve
          it. Currently it is kind of hard to implement your suggestions into my quite
          complex application.

          Regards
          Rainer


          Comment

          • Zhi-Xin Ye [MSFT]

            #6
            Re: Bad Flicker, TransparencyKey and ControlPaint.Dr awReversibleFra me

            Hello Rainer,

            You can enable default double buffering in your forms and authored controls
            in two ways. You can either set the DoubleBuffered property to true, or you
            can call the SetStyle method to set the OptimizedDouble Buffer flag to true.
            Both methods will enable default double buffering for your form or control
            and provide flicker-free graphics rendering.
            For more information how to do this, you can refer to the following
            documents:

            How to: Reduce Graphics Flicker with Double Buffering for Forms and
            Controls


            Double Buffered Graphics


            If you have any questions or concerns, please don't hesitate to let me know.

            Sincerely,
            Zhi-Xin Ye
            Microsoft Managed Newsgroup Support Team

            Delighting our customers is our #1 priority. We welcome your comments and
            suggestions about how we can improve the support we provide to you. Please
            feel free to let my manager know what you think of the level of service
            provided. You can send feedback directly to my manager at:
            msdnmg@microsof t.com.

            This posting is provided "AS IS" with no warranties, and confers no rights.

            Comment

            • Rainer Queck

              #7
              Re: Bad Flicker, TransparencyKey and ControlPaint.Dr awReversibleFra me

              Hello Zhi-Xin,

              I now have managed to get the double bufferting to work and I found the
              cause of my "understand ing" problem.
              Actualy it was no understanding problem, but a "TabControl " problem. With
              the "TransparencyIs sues" project which I sent you by e-mail, I realized,
              that if "this.DoubleBuf fered = true;" was set, wihle the TabControl existed,
              the "Form1_Pain t" event handler wasn't called any more. As I removed the
              tabcontrol, Form1_Paint was called again.

              Actually, the bad flickering problem was not solved with double buffering.
              It only gets solved by setting the TransparencyKey to a Color (I sent you a
              email with a 2MB avi screen video showing the flicker problem).

              By the way, I managed to solve the problem the problem with the rubber band
              rectangle, by drawing it directly to the bitmap. Also I solved the
              screenshot problem but I had to use the following code, becaus I do not only
              need the Applications main form, but also secondary windows opend by the
              form at the screenshot moment:

              User32.keybd_ev ent(0x2c, 0, 0, IntPtr.Zero);
              Application.DoE vents();
              Image img = Clipboard.GetIm age();
              string savePath = Path.Combine(Pr gCutSyn.screenS hotPath,
              String.Format(" CTS_{0}.jpg",
              DateTime.Now.To String("yyyyMMd d_HHmmss")));
              img.Save(savePa th, ImageFormat.Jpe g);

              Now that I thought, I have most of my problems solved (except of the "timer
              not fired" issue) I tried my application on the target system, which is a
              quite low performance industrial PC (800 MHz, 256 MB Memory). My application
              now eats up all the CPU power and loads the target CPU with 100%, only
              caused by the TransparencyKey !! If I do not assign a TransparencyKey , the
              CPU load is at 37%.

              100% is absolutely not acceptable!

              So all in all I think, TransparencyKey and TabControl has MAJOR PROBLEMS!

              Is there any chance to get all this issues solved some how?

              Regards
              Rainer


              Comment

              • Zhi-Xin Ye [MSFT]

                #8
                Re: Bad Flicker, TransparencyKey and ControlPaint.Dr awReversibleFra me

                Hi Rainer,

                I'm glad to hear that the rubber band and screenshot problems are solved.

                For the "timer not fire" issue, you can try the SplitContainer control
                instead, I've included a sample code in my email to you, please check it
                and let me know the result.

                Best Regards,
                Zhi-Xin Ye
                Microsoft Managed Newsgroup Support Team

                Delighting our customers is our #1 priority. We welcome your comments and
                suggestions about how we can improve the support we provide to you. Please
                feel free to let my manager know what you think of the level of service
                provided. You can send feedback directly to my manager at:
                msdnmg@microsof t.com.

                This posting is provided "AS IS" with no warranties, and confers no rights.


                Comment

                • Rainer Queck

                  #9
                  Re: Bad Flicker, TransparencyKey and ControlPaint.Dr awReversibleFra me

                  Hello Zhi-Xin,

                  thank you very much for your help and your efforts.
                  I now have workarounds to all the issues in conjunction with the TabControl
                  and TransparencyKey and can run the application on my high performance
                  developement machine. But...
                  I can not deploy my application to the target system, because of CPU
                  consumption :-(
                  100% CPU load, only because the TransparencyKey must be set to avoid the
                  flicker is not acceptable!

                  What can I do about that now?
                  Is there any chance, that these bugs in the .NET Framework get solved soon?

                  Regards
                  Rainer


                  "Zhi-Xin Ye [MSFT]" <v-zhye@online.mic rosoft.comschri eb im Newsbeitrag
                  news:bOHpF7tSJH A.1668@TK2MSFTN GHUB02.phx.gbl. ..
                  Hi Rainer,
                  >
                  I'm glad to hear that the rubber band and screenshot problems are solved.
                  >
                  For the "timer not fire" issue, you can try the SplitContainer control
                  instead, I've included a sample code in my email to you, please check it
                  and let me know the result.
                  >
                  Best Regards,
                  Zhi-Xin Ye
                  Microsoft Managed Newsgroup Support Team
                  >
                  Delighting our customers is our #1 priority. We welcome your comments and
                  suggestions about how we can improve the support we provide to you. Please
                  feel free to let my manager know what you think of the level of service
                  provided. You can send feedback directly to my manager at:
                  msdnmg@microsof t.com.
                  >
                  This posting is provided "AS IS" with no warranties, and confers no
                  rights.
                  >
                  >

                  Comment

                  Working...