简体   繁体   English

如何从DwmGetColorizationColor获取COLORREF

[英]How to get COLORREF from DwmGetColorizationColor

I am extremely new and I do not understand what to do. 我非常新,不知道该怎么办。 I am making a DLL in C++ for a game I am working on in another language. 我正在用另一种语言开发的游戏用C ++制作DLL。 I know nothing about C++ and have been barely been working myself through it. 我对C ++一无所知,并且几乎没有自己研究过C ++。 I need it to return the windows personalization color. 我需要它来返回Windows个性化颜色。 Someone on reddit gracefully gave me some source that worked but it only returned the ACTIVE_BORDER color which is not the same color that users can easily change in windows 8+ which is what I am focusing on. reddit上的某个人优雅地给了我一些有用的资源,但是它只返回了ACTIVE_BORDER颜色,这与用户可以在Windows 8+中轻松更改的颜色不同,这正是我关注的焦点。 I have modified it to work with DwmGetColorizationColor but now the problem is that it doesn't use a COLORREF which is what I need. 我已经对其进行了修改以与DwmGetColorizationColor一起使用,但是现在的问题是它不使用我需要的COLORREF。 Anyone who can help me out would be greatly appreciated. 任何可以帮助我的人将不胜感激。

Heres my source: 这是我的资料来源:

#include <windows.h>
#include <dwmapi.h>
#include <gdiplus.h>
#define DLLEXPORT extern "C" __declspec(dllexport)
#pragma comment(lib, "Dwmapi")

DLLEXPORT double GetCol(void) {
    DWORD color = 0;
    BOOL opaque = FALSE;
    HRESULT hr = DwmGetColorizationColor(&color, &opaque);
    return color;
};

The returned color is in the format of 返回的颜色格式为

0xAArrggbb

Whereas a Windows COLORREF is Windows COLORREF

0x00bbggrr

You need to shift around the parts of your returned DWORD to to into a COLORREF. 您需要将返回的DWORD的各个部分转移到到COLORREF中。

COLORREF c = 
   ((color && 0x00ff0000) >> 16) //red
   ||
   ((color && 0x0000ff00)) //green
   ||
   ((color && 0x000000ff) << 16);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM