October 2005 - Posts

I was having this problem in an application that I've been working on where I was drawing data points onto a PictureBox control - kind of like a canvas. The problem only showed up when a lot of data was thrown at the PictureBox: instead of seeing my data, I would see a loverly big red x.

So I did some chasing down a few rabbit holes (apparently this is a difficult issue to pinpoint - I found loads of unanswered forum/newsgroup posts about a red x) and found Bob Powell's GDI+ faq. Specifically, I found a good overview of How not to use the PictureBox control. After a few trials of throwing largish datasets at my picturebox canvas (that had yeilded those nasty red x's after a few screen refreshes just minutes before) it seems like the advice in that article just may have solved the problem.

We had been drawing to a Graphics object, then using that to spit out an image to the PictureBox's .Image property:

Graphics g = pbxCanvas.CreateGraphics();

//draw to graphics

pbxCanvas.Image = GetCanvasImage();

instead, now we create the Graphics object off of the .Image in the first place. It takes a little bit more setup, but I have yet to run into the red x again since implementing this code:

if(pbxCanvas.Image == null){
	pbxCanvas.Image = new Bitmap(pbxCanvas.Width, pbxCanvas.Height);

Graphics g = Graphics.FromImage(pbxCanvas.Image);

//draw to graphics

pbxCanvas.Image = GetCanvasImage();

Who would have thought that a call to Control.CreateGraphics would be so harmful?

I've been chasing down this odd Visual Studio bug where the Enter, Backspace, and Arrow keys stop working.

It happened to me in Redmond at Microsoft Campus (of all places!) and it's a known bug that a lot of others have run into apparently. Some folks have noted that it happens with the Beta 2 build, but the link above claims that it is gone from later builds. Sorry, wrong answer, kimo-sabe. Even on the RC build, this showed up.

It has to do with how Visual Studio handles USER SETTINGS. Thanks to a comment in ScottH's blog, I found a command line switch (devenv /resetuserdata) that brought up a user settings dialog asking me to set a profile when I started Visual Studio again. Instead of my usual C# profile, I decided to go with the General profile to mimic VS2003's settings. And whaddaya know? I can actually edit source files (for now). This does not bode well for Visual Studio as a development environment. Things should work by default, right? I can envision answering many questions about this in forums which I am subscribed to.

Goodbye, past coupla days. I'll miss ya.

Choice Quote:

 Now that I have actually used XSL in a project I've come to this conclusion: XSL is the Devil.

Go Check it Out. It's an interesting approach to wrapping [insert buzzword] functionality in an asp.net control. If you haven't read the first and second articles, you may want to read those first. The only drawback to this approach for me is the apparent lack of a commercial use license for the google maps api (somebody please prove me wrong on this).

[ Currently Playing : Drive Slow (Feat. Paul Wall & - Kanye West - Late Registration (4:32) ]

Just been shown something Microsoft are working on called "Spang" it's UNREAL.

When "Spang" comes out you'll all be so much happier, wish I could share but it's all NDA.


[Via Plip's Weblog]

What is Spang? It's going to revolutionize development as we know it. Keep a lookout for Spang.

More Posts