How do I revert a control back to its default theme?

Raymond Chen

A customer disabled visual styles for their control so that they could do custom rendering, but when the system switches to high contrast mode, they want to abandon their customizations and revert to the system styles.

// Disable visual styles for this control so we can
// draw it our own way.
SetWindowTheme(hwndControl, L"", L"");

But how do they undo the effect of that call and tell the system, “Um, hey, I know I told you that I didn’t want the system to draw any visual styles, but I changed my mind. Can you draw visual styles for me after all?”

You can return to the default behavior by passing NULL for the last two parameters.

When pszSubAppName and pszSubIdList are NULL, the theme manager removes the previously applied associations.

// Return to default visual styles for this control.
SetWindowTheme(hwndControl, NULL, NULL);

0 comments

Discussion is closed.

Feedback usabilla icon