Време е за първия блог пост на български. Каква по-добра тема от Windows 7? Днес Microsoft направи Windows 7 RC – Release Candidate, достъпен за всички. Можете да научите повече и свалите своето копие от тук. RC означава, че тази версия е много близо до крайната, която се очаква наесен.

Инсталацията е бърза и отнема не повече от 20 минути, а единствената информация, която е неоходима да въведете е езика, който да се инсталира, на кой дял и евентуално сериен ключ за активация (но не е задължителен).

Нека разгледаме какво е ново и променено в Windows.

Работният плот

Лентата на задачите е първата промяна, която ще забележите. В Windows 7 Quick Launch и обичайният Taskbar са обединени.

Работният плот Internet Explorer с preview Jump List

Бутоните в тази лента се комбинират, а липсата на имената на всички програми пести пространство (можете и да намалите размера на иконите или да включите опцията за показване на имената). Например ако имате отворени 7 таба или прозорци на Internet Explorer ще има само една икона в лентата. За сметка на това смяната на прозорци става като преминете през бутоните и изберете желания прозорец. Също така има и приятна плаваща анимация за тези, които използват Aero.

Лентата на задачите в три възможни режима

Ако щракнете с десния бутон върху някоя от програмите в таскбара, ще изкочи един нов вид списък – Jump List. Там повечето от програмите представят списък с последно отворени папки, картини в Paint, документи на Word или Еxcel, или страници посетени в интернет.

Една малка, но полезна промяна – ако премествате, копирате или сваляте файлове от интернет, бутона на програмата показва прогреса на операцията. Така можете да продължите работата си и само с един поглед ще разберете кога е готова.

ТемиТемите в Windows “преобличат” работния плот и могат да сменят фона периодично. Sidebar от Windows Vista вече го няма, а притурките (gadgets) могат да се закрепят към всеки край на екрана.



Библиотеки

Библиотеките са нов вид папки – по-точно, колекция от такива. Всеки има документи, снимки, музика на компютъра си, но в много случаи те са разхвърляни по различни дялове, а даже и външни харддискове. Е, с библиотеките е лесно да се изберат местоположения с даден тип медия и само с влизането в една библиотека, всички те ще бъдат обединени. Библиотеките се използват на много места в Windows 7.

Библиотеки Библиотека с картини

Развлечение

Media Player и Media Center, както повечето от приложенията в Windows 7, са с нов изглед. Windows 7 включва декодер за H.264 и поддръжка на формата QuickTime, което обезсмисля инсталирането на програмата на Apple. H.264 също така е и кодекът, който Blu-ray дисковете често използват.

Media Center - стартиране Media Center - картини Media Center - възпроизвеждане на Blu-ray диск 8

Дизайнерите в Microsoft наблягат на нюанси на синьото (“свежо”?) и се е получило добре. Paint и WordPad вече има много нови инструменти и изглеждат по-професионално, подобно на Office 2007.

Paint

Впечатление

Windows 7 е по-лекият и бърз наследник на Vista. Microsoft доста са поработили върху производителността, облика и приложенията в новата версия. Като release candidate, този билд съдържа всички възможности на операционната система. Оттук нататък можем да очакваме дори още подобрения в бързината.

Download

Можете да свалите копие на Windows 7 RC (билд 7100) тук.

Microsoft Most Valuable ProfessionalJust a couple of days ago Microsoft MVP lead Alessandro Teglia announced the newly awarded and renewed Most Valuable Professionals for 2009 — I would like to congratulate all of them on their achievements. Rock on!

I am also very happy and proud to be given the award for Visual C# this year. It is my programming language of choice and in my opinion the .NET Framework will continue to be adopted by developers in 2009. I hope the MVP program will offer a lot of new doors and opportunities.

So what’s to come on my blog? I plan on writing mosly technical posts about the .NET Framework as a whole, and coding patterns in .NET languages. Visual Studio 2010 is coming near release and it is going to introduce some very interesting additions, which I will go through in the coming days.

I am frequent on the official Microsoft newsgroups (mostly .NET-related) and will be attending Microsoft Days ‘09 later this month. You can expect an essential coverage as well.

