Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Wednesday, July 9, 2008

MarqueeAnimationSpeed

I was having issues with a progress bar that was set to Marquee style. It was moving at a pretty good rate, and setting the MarqueeAnimationSpeed value seemed to have no effect. Turns out that you need to specify the speed before you set the ProgressBar to Marquee. In my case, the working code looks like this:


encodeProgress->MarqueeAnimationSpeed = 35;
encodeProgress->Style = ProgressBarStyle::Marquee;


I imagine that's the exact problem that this person had. It's a shame Microsoft didn't figure out what the person had done.

Friday, June 13, 2008

Visual Studio - Icons

There are a few things involved in adding icons to a Visual Studio project. Where applicable, this guide will reference GIMPshop, but the procedure should be very similar in Photoshop or GIMP (I don't know for sure, as I haven't recently used either one).

First, make your icon in a larger resolution. 255x255 works well, since that's the largest size that the end result can be (Vista allows 255x255/256x256 icons if you have "large icons" enabled). After you have it as you want it, save it as a PNG, then scale it down to 3 different resolutions: 48x48, 32x32, and 16x16. All of these should be scaled down from the original 255x255, as that will provide the best-looking icons. After scaling, some manual pixel manipulation might be needed in order to produce the best-looking results, depending on the nature of the icon.

After you have all 4 image files, open up the 255x255 file, then "Open as Layer" the same file twice more. Then "Open as Layer" each of the other three files three times each. Save the whole thing as an Microsoft Windows Icon file (.ico). A window will come up with each of the layers in it, and next to each layer is a dropdown box. The box lets you select the color bitrate for each layer. For each image size, you want one layer to be 32-bit, one layer to be 8-bit, and one layer to be 4-bit. Reducing the bitrate may require additional touching-up as well.

You now have an icon file that can be imported into Visual Studio. There are two places where it should be imported into your project. The first is in the main window. In the window's Icon field, select the file you just made. Then do the same in the application's properties page (though VS may like it more if you import the icon as a Resource, then add it that way).

With this, Windows should know when to use the right filesize and bitrate for any given situation. These 12 images are all that's recommended by Microsoft for Vista compatibility, but you can put in more if you want to be prepared for situations where Windows would otherwise scale the icons for you.

Tuesday, June 3, 2008

ClickOnce - Publisher Name

Something I'd forgotten: the item that determines the placement of a ClickOnce application within the Start menu is in Options->Publisher Name. I'm not sure how to publish to subfolders with ClickOnce yet though.

Thursday, May 29, 2008

Renaming "Form1"

Visual Studio should really allow you to change the name of the startup form on creation of a new project, or at least have a more descriptive name, such as (ProjectName)Main. However, they don't do this, and you're stuck with the entirely bland and nondescript Form1.

There is a way around this though: it's still much easier to do this right after you create the project rather than a long time down the road, but here it is:

-Rename the filename of the main form (Form1.cs, Form1.h, etc).
-Press Ctrl+H (brings up Quick Replace menu)
-Change "Look in" to "Entire Solution" (not just that file)
-Find "Form1", replace with the new name you've chosen.

Tuesday, May 27, 2008

Recurse directories with C#

I'm working on a C# program that recurses through directories, adding all the files to a list (I felt like trying out C#, and this was a good place to start). I found this VB.NET program doing something very similar, and adapted it to C#.

private void recurseDirs(String rootdir) {
DirectoryInfo dirinfo = new DirectoryInfo(rootdir);
foreach(FileInfo fi in dirinfo.GetFiles()){
FileList.Items.Add(fi.FullName);
}
foreach(DirectoryInfo di in dirinfo.GetDirectories()){
recurseDirs(di.FullName);
}
}