Bad Flicker, TransparencyKey and ControlPaint.DrawReversibleFrame

R

Rainer Queck

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 :
http://groups.google.de/group/micro...p/browse_thread/thread/39e9f7d0b96b048f?hl=de

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.DrawReversibleFram(..) 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
 
Z

Zhi-Xin Ye [MSFT]

Hello Rainer,

I can reproduce this problem. When specify a TransparencyKey for the form,
the form become a layered window, it seems that
ControlPaint.DrawReversibleFrame() 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.DrawReversibleFrame() method to draw rubber
band outside the form.

For example:

private void MyDrawReversibleRectangle(Point p1, Point p2)
{
Rectangle rc = new Rectangle();

GDI32 gdi = new GDI32();
gdi.DrawRectangle(this.CreateGraphics(), p1, p2);


// Convert the points to screen coordinates.
p1 = PointToScreen(p1);
p2 = PointToScreen(p2);
// 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.DrawReversibleFrame(rc,
Color.Black, FrameStyle.Thick);
}


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.DllImportAttribute("gdi32.dll")]
private static extern bool Rectangle(IntPtr hdc, int X1, int Y1,
int X2, int Y2);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr CreatePen(PenStyles enPenStyle, int
nWidth, int crColor);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr CreateSolidBrush(BrushStyles
enBrushStyle, int crColor);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool DeleteObject(IntPtr hObject);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr SelectObject(IntPtr hdc, IntPtr
hObject);
[System.Runtime.InteropServices.DllImportAttribute("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.Transparent;
fillColor = Color.White;
lineWidth = 1;
brushStyle = BrushStyles.BS_NULL;
penStyle = PenStyles.PS_SOLID;
}

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.ToArgb() & 0xFFFFFF;
}

public void DrawRectangle(Graphics 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(penStyle, lineWidth,
GetRGBFromColor(PenColor));
gdiBrush = CreateSolidBrush(brushStyle,
GetRGBFromColor(fillColor));
if (PenColor == Color.Transparent) SetROP2(hdc,
(int)RasterOps.R2_XORPEN);
oldPen = SelectObject(hdc, gdiPen);
oldBrush = SelectObject(hdc, gdiBrush);
}

protected void Dispose(Graphics g)
{
SelectObject(hdc, oldBrush);
SelectObject(hdc, oldPen);
DeleteObject(gdiPen);
DeleteObject(gdiBrush);
g.ReleaseHdc(hdc);
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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#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
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
R

Rainer Queck

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 DrawReversibleFrame
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.Width, this.Height);
using (Graphics g = Graphics.FromImage(bm))
{
g.CopyFromScreen(new Point(this.Left, this.Top), new Point(0, 0), new
Size(bm.Width, bm.Height));
string savePath = Path.Combine(myPrg.screenShotPath,
String.Format("CTS_{0}.jpg", DateTime.Now.ToString
("yyyyMMdd_HHmmss")));
if (!Directory.Exists(myPrg.screenShotPath))
{
Directory.CreateDirectory(myPrg.screenShotPath);
}
bm.Save(savePath, ImageFormat.Jpeg);
}

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 said:
Hello Rainer,

I can reproduce this problem. When specify a TransparencyKey for the form,
the form become a layered window, it seems that
ControlPaint.DrawReversibleFrame() 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.DrawReversibleFrame() method to draw
rubber
band outside the form.

For example:

private void MyDrawReversibleRectangle(Point p1, Point p2)
{
Rectangle rc = new Rectangle();

GDI32 gdi = new GDI32();
gdi.DrawRectangle(this.CreateGraphics(), p1, p2);


// Convert the points to screen coordinates.
p1 = PointToScreen(p1);
p2 = PointToScreen(p2);
// 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.DrawReversibleFrame(rc,
Color.Black, FrameStyle.Thick);
}


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.DllImportAttribute("gdi32.dll")]
private static extern bool Rectangle(IntPtr hdc, int X1, int Y1,
int X2, int Y2);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr CreatePen(PenStyles enPenStyle, int
nWidth, int crColor);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr CreateSolidBrush(BrushStyles
enBrushStyle, int crColor);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool DeleteObject(IntPtr hObject);
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr SelectObject(IntPtr hdc, IntPtr
hObject);
[System.Runtime.InteropServices.DllImportAttribute("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.Transparent;
fillColor = Color.White;
lineWidth = 1;
brushStyle = BrushStyles.BS_NULL;
penStyle = PenStyles.PS_SOLID;
}

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.ToArgb() & 0xFFFFFF;
}

public void DrawRectangle(Graphics 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(penStyle, lineWidth,
GetRGBFromColor(PenColor));
gdiBrush = CreateSolidBrush(brushStyle,
GetRGBFromColor(fillColor));
if (PenColor == Color.Transparent) SetROP2(hdc,
(int)RasterOps.R2_XORPEN);
oldPen = SelectObject(hdc, gdiPen);
oldBrush = SelectObject(hdc, gdiBrush);
}

protected void Dispose(Graphics g)
{
SelectObject(hdc, oldBrush);
SelectObject(hdc, oldPen);
DeleteObject(gdiPen);
DeleteObject(gdiBrush);
g.ReleaseHdc(hdc);
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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#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
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
 
Z

Zhi-Xin Ye [MSFT]

Hello Rainer,

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

Flicker-free painting
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=2044742&SiteID=1

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.DrawRectangle() method to draw the rubber band on the form.
However, for drawing rubber band outside the form, you can still use the
ControlPaint.DrawReversibleFrame() method.

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

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.TransparencyKey = Color.SaddleBrown;

this.Load += new EventHandler(Form1_Load);
}

