更改 SysLink 控件的颜色 [英] Change color of SysLink control

查看:38
本文介绍了更改 SysLink 控件的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为

解决方案

这是默认情况下 syslink 控件的样子:

注意静态部分是黑色的(和静态控件一样).只有链接部分是蓝色的.在您的情况下,所有内容始终为蓝色,背景颜色与对话框颜色相匹配.因此应用程序已经进行了自定义更改.

如果有正常的消息处理,那么下面的代码应该将所有内容都更改为红色:

<小时>

使用WM_CTLCOLORSTATIC,但是你必须告诉syslink控件接受颜色变化:

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){开关(味精){案例 WM_CTLCOLORSTATIC:{HDC hdc = (HDC)wp;SetTextColor(hdc, RGB(255, 0, 0));SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));返回(LRESULT)GetSysColorBrush(COLOR_BTNFACE);}案例 WM_INITDIALOG:{...LITEM 项目 = { 0 };item.iLink = 0;item.mask = LIF_ITEMINDEX |LIF_STATE;item.state = LIS_DEFAULTCOLORS;item.stateMask = LIS_DEFAULTCOLORS;SendMessage(hsyslink, LM_SETITEM, 0, (LPARAM)&item);...返回真;}...}...}

I am writing a plugin for Autodesk 3ds Max, a native, Windows-only application. The plugin is written in C++ and uses the raw Win32 API to build its user interface, as 3ds Max plugins are supposed to.

I would like to display an HTML link in the plugin's UI to let the user download a new version of the plugin from the web. The SysLink control seems to do the job.

Here's the difficulty: the colors of 3ds Max's user interface are configurable. I would like my plugin to be a good citizen, so I need the SysLink control to use the same color as other static labels.

Unfortunately, right now the text of the SysLink control is always drawn in blue, which doesn't work so well with the dark color theme of 3ds Max. Moreover, it doesn't look like I can ask 3ds Max for its color palette.

How could I make the SysLink control use the same color as other static labels?

解决方案

Edit:

This is what syslink control should look like by default:

Note the static part is black (same as static controls). Only the link part is blue. In your case everything is always blue, and background color matches dialog color. Therefore the application has already made custom changes.

If there is normal message handling then the code below should change everything to red:


Use WM_CTLCOLORSTATIC, but you have to tell the syslink control to accept color change:

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {

    case WM_CTLCOLORSTATIC:
    {
        HDC hdc = (HDC)wp;
        SetTextColor(hdc, RGB(255, 0, 0));
        SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
        return (LRESULT)GetSysColorBrush(COLOR_BTNFACE);
    }

    case WM_INITDIALOG:
    {
        ...
        LITEM item = { 0 };
        item.iLink = 0;
        item.mask = LIF_ITEMINDEX | LIF_STATE;
        item.state = LIS_DEFAULTCOLORS;
        item.stateMask = LIS_DEFAULTCOLORS;
        SendMessage(hsyslink, LM_SETITEM, 0, (LPARAM)&item);
        ...
        return TRUE;
    }
    ...    
    }
...
}

这篇关于更改 SysLink 控件的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