Archive

Archive for September, 2009

Desktop Window Manager

September 15th, 2009 No comments

The desktop composition feature, introduced in Windows Vista, fundamentally changes the way applications display pixels on the screen. When desktop composition is enabled, individual windows no longer draw directly to the screen or primary display device as they did in previous versions of Microsoft Windows. Instead, their drawing is redirected to off-screen surfaces in video memory, which are then rendered into a desktop image and presented on the display.

Desktop composition is performed by the Desktop Window Manager (DWM). Through desktop composition, DWM enables visual effects on the desktop as well as various features such as glass window frames, 3-D window transition animations, Windows Flip and Windows Flip3D , and high resolution support. For more information about the user experience features enabled by the DWM visit the Windows Vista: Features user experience page.

Many of the DWM features can be controlled or accessed by an application through the DWM APIs . The following documentation describes some of the features and requirements of the DWM APIs.

Using SetForegroundWindow on Windows Owned by Other Processes

September 15th, 2009 No comments

In modern versions of Windows (XP, Vista, and beyond), the API call SetForegroundWindow() will bring the specified window to the foreground only if it’s owned by the calling thread. The following code removes this limitation and provides a workaround:

void NewSetForegroundWindow(HWND hWnd)
{
    if (GetForegroundWindow() != hWnd)
    {
        DWORD dwMyThreadID = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
        DWORD dwOtherThreadID = GetWindowThreadProcessId(hWnd, NULL);
        if (dwMyThreadID != dwOtherThreadID)
        {
            AttachThreadInput(dwMyThreadID, dwOtherThreadID, TRUE);
            SetForegroundWindow(hWnd);
            SetFocus(hWnd);
            AttachThreadInput(dwMyThreadID, dwOtherThreadID, FALSE);
        }
        else
        {
            SetForegroundWindow(hWnd);
        }
        if (IsIconic(hWnd))
        {
            ShowWindow(hWnd, SW_RESTORE);
        }
        else
        {
            ShowWindow(hWnd, SW_SHOW);
        }
    }
}

Another (but more intrusive and restrictive) way to make SetForegroundWindow() behave the same way as it did on Windows 95 and Microsoft Windows NT 4.0 is to change the foreground lock timeout value SPI_SETFOREGROUNDLOCKTIMEOUT, as described in this MSDN document.

Reference

Creating a Benchmark

September 15th, 2009 No comments

To create a benchmark, follow the instructions for crating a test and then add a QBENCHMARK macro to the test function that you want to benchmark.

class MyFirstBenchmark: public QObject
{
  Q_OBJECT;
  private slots:
   void myFirstBenchmark()
   {
     QString string1;
     QString string2;
     QBENCHMARK
     {
       string1.localeAwareCompare(string2);
     }
   }
};

The code insde the QBENCHMARK macro will be measured, and possibly also repeated several times in order to get an accurate measurement. This depends on the selected measurement back-end. Several back-ends are available an can be selected on the command line.

Documentation

Tags:

Security Development Lifecycle (SDL) Banned Function Calls

September 15th, 2009 No comments

Note: This paper is derived from the book The Security Development Lifecycle, by Michael Howard and Steve Lipner, Microsoft Press, 2006.

Prohibiting the use of banned APIs is a good way to remove a significant number of code vulnerabilities — this practice is reflected in Stage 6 of The Microsoft Security Development Lifecycle: “Establish and Follow Best Practices for Development.” It can also be referenced in Chapter 11 of the Microsoft Press Book The Security Development Lifecycle.

When the C runtime library (CRT) was first created about 25 years ago, the threats to computers were different; machines were not as interconnected as they are today, and attacks were not as prevalent. With this in mind, a subset of the C runtime library must be deprecated for new code and, over time, removed from earlier code. It’s just too easy to get code wrong that uses these outdated functions. Even some of the classic replacement functions are prone to error, too.

This list is the SDL view of what comprises banned APIs; it is derived from experience with real-world security bugs and focuses almost exclusively on functions that can lead to buffer overruns (Howard, LeBlanc, and Viega 2005). Any function in this section’s tables must be replaced with a more secure version. Obviously, you cannot replace a banned API with another banned API. For example, replacing strcpy with strncpy is not valid because strncpy is banned, too.

Also note that some of the function names might be a little different, depending on whether the function takes ASCII, Unicode, _T (ASCII or Unicode), or multibyte chars. Some function names might include A or W at the end of the name. For example, the StrSafe StringCbCatEx function is also available as StringCbCatExW (Unicode) and StringCbCatExA (ASCII).

More info

Windows Animation

September 15th, 2009 No comments

The Windows Animation Manager (Windows Animation) is a programmatic interface that supports the animation of visual elements of Windows applications. Windows Animation is designed to simplify the development and maintenance of animation sequences and to enable developers to implement animations that are consistent and intuitive. Windows Animation can be used with any graphics platform including Direct2D, Direct3D, or GDI+.

Basic Concepts

The two fundamental units of an animation are (1) the characteristic of a visual element to animate and (2) the description of how that characteristic changes over time. An application can animate a wide variety of characteristics such as position, color, size, rotation, contrast, and opacity.

In Windows Animation, an animation variable represents the characteristic to animate. A transition describes how the value of that animation variable changes as animation occurs. For example, a visual element might have an animation variable that specifies its opacity, and a user action might generate a transition that takes that opacity from a value of 50 to 100, representing an animation from semi-transparent to fully opaque. A storyboard is a set of transitions applied to one or more animation variables over time.

An application displays animations by constructing and playing storyboards and then drawing sequences of discrete frames as the values of animation variables change over time.

Introducing the Windows Ribbon Framework

September 15th, 2009 No comments

The Windows Ribbon (Ribbon) framework is a rich command presentation system that provides a modern alternative to the layered menus, toolbars, and task panes of traditional Microsoft Windows applications.

The Ribbon framework is a collection of Microsoft Win32 APIs that provides a host of new user interface capabilities for Windows developers and includes both the ribbon command bar and a context menu system. This rich, new command framework offers:

  • Easy implementation for brand new Ribbon applications and straightforward migration of existing Win32 applications.
  • Consistent appearance and behavior across Ribbon applications.
  • Adherence to Windows user interface (UI) guidelines for a first-class Windows experience through accessibility standards, visual style (theming) support, automatic high contrast adjustments, and high dots per inch (dpi) awareness.

Additional: Ribbons are the modern way to help users find, understand, and use commands efficiently and directly—with a minimum number of clicks, with less need to resort to trial-and-error, and without having to refer to Help.

    Win32 Tips, Tricks and Tutorials

    September 15th, 2009 No comments

    No MFC, No VB – pure Win32 C/C++.

    Presented here are a collection of programming tutorials for Windows. The tutorials cover various Windows programming topics, but most concentrate on the user-interface aspect of programming. All tutorials and source downloads are in the C programming language. No external libraries such as MFC are required to build the source code presented in these tutorials.

    GPS Framework for .NET

    September 15th, 2009 No comments

    GPS Framework for .NET – GPS.NET is a formerly commercial .NET component maintained by GeoFrameworks, LLC from 2004 to 2009. In 2009, Jon Person decided to release the full source code of GPS.NET to the public domain for the benefit of the open source development community. This version (3.0) is the latest release which had a short lifespan before being released here on CodePlex. The purpose of this framework is to deliver intuitive real-time GPS functionality with maximum laziness efficiency for all possible computers, mobile devices and NMEA-compliant GPS devices.

    9 качеств, которые перевернут вашу карьеру

    September 14th, 2009 No comments

    Успех – понятие очень многогранное. Однако есть вещи, которые помогут вам стать успешнее в делах, независимо от того, кто вы и к чему стремитесь. Вот они:

    Read more…

    MindMap

    September 10th, 2009 No comments

    A mind map is a diagram used to represent words, ideas, tasks, or other items linked to and arranged around a central key word or idea. Mind maps are used to generate, visualize, structure, and classify ideas, and as an aid in study, organization, problem solving, decision making, and writing. (more or russina version)

    Software

    • FreeMind is a premier free mind-mapping software written in Java. The recent development has hopefully turned it into high productivity tool. We are proud that the operation and navigation of FreeMind is faster than that of MindManager because of one-click “fold / unfold” and “follow link” operations. (FreeMind homepage)
    • Edraw Max is an all-in-one graphics software that makes it simple to create professional-looking flowcharts, organizational charts, network diagrams, business presentations, building plans, mind maps, fashion designs, UML diagrams, workflows, program structures, web design diagrams, electrical engineering diagrams, directional maps, database diagrams and more. (homepage)

    Additonal links

    Tags: , , ,