Last, but definitely not least, a big “Thanks” to Microsoft and a very good friend of mine, Christoffer Andersson, for all the support!

P.S. I am contemplating mirroring some or all of the articles in Bulgarian, my native language. Are there any Bulgarian readers out here?

GlassLib is a wrapper library for the Desktop Window Manager API and is to be used by developers which would like their applications to take advantage of .NET Framework and Windows Presentation Foundation in particular.

It can be used to control the Desktop Composition due to application requirements, create and reference Live Thumbnails of arbitrary windows, manipulate the Glass client area of windows and receive events which occur for them (Figure). Developers who target their applications for Far East users can also use the wrapper library to control the flow direction of controls and caption bar.

While the library wraps a big portion of the API exposed by DWM, the timing and performance counter part is to follow up shortly.

Documentation and a test application are provided. The usage of the wrapper library is pretty much straight-forward. Following is a list of several key facts:

  • Add a reference to the DwmWrapper.dll library to your project (from the Solution Explorer, select your project’s node, right click it and select Add Reference. From the new dialog box, browse the library file). Please note that the library is compiled against the .NET Framework 2.0 therefore it can only be used in projects compiled against it, or a newer version.
  • Include the GlassLib namespace so that the Dwm-related classes can be accessed more easily.
  • When used in a System.Windows.Window, override the OnSourceInitialized method and then set up the event handlers.
  • Per-window options can be set using the Dwm.Glass, Blur, Events, NonClientArea and Flip3D. This is available by using the indexer (default property) of these properties. The value passed to the indexer can be an IntPtr - handle to a window or a System.Windows.Media.Visual whose window handle will be manipulated. E.g:
    • In VB .NET: Dwm.Glass(Me).Enabled = False
    • In C# .NET: Dwm.Glass[this].Enabled = false;
      • Note: this and Me refer to the calling instance, which is a System.Windows.Window in the example.
  • The Dwm* structures have implicit operators. This allows for casting Windows Presentation Foundation Rect and Thickness implicitely to DwmRect and DwmMargins, respectively. For instance, the following expression will be valid:
    • Thickness foo = new Thickness(5, 30, 5, 20);
      // Assign foo to a Visual’s margin.
      Dwm.Glass[this].Margins = foo; // foo is implicitely casted to DwmMargins.

GlassLib Test Application GlassLib Test Application - Right-To-Left Layout

If you have any questions, suggestions or would like to report an issue, please feel free to use the Contact form.

Written in C# .NET. Binaries and the sources of a test application are available here; only binaries.

 

Following the first part of the Tweak DWM from your programs series, we are going to explore the actual usage of the Desktop Window Manager API in a Windows Forms-based program. The test application–included in the source package–also makes use of glassbarGlassBar, an extension to the existing control set.

Using GlassLib in your program

projectGlassLib is going to be main focus of this part of the series. It supersedes projectDwmWrapper by implementing a framework around glassbarGlassBar which can be used as a complement to your visually-rich forms. In order to use this library in your project, you have to do the following:

  1. Include a) a reference to the DLL in your project from Visual Studio: Project menu => Add reference, or b) the actual code files to your C# project (adding them as links (shortcuts) as opposed to copying them is more suitable if you wish include the files in multiple projects and/or wish to make changes to the code yourself).
  2. Remember that all of the functionality lies in the namespace_GlassLib namespace. You can use the using or Imports clause in the beginning of your C# or VB.NET code file, respectively, or the global imports if you code exclusively in VB.NET.

Exploring the GlassLib Test app

Let’s begin exploring the framework by opening the project file for projectGlassLibTest. Included in the GlassLib solution, it depends on the projectGlassLib project reference, which on its part has all the projectDwmWrapper code. Open the formfrmMain.cs file which is the form which is to be executed right at start up. As described in the first part, the first thing the class constructor public frmMain() should do is to set Dwm.ThrowExceptionTypes to DwmExceptionTypes.None in order to avoid any exceptions from being raised when DWM is not enabled or available on the OS, or if any function failed. The next thing the program does is to enable dragging from the Glass-extended area.

