KIS Systems, Inc - Contract Programming for Unix/Windows/Web in C++/C#/PHP/Qt/.NET and other technologies.

KIS Technoblog

Technical ruminations from our chief codemeister – Rick Berger

Archive for the 'Win32 API' Category

Win32 API – Can’t Get Away

Posted by admin on 27th September 2006

Ran into a window controlling problem with C#/.NET – a couple of things in the API aren’t exposed. The first is (are, really), the messages WM_NC* (used to detect non-client mouse hits, etc.) The second is the ability to set window settings via the SystemParametersInfo call. In this case, I want to use SPI_{SET/GET}DRAGFULLWINDOWS. C#/.NET exposes the GET functionality, but not the SET.

The first case is handled relatively painlessly – simply a matter of putting a message filter on the app and then watching for the hwnd and WM_ message of interest. You don’t want to get too carried away with message filters – every message that goes through the message pump is forwarded to the filter, first, once installed. So, you install it only when you need it, and remove it when you don’t. And just do minimal processing, while you’re in there.

The second problem requires an interop call to the user32 dll and getting that all set up properly. Not terrifically taxing, but not perfectly straightforward, either. It’s unfortunate the named constants for the SPI_, WM_, etc values aren’t available in the toolkit. You have to redeclare them in your code, somewhere (don’t want to use raw numbers, for sure.)

On one hand it points out the shortcomings of a kit like C#/.NET – on the other, it’s always nice to know I can get under the cover/lift the hood when I need to.

rickb

Posted in .NET, Programming, Win32 API, Windows, software | No Comments »