Visual Studio Tip: Show Threads in Source

May 29, 2012

Debugging multithreaded applications is always hard, so any help we can get from the debugger is appreciated. Here’s one tip that can help using Visual Studio 2010 when many threads are running at the same time, some of which run similar code.It’s tedious to lookup each thread’s call stack to see where its next instruction pointer is located. Here’s the Threads window in action: To find the actual source line each thread is at the breakpoint moment, we’ll need to switch to that thread by double clicking it in the Threads window and then we’ll see something like...

Windows Media Foundation: Controlling Camera Properties

May 19, 2012

I have blogged about Media Foundation before; it’s the “next generation” of DirectShow, introduced in Windows Vista, enhanced in Windows 7 and further enhanced in Windows 8 (more on that in a future post). One of the tasks I encountered recently was to do a video capture from a camera. This is not too difficult to do (once you understand how Media Foundation works) and there’s even two sample in the SDK. But how do you control various camera properties, such as focus, zoom, white balance, etc.? It turns out Media Foundation does not define any specific interfaces for...

Windows 8: TopMost vs. TopMost

May 16, 2012

In Windows, a Window can be made topmost, by setting an extended style with the value WS_EX_TOPMOST (8), typically provided to CreateWindowEx. A topmost window is always on top of non-topmost windows. Among all topmost windows, the normal z-order rules apply. That is, until Windows 8. A Metro application is built with a topmost window – that makes perfect sense. What about desktop apps? Here’s an empty desktop snapped with a metro app (the desktop itself can be seen as a kind of metro app): Now let’s open Task Manager and make it topmost (Options / Always On...

WPF Tip: Attached properties and bindings

May 12, 2012

Attached properties are a great way to extend capabilities of existing elements without the need to derive or otherwise tinker with those elements. Suppose we create an attached property that is a collection of objects of some particular kind. When that property changes, those objects are read, and that special functionality is applied. Here’s a hypothetical example of such a scheme: public static class SomeHelper {     public static DemoCollection GetData(DependencyObject obj) {         return (DemoCollection)obj.GetValue(DataProperty);     }       public static void SetData(DependencyObject obj, DemoCollection value) {         obj.SetValue(DataProperty, value);     }       public static readonly DependencyProperty DataProperty =          DependencyProperty.RegisterAttached("Data",...
tags: , , ,
one comment

Win32 and Metro–CreateFile(2)

May 3, 2012

When a new Windows version comes out, I’m always curious about the new Windows API (Win32) functions that are added to the release. With Windows 8, things get a little more complicated, as there are desktop apps and there are metro apps. Now, for every Windows API function the documentation states whether this API is valid for desktop apps only or for desktop apps and metro apps. One classic function is CreateFile. This is one of the oldest functions – exists since the very first Windows NT version. In Windows 8, it’s marked for desktop apps only. This may...