Quantcast
Channel: May 2023 - The Old New Thing
Browsing all 10 articles
Browse latest View live

What is the opposite of LVM_SORTITEMS?

A customer was using the LVM_SORT­ITEMS message to sort the items in a classic Win32 ListView control in response to the user checking a box called “Show sorted by date”. That part worked great. They...

View Article


On catching exceptions in PPL tasks

Say you want to catch exceptions that emerge from the Parallel Patterns Library (PPL) task class. Your initial inclination might be to write something like this: extern concurrency::task<int>...

View Article


Speeding up the insertion of a sorted (or mostly-sorted) key list into a...

Suppose you want to insert or emplace a bunch of items into a std::map, std::multimap, std::set, or std::multiset (collectively known as ordered associative containers), and you have the items in...

View Article

On creating (and using) a transforming iterator

The C++20 ranges library come with the ability to transform a view; that is, to provide a unary function that is applied to each element of a view, producing a new view. std::array<int, 2> a = {...

View Article

Don’t name your header file security.h either

A customer found that the GetUserNameExW function suddenly disappeared. error C2065: 'NameSamCompatible': undeclared identifier error C3861: 'GetUserNameExW': identifier not found What happened? These...

View Article


How can I trigger a recalc of the mouse cursor after I changed some of my...

Some time ago, I described how to trigger a recalc of the mouse cursor after changing internal application state. In the bonus chatter, I noted that the cursor you set with Set­Cursor is used only when...

View Article

Getting a strong reference from the this pointer too late

It is a standard pattern for functions that are coroutines to promote the this pointer to a strong reference (either a COM strong reference or a shared_ptr), so that the object won’t be destructed...

View Article

On writing functions that accept any specialization of a C++ template type

Suppose you want to write a template function that accepts any specialization of std::vector. Your first try would probably be something like this: template<typename Value> void...

View Article


How do I change the directory Windows uses for user profiles? revisited

Some time ago, I noted that you can use the Profiles­Directory setting in your unattend file to move the directory that Windows uses for user profiles. The classic documentation has been updated to...

View Article


C++/WinRT event handlers that are lambdas with weak pointers to the parent...

C++/WinRT provides multiple ways of auto-implementing delegates. // Function pointer e.add(&MyClass::StaticMemberFunction); // Raw pointer + non-static member function pointer e.add({ this,...

View Article
Browsing all 10 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>