The wyDay blog is where you find all the latest news and tips about our existing products and new products to come.
This is another easy tip to wrap up this series of articles.
Start your application and unplug your mouse. Can you navigate and use your application? If you hit the tab key does the next logical control get focused? Can you open the file menu by pressing Alt-F?
Simply set the TabIndex property of your controls in ascending starting with 0. This way when your users press the tab key they next focused control is the next control in the flow of your form.
To add quick key ability to your menus you just need to put an ampersand (&) before the letter that will be used for quick access. For example, instead of a menu item captioned File, caption it &File instead. Now your users can access that menu quickly by pressing Alt-F.
In Windows Vista Microsoft changed the buttons, radio buttons, and checkboxes to have subtle animations. When you hover, check, and click these controls they all yield organic animations. But if you built your app using Windows Forms the subtle animations arent there.
To add these animations all you have to do is set the FlatStyle of these controls to System.
Microsoft has assembled a great collection of guidelines for designing applications. Its filled with screenshot examples showing good & bad designs. Plus its surprising self deprecating some of their examples of bad design are screenshots taken directly from Microsoft apps.
You should skim the guide at least once and bookmark it for later.
Thats it for the series. If you missed the earlier articles you can see the full list of articles in the series.
In todays tip Im going to cover showing drag & drop icons. Specifically keeping the icon overlay shown when you drag files from Windows Explorer to your .NET application. Heres a close-up of a user dragging files from a folder into wyBuild.
If we had used the normal .NET Framework interfaces for dragging files to wyBuild as soon as the cursor passes into the window the icons would disappear.
But, as you can see in the screenshot, the icons stay when dragging over our window. We can also set the drag & drop text to the current folder the user is dragging over.
This is one control I cant take credit for. Adam Root from Microsoft wrote up a nice control on his blog in a post Shell Style Drag and Drop in .NET - Part 3. The control works for both Windows Form and Windows Presentation Foundation (WPF) applications.
He wrote a 3 part series, and its interesting if you want to dig into the nitty-gritty Windows API.
We use the Windows Form control in wyBuild, but we have to use a little trickery to get it work right. Because Adam wrote the Drag & Drop control using a .NET Framework 3.5 language feature, and wyBuild is built using .NET Framework 2.0, we have to use this little trick from Daniel Moth.
Just add this snippet of code to your project and youll be all set to go.
//HACK: this is to support a .NET language 3.5 feature in .NET 2.0
//see, http://www.danielmoth.com/Blog/2007/05/using-extension-methods-in-fx-20.html
namespace System.Runtime.CompilerServices
{
public class ExtensionAttribute : Attribute { }
}
Join me tomorrow when I talk about Using shield icons, UAC, and process elevation. See the full list of articles in the series.
This will be another easy tip because all the work is already done and wrapped up in a nice little control. Its open source and handles all of the details, get it here.
Progress bars in Windows 7 are nearly identical to what they were in Windows Vista. Theyre green, animated and have 3 states: Normal, Error, and Paused:
To get both the 3-state progress bar (regular, error, and paused) along with the taskbar progress bar we need to use some Windows API. The easier of the two to implement is changing the state of the progress bar. This works on Windows Vista and Windows 7:
[DllImport("user32.dll", CharSet = CharSet.Auto)]
internal static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); SetPaused()
{
// 0x410 = PBM_SETSTATE
// 0x0003 = PBST_PAUSE
SendMessage(progressBar.Handle, 0x410, 0x0003, 0);
} SetError()
{
// 0x0002 = PBST_ERROR
SendMessage(progressBar.Handle, 0x410, 0x0002, 0);
} SetNormal()
{
// 0x0001 = PBST_NORMAL
SendMessage(progressBar.Handle, 0x410, 0x0001, 0);
}
Then theres the matter of the taskbar progress bar in Windows 7. You can download the Windows7ProgressBar source code (zip file) to see how I did it, but the gist of it is you need to implement the ITakbarList3 Interface, and then use the SetProgressState to set the state (Normal, Error, Paused, or Marquee) and SetProgressValue to set the value.
Join me Monday when I talk about Drag & Drop icons. See the full list of articles in the series.