Windows Forms

There are a few things that have to happen for this "regression" to show up. First, you have to be working in .net 2.0 WinForms. Second, you must be using a custom application context. Third and most importantly, you must have at least one form open in your application that handles its closing event and sets CancelEventArgs.Cancel = true. What's the behavior? While operating under a custom ApplicationContext, what would be my Main form is closed by the user. Since the application context is not associated with that form, I decide to call "Application.Exit()" in an override of OnClosing. My...

If you do anything "out of the ordinary" in your UserControl or Form derived classes in Visual Studio 2005, let me introduce you to a little snippet that will probably save you lots of headaches:if ( DesignMode ) return; or, its equally useful counterpartif(!DesignMode){ doStuff(); } Now, the "out of the ordinary" thing I was doing was...hooking up an instance EventHandler using a static property that exposes a Form derived class in an OnLoad override. What? I know, not the clearest situation, and probably one that could use a boatload of refactoring, but it works. In short, if you are having designer problems in...

I've updated the NetVibe source with a mildly useful update: listening for changes in SSID as well as IP Addresses. The source is hosted at http://chrisfrazier.net:8080/NetVibe on a subversion server. I used some code that I found at the FurryGoat experience, modified it a little bit, and it seems that it's at least useful in detecting if an SSID ends with something...for example, my WiFi at work has an SSID of VelocityDatabank, so I created a rule to look for an SSID/IP Address that EndsWith Databank. This code definitely needs improvement, but I have found it very useful, and now I don't...

This looks interesting. I thought Mr. "Just finished my last chapter of Beginning AJAX" would have for sure created this as an asp.net control...guess I should have read closer the first time ;) Could be useful in PostXING, ifn we ever put some real security innit. Since there has been so much interest in the SecurePasswordTextBox control (see my previous post http://weblogs.asp.net/pglavich/archive/2006/02/26/439077.aspx and http://weblogs.asp.net/pglavich/archive/2006/03/12/440052.aspx ), I thought I would take the time to iron out the bugs. When I first released it, I performed minimal testing (i.e. about 15 minutes worth) and just...

Sorry I keep putting out these tests, but I'm trying to see what different regexes will do to a friendly url in subtext. Nothing more to see here. [ Currently Playing : Have You Heard? - ZZ Top - Tres Hombres (3:12) ]

I've got weak regex skillz. I'll admit it. I don't use them very much, so when I do need to, it's nice to know that regexlib is sitting there, waiting for me to come to it with my regex needs. In particular, there is an online Regular Expression Tester that has helped me to look smarter than I actually am on more than one occasion. Sure, I could use a desktop tool for my regex needs (and sometimes I do), but regexlib has the added bonus of having a collection of user-contributed regular expressions that are super useful when looking for ideas...

I can't believe nobody called me on this: BackgroundWorker.IsBusy Property Reflector says it does exactly what I was looking for in a previous post. Technorati Tags:  Windows Forms  BackgroundWorker 

Here's a link to the hotfix for the winforms designer error that looks like this: One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. TypeLoad failure. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at System.Reflection.Assembly.GetTypes() at Microsoft.VisualStudio.Shell.Design.AssemblyObsoleteEventArgs..ctor(Assembly assembly) at Microsoft.VisualStudio.Design.VSDynamicTypeService.ReloadAssemblyIfChanged(String codeBase) at Microsoft.VisualStudio.Design.VSDynamicTypeService.CreateDynamicAssembly(String ...

This is a private boolean member of the new BackgroundWorker class in .NET 2.0. If it were public, perhaps there would be less questions like this one on the gotdotnet messageboards. I ran into a similar problem recently and decided that instead of catching an exception when the BackgroundWorker is running, I would emulate the isRunning member myself. Since this is multithreaded by its nature, I decided to use a lock object to control access to a static boolean member in the class that uses the BackgroundWorker component.static bool isRunningBgWorker = false; static object lockObj = new object(); ... if (!isRunningBgWorker) { this.backgroundWorker1.RunWorkerAsync(); } I check to...

A few people asked for the source code/a download for the little widget I whipped up on Friday, so I spent this morning adding a little bit of persistence. The original code for switching my networks is still in there (and still works on my machine if I change the code to point there) but I made it more general and also used it as an excuse to explore the Settings API as well as use a couple of neat features of VS 2005. (If you don't care about any of that stuff and just want to see if you...

This is pretty cool:System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += new System.Net.NetworkInformation.NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged); I have a laptop that everyday switches between my wireless home network and my wired work domain. I was looking for a way to add scripting abilities to the interface itself (i.e. when a network connects, run some script) when I stumbled upon this jem. So, I now have a little winforms app that sits in my tray (yet another one) and doesn't do anything but run a script (that in turn modifies my hosts file) and change its tray icon when I'm connected to different networks. Here's what connected at home looks like:  It began as...

*sigh* Winforms team, winforms team, when will you start making my life easier? As others have said (and I completely agree ) windowsforms.net is pretty useless. Well, there's some new Whidbey .NET 2.0 content, but all of the things I enjoyed when starting w/ v1 of .NET (like, erm, QuickStarts? What happened to installing those locally?) seem to be gone. To be fair, they do have a presence over on forums.microsoft.com where there are a few PM's and devs answering questions. I even found a hack fix for my dilemma via one of the posts that links to a download from Beta 2 or somewhere...

-> Wow. I played with ClickOnce deployment for a little while earlier. After getting a couple of files/dependencies worked out, I had a fully installable ClickOnce application. It didn't let me specify where I wanted to install it, but I guess that's part of the deal for auto-updates etc. I'm going to have to investigate this further...I knew ClickOnce was supposed to be cool, but easy too? Get outta here. [ Currently Playing : Come Back - Foo Fighters - One by One (7:49) ]

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...

Anybody else find that MS has so much crap going on that it's hard keep tabs on a single, solid, resources to use to keep up to speed on things? (And don't even send me to msdn.microsoft.com - that thing is 1) schizophrenic (is it a developer resource, or a place to buy subscriptions and stuff?) and 2) complete sensory overload. ) [Via AngryPets.com :: Blog] It is pretty worthless unless you are looking for controls - even then, the contol gallery has broken images and dead links everywhere. I've found that unlike...

This has probably been done a hundred times already, but I couldn't find one in the first few pages of google results, so I wrote my own in ~40 lines of C#:using System;using System.ComponentModel;using System.Drawing;using System.Drawing.Drawing2D;using System.Windows.Forms;namespace PostXING.Controls{ /// <summary> /// GradientPanel is just like a regular panel except it optionally /// shows a gradient. /// </summary> [ToolboxBitmap(typeof(Panel))] public class GradientPanel : Panel { /// <summary> /// Property GradientColor (Color) /// </summary> private Color _gradientColor; public Color GradientColor { get { return this._gradientColor;} set { this._gradientColor = value;} } /// <summary> /// Property Rotation (float) /// </summary> private float _rotation; public float Rotation { get { return this._rotation;} set { this._rotation = value;} } protected override void OnPaint(PaintEventArgs e) { ...

I couldn't find a cut & dry solution to this (probably b/c it's too simple for anyone to think they would need an example) so here's how I got an xml file embedded as a resource in a vs2003 project written to the filesystem. First, you just add an xml file with some default information you want for it to your project and change its build action to Embedded Resource. Then, you find the name of the resource (it can be tricky if you have a few folders) by opening up ildasm and double clicking the MANIFEST node. Using that resource...

Royo asks: I'm interested to know whether you found my Extensibility application block useful, or if you had to make many changes to it to make it workable. The short answer to this question is: yes and that depends on your definition of 'many'. The EAP was useful to me: without the ideas and articles supporting it, it would have taken me at least twice as long to implement a spell checking plugin for PostXING. That said, there were some hurdles I had to overcome in order to get it working consistently for me. First, let me say that I...

