How to position windows correctly at 120 DPI in WPF

If you want to place a window at a specific place in WPF, it will work pretty much as you expect—unless your DPI is 120 (the default is 96). Here’s a sample that shows how to put it where you want.
In this case, I want to put a window just under another control, aligned [...]

Popularity: 4% [?]

A WPF Numeric Entry Control

When WPF first shipped, there was a noticeable lack of certain controls we’ve become used to in Win32 and WinForms: Calendar, DateTimePicker, and NumericUpDown. WPF 4 adds Calendar and DatePicker, but not anything for numeric entry.
For my solution I wanted something that behaved very similarly to the WinForms NumericUpdown control.
Some of the specifications:

Allows user [...]

Popularity: 4% [?]

Updated CPU usage article

I made a important changes to the CPU usage code and have updated the article to reflect it. Instead of a critical section, the code uses just the interlocked increment/decrement functions. I also updated the sample demo to use multiple threads to read the CPU usage to demonstrate the thread safety clearly.
Popularity: 12% [?]

Popularity: 12% [?]

Determine CPU usage of current process (C++ and C#)

Updated 2/4/2009: I changed the implementation of these classes from the original:

Instead of a critical section, InterlockedIncrement/Decrement is used.
The sample driver program now demos using multiple threads using the CpuUsage class to show thread safety.

Download the C++ and C# projects that accompany this article.
Just to make it clear, there is no API called GetProcessCpuPercentage(). To [...]

Popularity: 26% [?]

An easy stack layout panel for WinForms

This is a simple, but useful tip. Users of WPF are spoiled. They have all sorts of layout options. Those of us still working in WinForms have FlowLayoutPanel and TableLayoutPanel. That’s it. WPF has those and more.
For my current project, I needed a panel to layout controls vertically. The TableLayoutPanel can be awkward to work [...]

Popularity: 18% [?]

Converting OLE_COLOR to System.Drawing.Color

I’ve been working on a project using Visual Studio Tools for Office 2008 (VSTO) and at one point I needed to get the colors for categories in Outlook 2007. There are actually 3 colors, and they are returned as uint’s–why the .Net wrappers don’t convert to colors for you, I don’t know (to avoid linking [...]

Popularity: 11% [?]

Tracking database changes using triggers

Tracking changes in database tables is an incredibly useful feature–especially for operational data that can change often. Having recently had to implement this feature, I thought I’d share some of the techniques I learned.

Sample Database
First, let’s conceptualize a very simple database consisting of user information (name, date of birth), and e-mails. A user can have [...]

Popularity: 7% [?]

In this universe we obey the law of commutativity

This kind of thing has happened to be a few times now, so I thought I’d share the fun.
In one of our pieces of software we have a process that looks like this:

void MyThread()
{
while (true)
{
DoFunctionA();
[...]

Popularity: 4% [?]

GetTextExtent vs. DrawText (with DT_CALCRECT)

Working on an MFC app that has just been converted to Unicode (finally!), I noticed that one button (which is created dynamically) is too small to fit the text in Korean (and Russian and a few other languages).
The code was calling something like:

CSize sz = m_btAdjustColors.GetDC()->GetTextExtent(sCaption);

It seems correct, but these script languages are throwing it [...]

Popularity: 7% [?]

How to file good bug reports (from Frank Kelly)

This is an issue I run into constantly at my job.
Frank Kelly wrote up a good summary of some items. They’re simple, easy to understand, easy to follow, even for non-programmers.
In fact, I’m sending this link out to everyone in my group here at work.
Technorati Tags: testing,programming,bug reporting
Popularity: 5% [?]

Popularity: 5% [?]