Dwm.Glass[this].DragExtendedArea = true; is useful if you want the extended area to act as the caption bar does, like in Windows Media Player. This is what the glassbarGlassBar toolbar does as well (more on this later in this part). toolbox Switch to Designer mode (View => Designer) and you can see the layout of the form: the usual Windows Forms buttons, combo and text boxes et cetera, but also glassbarGlassBar. To add the latter to your own forms, open the Toolbox (View => Toolbox) and drag it to your form (see figure on right). The toolbar will automatically dock to the bottom of it and extend Glass from this side of the form. You are free to dock it to the whole form (or container for that matter) or one of the other sides. Because DWM only supports Glass on top-level windows, in designer mode glassbarGlassBar falls back to UXTheme API in order to get the theme-specific background image or brush which is suitable for all non-Aero Glass themes such as Aero Basic, Luna (on Windows XP) or Windows Classic on any supported Windows version. On top of this, you can choose to write your own classGlassBarRenderer.

This feature provides two key benefits to your application’s design:

  • For Windows Vista systems and future OS with support for Glass: rich, seamless Glass UI
  • For Windows Vista systems where DWM is disabled or unavailable, and all previous Windows releases: seamless UI deriving from the appropriate Windows theme, including custom themes created with software such as WindowBlinds.

GlassBar

Managing the GlassBar items

Adding your items to GlassBar is quite easy. While in Design Mode, make sure that the Properties pane is visible (View menu => Properties Window to invoke it), select Items and expand the Collection Editor. You can add, remove and rearrange the items. For each one of them you can customize their:

  property_thumb1Name Used in code only (does not appear in UI)
  property_thumb1Enabled Enables/disables the item from the UI
  property_thumb1Icon Preferably translucent PNG image 25×25 pixels in size
  property_thumb1IsSeparator Denotes whether the item is a separator (its Icon will be disregarded)
  property_thumb1Overlay Image, useful for ‘hover’ effects
  property_thumb1Text Alternative text shown when the item is hovered
  property_thumb1Visible Shows/hides the item

You can of course manage items programmatically using the property_thumb1Items property, for example adding one: Image img = Image.FromFile(“someFile.png”); GlassBarItem gbi = new GlassBarItem(“Sample Text” + i, img); glassBar.Items.Add(gbi); When the logic of your program requires an item be disabled or hidden, e.g. an unavailable feature, you can use property_thumb1Enabled or property_thumb1Visible to prevent users from clicking it.

Custom renderers

Internally GlassBar defines a standard renderer which on Windows Vista with Aero Glass enables draws on a translucent surface and otherwise falls back to the system-defined theme. If you wish to code a custom renderer for your needs, what you have to do is:

  1. Create a class deriving from (inheriting) from one of the following classes:
    • classGlassLib.Rendering.DefaultGlassBarRenderer if you wish to customize only specific parts of the default renderer (images, background etc)
    • classGlassLib.Rendering.GlassBarRenderer if you wish to build one from the ground up. This requires you to implement all of the methods and properties and is unlikely to be your choice.
  2. Decide which functions or images you would like to change. You can assign any image to property_thumb1MainPiece, RightSecondaryStates, AnimationStrip etc.
  3. The method_thumb1DrawBarBackground function is called every time the UI changes and needs to be redrawn. It is here where you can change most of the behavior of the default renderer and implement your own features.
  4. Assign an instance of your custom renderer to glassbarGlassBar
    • glassBar.Renderer = new CustomRenderer(); or to revert to default:
    • glassBar.Renderer = new GlassLib.Rendering.DefaultGlassBarRenderer();

The test app

There is a test program added to the package, project_thumb1GlassLibTest, whose code and compiled binary you can explore and experiment with GlassBar and DWM. If you have any comments, questions, wishes or just an opinion, I would be happy to hear it.

Flip 3DWith Windows Vista, Microsoft introduced a whole new window manager which provides a better experience to the user and an independent graphics surface to us developers by taking advantage of graphics acceleration hardware (your graphics card or integrated GPU).

In a three-part blog post, I will show you how to use a wrapper around the Desktop Window Manager Application Programming Interface in order to control its state, change colorization, or change the rendering policy of windows from your Windows Forms and .NET 3 Presentation Foundation programs.

Getting Started