When I was working on the latest release of the BlogThisUsingPostXINGPlugin, I kept running into file access issues. The whole thing was an excersize in refactoring - well, really, the whole thing WAS a refactor, since the basic functionality already existed, but I was making additions in how things were going to work. First, I changed the XsltStream to return a FileStream or a ManifestResourceStream, based on the existence of a user-specific file: 1 Stream XsltStream 2 { 3 get 4 { 5 string filePath = Path.Combine(ConfigurationPath, this.BlogType.ToString() + ".xslt"); 6 if(File.Exists(filePath)){ 7 //read from...

I was doing my early morning googling and came across this - a set of free icons in the WinXP custom format. Really nice if you want to add that touch of candy to your apps, be they windows or webforms. There are also a set of spheres there that have a slew of different colors...That along with the FireFox extension downTHEMall made for a great 5 minutes of getting some nice starter icon sets.

I don't know whom this would benefit but someone building a blog posting tool for the desktop, but anyway here's the code that I converted from the jscript example that comes with the Windows Media Player blogging powertoy:using System; using Microsoft.Win32; public class MediaPlayerInfo { public static string GetCurrentlyPlayingMedia(){ RegistryKey regKey = Registry.CurrentUser; regKey = regKey.OpenSubKey("Software\\Microsoft\\MediaPlayer\\CurrentMetadata"); string displayString = "<div class='media'>[ Currently Listening to: "; bool hasMetadata = false; string trackInfo = ""; try{ trackInfo = regKey.GetValue("Title").ToString(); if(trackInfo.Length != 0){ hasMetadata = true; displayString += trackInfo + " "; } }catch{ try{ trackInfo = ""; trackInfo = regKey.GetValue("Name").ToString(); if(trackInfo.Length != 0){ hasMetadata = true; displayString += trackInfo + " "; } }catch{} } try{ trackInfo = ""; trackInfo = regKey.GetValue("DurationString").ToString(); if(trackInfo.Length != 0){ hasMetadata = true; displayString += "(" + trackInfo...

I've been doing a lot of that lately (embracing and extending). So I'm reading thru Mike's latest article, thinking how can I apply this to an application I'm currently developing? In the article, he mentions that Office 2003 uses both a deductive and inductive UI for various parts of the interface (see his article for a much better explanation than I could give you.) So I tried it out. I downloaded the code and applied something very similar to the Office example shown in the article using Tim Dawson's awesome Sandbar library. There was a problem, though. By virtue of a vertical scrollbar, enabled, disabled, visible,...

Okay, not everything, but at least www.weblogs.com and blo.gs. I already had some of the code in place, but then I came across an example by Charles Cook, mr. xml-rpc.net hisself, and decided to hack it a little bit. Pretty simple stuff, but this post will tell me if it works :) /me:crosses fingers update: So it looks like it "kinda" worked for weblogs.com - since my blog engine, .Text pings weblogs.com itself, I got a nice little message from weblogs.com saying I should get out more and enjoy life for pinging twice in a row. Well, my friends, it's raining today. blo.gs came back...

I've needed this link ( http://www.nikhilk.net/Entry.aspx?id=11 ) a few times, so I thought I'd give it a little google juice so I could find it easier next time. The link is to a widget written by Nikhil Kothari, I'm using it in one of my apps currently, and it's really great. Included with a little agility ( .NET Html Agility Pack: How to use malformed HTML just like it was well-formed XML... ), this is a tight little package for editing html in Windows Forms.

I had some very humble console app beginnings in C++. Ya know, "cash register" dos-like programs, completely keyboard driven. However, my beginnings had nothing to do with converting strings to and from floats. I spent a better part of today wondering why atof would not return anything but a 0.000000 from a floating-point string. My platform is Windows XP - is it clear yet? If nothing else than for my own personal reference, in MFC it could possibly be better to use _wtof(). Goodbye first half of Friday.

So I wanted to allow for this, right? What if I find something on the net that just begs me to post it, and I want to use the url as the source for my post? Well, it's insanely easy...but you still have to wire it up a little bit. From the article I found (using google, of course), I changed the source code to this:1 private void txtUrl_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { 2 if(e.Data.GetDataPresent(DataFormats.Text)){ 3 e.Effect = DragDropEffects.All; 4 } 5 } 6 7 private void txtUrl_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { 8 this.txtUrl.Text = e.Data.GetData(DataFormats.Text).ToString(); 9 } where txtUrl is the url I want to use as a source for my post. Set AllowDrop = true...

Julien Ellie, you rock. In response to all the WinForms hubub yesterday, I asked for a higher limit on the file selection dialog (you can only select about 200 ATM). Julien said in my comments: Well, I see that a KB article (820631) says this behavior is by design so I don't know how much freedom we have here. You'll understand that I can't promise anything, I am just a dev, but I'll make sure to look into it and ask questions about this. Thanks! That is so slick. Julien, you may be just...

Like to hear my feedback? I'd like a file dialog that lets me select more than 200 files at a time. With the people and companies I work with, it is a necessity. We deal with lots of files. Thanks!

BTW, this is yet another code-when-I-have-a-free-time program

I finally decided on a name for my project - PostModern. I had already gotten syntax highlighting worked out, but I ended up using a different component than I had originally planned. I'm using a component from SquishyWare called squishySyntaxHighlighter. It's really nice...simple, easy to modify, and it looks pretty spiffy too. So here's the thing. It creates a little bit of markup by using [span style=] tags where you would expect coloration, so if you're posting any sizeable amount of code, it can get bloated. (That's why I put the second part of the title in there, you nasty nelly you!) I've...

Scott Mitchell told me: Feature request: you will be my hero if your blog software can display code snippets in a color coding like in VS.NET. And if it's a snap to add such code and have it formatted. (That is, I don't have to do more than just add, [code language="C#"] ... code ... [/code].) Thanks to Thomas Johansen's  AylarSolutions.Highlight, you're gonna get exactly that! This was one of the requests that more than one person told me would be nice, so I decided to go ahead and add syntax highlighting to the app b/c yeah it would be nice. Tom's...

In my comments here, Michael Slater says I should try out zempt for my blog-editing pleasure...well, I went to the site and thanks for the suggestion, Mikey, but I think that zempt only targets MT, which this blog is not (thank you Jesus...and ScottW:) So, I've been thinking of what I should name my little side project, and I thought you could help me. I've asked this same question elsewhere, and here's a little list of what has been suggested so far: BlogPost BlogPoster Blogster Hi-Lited-Blog-Poster Poster Face (like poker face:) POSTERIOR Sharlene Sally PostThoughts PostBloggem POST-it (can I get sued for that?) POST-Code POSTAL (as in I'm going) I was thinking something that included a play...

Thanks to comments from my previous post, I did snag a copy of Blogert. Just like I thought, it's almost everything that I wanted, but I want a couple of more features -  like the ability to post to many blogs at once (this is my main want) and it seems from initial reaction that it would be cool to be able to post snippets of code into the entry that you're writing. So I've got the behaviors that I want, but spread across two different apps. Looks like I've found myself a pet project.

...way to post to my weblogs. Maybe you can help me out. Objective: Create a desktop application that will enable posting entries to a weblog. Technology: Windows Forms, C# Needs: A simple, familiar, WYSIWYG interface for creating content. Use the MetaBlog API for posting and retrieving content. Ability to post to many blogs at once. Ability to save posts locally at the user's discretion and/or in a disconnected scenario. Wants: That's where you come in! I've seen the images of Blogert, but I can't find where to download it. It looks like it does almost everything that I need it to do, and it would be real nice...

The place that I work uses what we call index numbers (they're not really numbers per se...) that are based on API numbers (which are usually numbers) for check shot velocity surveys. I'm working on a project that will validate these and I thought that it would be well suited for Regex since it's going to be text validation and there are rules in place for these Index “numbers”. So first I go to www.regexlib.com and see what that might have to get those Regex juices flowin. Then I thought about the Regex that I need to write and wrote...

Working with windows forms sucks. Especially if you're coming from the much more approachable asp.net side. I have state, but simple things like pre-selecting an item in a datagrid are not easy - and they should be. You should make me feel comfortable in your environment. Give me a reason to use Windows Forms other than 'it runs on Windows'. I'm about halfway thru my first Windows Forms project. If I were doing this in asp.net, I would be done by now. That is all.

For anyone else who might have run into Intellisense weirdness, I found that just 'touching' the file that was generated by vs.net for the dataset and recompiling gave intellisense its needed kick in the rear. All I did was go to the file, hit enter, hit backspace, shift+ctrl+b, and intellisense was ready again to do my bidding. Weird, but it worked for me

So I'm doing some work with typed datasets right now that is really souring my experience with VS.NET 2003. I'm using the same technique that I used months ago with VS.NET 2002 that worked pretty smoothly - wait, first let me say that it is working, it's the Intellisense that's jacked up. Unfortunately, it looks like it doesn't pick up everything that is included within the generated DataSet, including the public DataTable and DataRow classes generated. So, the code compiles and works fine during runtime, but intellisense is shot down at the first level. Is this what it was like before...

Looks like Marc is having trouble with sealed ImageLists. I've been working on my first Windows Forms project and I'm using the same ImageList throughout the application, even tho there are yet only a few forms in it. I adapted an example by Lutz Roeder that uses a static class (well, ya know static members, whatever) to load a bitmapstrip into an internal ImageList. The class has a bunch of static properties that return the correct index of the image based on the loaded ImageList. (Like Images.Forward or Images.Undo) I also added a static property to return the internal ImageList incase I...

I want to say thanks to those who have given me feedback on a previous post. It's given me a little bit more insight into this beast called SqlServer. Anyways, I think perhaps I should ask this particular question on a listeserv of some sort, or maybe stick with just dynamically creating the sql text - given the fact that this particular endeavor is a windows forms project that shouldn't go outside of my company...