void Form1_Load(object sender, EventArgs e)
{
MouseDown += new MouseEventHandler(MyMouseDown);
MouseUp += new MouseEventHandler(MyMouseUp);
MouseMove += new MouseEventHandler(MyMouseMove);
bHaveMouse = false;
}

protected override void OnPaint(PaintEventArgs e)
{
if (bHaveMouse)
{
using (Pen p = new Pen(Color.Black))
{
p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
//Use the DrawRectangle() method to draw a rubber band
on the form.
e.Graphics.DrawRectangle(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(Object 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 MyDrawReversibleRectangle(Point p1, Point p2)
{
Rectangle rc = new Rectangle();

// Convert the points to screen coordinates.
p1 = PointToScreen(p1);
p2 = PointToScreen(p2);
// 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.DrawReversibleFrame(rc,
Color.Black, FrameStyle.Dashed);
}
// Called when the left mouse button is released.
public void MyMouseUp(Object 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);
MyDrawReversibleRectangle(ptOriginal, 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(Object 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)
{
MyDrawReversibleRectangle(ptOriginal, ptLast);
}
// Update last point.
ptLast = ptCurrent;
// Draw new lines.
MyDrawReversibleRectangle(ptOriginal, ptCurrent);

this.Invalidate();
}
}
}

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

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

private void button1_Click(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, new Rectangle(0, 0, this.Width,
this.Height));
bmp.Save(@"c:\test.png");
}

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

copyFromScreen - no alpha window captured
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1589138&SiteID=1

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:
(e-mail address removed).

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

Rainer Queck

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
 
Z

Zhi-Xin Ye [MSFT]

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 OptimizedDoubleBuffer 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
http://msdn.microsoft.com/en-us/library/3t7htc9c(VS.80).aspx

Double Buffered Graphics
http://msdn.microsoft.com/en-us/library/b367a457(VS.80).aspx

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:
(e-mail address removed).

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

Rainer Queck

Hello Zhi-Xin,

I now have managed to get the double bufferting to work and I found the
cause of my "understanding" problem.
Actualy it was no understanding problem, but a "TabControl" problem. With
the "TransparencyIssues" project which I sent you by e-mail, I realized,
that if "this.DoubleBuffered = true;" was set, wihle the TabControl existed,
the "Form1_Paint" 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_event(0x2c, 0, 0, IntPtr.Zero);
Application.DoEvents();
Image img = Clipboard.GetImage();
string savePath = Path.Combine(PrgCutSyn.screenShotPath,
String.Format("CTS_{0}.jpg",
DateTime.Now.ToString("yyyyMMdd_HHmmss")));
img.Save(savePath, ImageFormat.Jpeg);

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
 
Z

Zhi-Xin Ye [MSFT]

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:
(e-mail address removed).

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

Rainer Queck

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
 
Z

Zhi-Xin Ye [MSFT]

Hello Rainer,

I check the code in the sample you sent to me, I notice that there're two
timers, tmrPaint and resizeTimer, what's the resizeTimer used for? And
does the tmrPaint timer need to tick for every 200 milliseconds? If you
increase the tick interval for the timer, for example, set Interval
property to 1000 or larger, the performance would increase a lot.

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:
(e-mail address removed).

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

Rainer Queck

Hello Zhi-Xin Ye,
I check the code in the sample you sent to me, I notice that there're two
timers, tmrPaint and resizeTimer, what's the resizeTimer used for?
In the sample, the resizeTimer has no function. I just added it, because I
first thought, it could be a a reason for the "Timer does not fire" issue.
In my actual application, the resize timer gets restarted on every resize
event and does a delayed recalculation of my bitmap. Due to the low
performance destination system, I don't want the bitmap to be recalculated,
over and over again, if the main window is resized. So if resizing is
done, - no more resize events - the timer fires and does a bitmap
recalculation once, then beeing disabled.
And does the tmrPaint timer need to tick for every 200 milliseconds?
If you increase the tick interval for the timer, for example, set Interval
property to 1000 or larger, the performance would increase a lot.
Yes the Paint timer is needed at 200 milliseconds MAXIMUM. The bitmap beging
painted represents a moving ribbon with some object on it. The ribbon must
be shown as a flowing ribbon.
I have in the meanwhile changed some other things in my project and thereby
achieved a load decrease down to 70-80 % CPU load, wich still is not in a
acceptable range because other applications on the target system must be
running too.

Do you know, when Microsoft is taking care of this bug ?
Or may be it has been solved already and there is a patch available?

Please refere to:
From :
http://groups.google.de/group/micro...p/browse_thread/thread/39e9f7d0b96b048f?hl=de
"-----
By : Linda Liu [MSFT]
The reason a form will sometimes flicker, often has to do with a bug in
WinForms and how it deals with transparent windows. WinForms is in fact
just a wrapper to the Windows API. When dealing with opacity, WinForms will
use a Windows API to convert your form to what is known as a layered window.
-----"

Regards
Rainer Queck
 
Z

Zhi-Xin Ye [MSFT]

Hello Rainer,

I'm not sure which bug Linda Liu refered to. I would suggest you post this
issue to our Connect feedback portal. Our developer will evaluate it
seriously and take them into sideration when designing furture release of
the product.

Here is the link for the Connect feedback portal:

http://connect.microsoft.com/VisualStudio/

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:
(e-mail address removed).

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

Rainer Queck

Hello Zhi-Xin,
I'm not sure which bug Linda Liu refered to. I would suggest you post
this
issue to our Connect feedback portal. Our developer will evaluate it
seriously and take them into sideration when designing furture release of
the product.
I will do that.

Thanks again for your help on this subject.

Regards
Rainer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top