Windows Forms and Windows Presentation Foundation will be referred to in these posts as WF and WPF respectively.

The code you will need can be downloaded from here and is written in C# (as are the code samples in this post). That being said, you can use it in projects of any other .NET language — you can include the compiled libraries as references. Otherwise (if you code in C#), you also have the option to include the files in your project and not distribute a separate library. The solution is for use in Visual Studio 2005 but is also compatible with version 2008.

The whole framework is located under the namespace_GlassLib namespace and is the source to three main types of projects:

  • projectDwmWrapper is a .NET wrapper around the DWM API, which can be compiled in the following flavors:
    • No dependency on WF or WPF. It can be used to avoid DLL clutter when coding command-line applications to manipulate the DWM.
    • Solely WF or WPF
    • Both for mixed-framework projects.
  • projectGlassLib is a WF-powered layer above projectDwmWrapper and provides a set of classes, including the classGlassBar control for use in your forms
  • projectThe Test Projects you can use to try the various features that the two other projects have. They will be used here ad hoc.

DWM test appIn this first part, we will explore the architecture of the wrapper, its core functionality and application in Windows Forms programs.

Microsoft provides an API for DWM in the equivocal DwmApi library. Encapsulating it for easier use in .NET programs is the wrapper’s main purpose.

Since all necessary classes are located under the namespace_GlassLib namespace, in order to avoid writing it every time, I would suggest that you insert it in your C# or VB code file’s “imports” or, if you are working exclusively with VB, in your project’s “Imported Namespaces” list in order to avoid doing the first as well.

The most important class is classDwm and can be used to control virtually any aspect of DWM as long as the public API allows it. The various features are available via the following properties of classDwm:

  propertyBlur Enables/disables the black background transition when a window (not necessarily your window) is maximized, sets custom blur region
  propertyColorization Gets/sets the Aero Glass colorization
  propertyComposition Enable/disable DWM, check if running and if the system is DWM-capable
  propertyEvents Used to set up notifications for colorization, composition, non-client rendering or window-maximized changes
  propertyFlip3D Start/Stop Windows Flip3D or Flip
  propertyGlass Enable/disable Glass on a given form (via its instance, e.g. this) or window (via its handle/hWnd, an classIntPtr)
  propertyNonClientArea For advanced users only, gets or sets how DWM is handing the painting of a given form or window (see propertyGlass above)

Using the Wrapper

Note that DWM is only available on Windows Vista, so I would suggest that you select how to handle the wrapper’s behavior on earlier operating systems. Otherwise, exceptions will be raised which you will have to catch.

The first option is to limit the exceptions the wrapper will raise by setting propertyDwm.ThrowExceptionTypes to one of the available optionsDwmExceptionTypes

  propertyNone
  propertyUnsupportedFeatures
  propertyDesktopWindowManager

Raising no exception will most likely suit your needs best so adjust this property before you make any other changes to DWM, preferably at program startup or in the form’s constructor.

Dwm.ThrowExceptionTypes = DwmExceptionTypes.None;

Now you can make any changes you want to your form’s state in the DWM, for example enable Glass–it is as easy as writing

Dwm.Glass[this] = new DwmMargins(100, 4, 8, 20);

where this is the instance of the form (you can replace this with any other form instance you would like) and the margins are defined as left-right-top-bottom. You can use propertyDwmMargins.EntireWindow instead to extend glass in the whole window client area, like Mobility Center does in Windows Vista.

Restoring the default borders is done by calling the methodRestore method.

Dwm.Glass[this].Restore();

DWM colorizationsReceiving notifications on the global DWM state or on your forms’ is important in order to know how you should handle painting backgrounds or the non-client area. You can choose to get notified when the Aero Glass colorization is changed or DWM starts up or shuts down. In GlassLib this is straightforward: each form that you wish to be notification-aware, GlassLib will include in its list and you have to attach your handlers to the colorization, composition, non-client rendering or window-maximized changes.

Dwm.Events[this].AddHandlers(); // Notifying GlassLib…

// Add our handlers

Dwm.Events[this].CompositionChanged += new DwmEventHandler(OnCompositionChanged);
Dwm.Events[this].ColorizationChanged += new DwmEventHandler(OnColorizationChanged);

private void OnCompositionChanged(object sender, DwmEventArgs e)
{
// Update the UI on composition change (extend glass if DWM is enabled, otherwise restore)
if (Dwm.Glass[this].Enabled)
Dwm.Glass[this].Margins = new DwmMargins(100, 4, 8, 20);
else
Dwm.Glass[this].Restore();
}

private void OnColorizationChanged(object sender, DwmEventArgs e)
{
MessageBox.Show(e.Colorization.ToString());
}

Flip 3DAlthough the public DWM API does not make it easy for one to change the colorization programmatically, DwmWrapper exposes this functionality through the propertyDwm.Colorization property. Controlling the Desktop Window Manager is also as easy as setting propertyDwm.Composition.Enabled to the desired value, either true or false. Other useful “one-liners” include invoking Windows Flip and Flip 3D: methodDwm.Flip3D.EnterAltTab(); and methodDwm.Flip3D.Enter();, respectively.

You can tinker with the full GlassLib source code and the included test projects to see how all of the aforementioned features work in a real environment. In the next part I am going to cover the more advanced functionality of the wrapper, the Windows Forms test app and how it manages DWM thumbnails.

If you have any comments, questions, wishes or just an opinion, feel free to post it here.

You are free to use GlassLib in your freeware programs, but please at least acknowledge it in your release notes/about dialog/website. In case your program is commercial/shareware, I would appreciate it if you could contact me beforehand. Thanks.

Yesterday Microsoft released the whole series of language packs (34), including Arabic, Greek and Bulgarian. The latter will be useful to fellow Bulgarians running Windows Vista Ultimate or Enterprise–they are the only editions of Windows with support of language packs.

There were some critic reactions to Windows Vista Ultimate Extras as a service because the team could not provide Windows DreamScene and all of the language packs besides other extras on time, although this was paid for by Ultimate users. However, the team is again up and running and I congratulate them on the job well done.

Windows Vista Ultimate Extras - Language Packs

 

  

 

I have recently worked on Windows Sidebar Styler and version 2.0.6 is now available.

Among the improvements is instant application of styles as well as the resizable Windows Sidebar feature. The latter is especially useful when Windows Sidebar is docked on the left. Added are more localizations and Alky for Applications is supported for use in Windows XP or Server 2003.

The new version can be downloaded here.

If you are interested in localizing Windows Sidebar Styler in your native language, or just want to suggest a feature for the next version, please do not hesitate to contact me.

Christoffer Andersson–an MVP in Active Directory and a very good friend of mine–recently released the first beta of his Fine-Grained Password Policy Tool. If you are an IT planner or analyst or simply experimenting with the new features of Windows Server 2008 in terms of domain-wise security, you will like to deploy the application. It includes Management Console and PowerShell snap-ins which create and manage Fine Grain Password Policies with complex properties as provided by the latest Server OS.

  

Binaries: FGPP Beta 1_2228-20070706.0 32-bit, 64-bit

Documents: Original blog post, Quick Start Guide, Overview of Fine-Grained Password Policies

Notes: Contributors to the development of FGPP include Björn Österman and myself.

Microsoft is currently running a few campaigns for their partners, one of which is Windows Vista Partner Odyssey. It aims to bridge partners who have developed for the new platform or simply leveraged its power for their business. If you are one of those you can enter now — you stand a fair chance of being selected as a Windows Vista Adventurer and sent a bag full of survivor tools (in fact, it is rather nice). Microsoft will also award 5 exciting adventures to one of these partners each month.

I am glad that Microsoft selected Windows Sidebar Styler to highlight AeroXperience. You can read our case study on the Partner Profiles page by searching for AeroXperience.

Case study

An updated version of Windows Sidebar Styler (v2.0.5) has been made available. Please check the previous post for download links as well as updated documentation.

Additions include support for Gadget resource localization, translations of the application UI, as well as fixed issues with VAIO. If you are interested in helping localize Windows Sidebar Styler in your native language, please do not hesitate to contact me.




About

Stanimir Stoyanov is a programmer, Microsoft MVP, and Windows enthusiast. Read More...

Currently, he is administering AeroXperience and coding using Visual Studio 2008 on Windows 7.