OKwy
OKwy

Reputation: 104

Extracting control buttons from .msstyle

Windows created by Windows have so-called control buttons. These buttons mean "minimize", "maximize", "restore", "close". These buttons can be found in .msstyle files under the path DWMWindow > Common Properties.

MSStyle Editor

The current .msstyle file can be found by using the registry editor at the path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager and accessing the DllName value.

Regedit

In C++, you can open a .msstyle file like this (Taken from How to create control buttons exactly like Window's (OS) control buttons in wxWidgets?):

HINSTANCE handle = LoadLibraryEx(L"C:\\Windows\\Resources\\Themes\\aero\\aero.msstyles",
                                     0, LOAD_LIBRARY_AS_DATAFILE);

HTHEME theme = OpenThemeData(reinterpret_cast<HWND>(this->GetHandle()),L"DWMWindow");

Is it possible to "pull" icons from a given file, but using the python programming language?

I will be glad to any answer!

Upvotes: 1

Views: 198

Answers (1)

pratikpc
pratikpc

Reputation: 680

For the given question, you could look into the PyWin32 library

The library seems to contain within it an OpenThemeData function

The library also seems to contain a LoadLibraryEx function

The usage of a different example is here as well

dllHandle = win32api.LoadLibraryEx(
    dllName, 0, win32con.LOAD_LIBRARY_AS_DATAFILE
)
try:
    data = win32api.FormatMessageW(
        win32con.FORMAT_MESSAGE_FROM_HMODULE,
        dllHandle,
        eventLogRecord.EventID,
        langid,
        eventLogRecord.StringInserts,
    )
finally:
    win32api.FreeLibrary(dllHandle)

It also seems to support the popular winxptheme library

Code inspired from

        # Get the size of a small close button (themed)
hwnd = self.win.GetHandle()
theme1 = winxptheme.OpenThemeData(hwnd, "Window")

Based on both of these, I think the work to combine both should be relatively easy

Upvotes: 1

Related Questions