简体   繁体   中英

Progressbar showing red cross

I am using a custom ProgressBar-Control I found somewhere on the internet which enables me to control the color and all in all tweaks it a little bit. Now for the first time it is failing. The image below is what I see after setting the value often for some time. I am using it for a launcher which downloads alot of small files and I think updating the ProgressBar too fast may be the cause for this error.

Does anyone by any chance know, what exactly is happening? 图片

Greetings

// Edit: I found the solution: For some reason, the ARGB values were -2.147.483.648. This little code handles that case:

if (a > 255) { a = 255; } if (a < 0) { a = 0; }
if (r > 255) { r = 255; } if (r < 0) { r = 0; }
if (g > 255) { g = 255; } if (g < 0) { g = 0; }
if (b > 255) { b = 255; } if (b < 0) { b = 0; }

return (Color.FromArgb(a, r, g, b));

The code crashed in one of the paint-related methods, like customdraw or something similar.

Exceptions here are not reported as "Unhandled" since there is a try/catch block in effect that will swallow it, on the framework level, which then reverts to displaying the control with that big red cross afterwards.

This circumvents the normal "pop up on unhandled exception" functionality of Visual Studio, which is why it just crashes silently.

To catch this exception during debugging, open the Exceptions dialog from the Debug menu, and click the checkbox in the Thrown column for "Common Language Runtime Exceptions", this will make the debugger stop on that exception when it is thrown, not just when it isn't handled.

当发生GDI +错误时,将显示一个红叉。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM