如题,MagicSet、Windows优化大师等软件实现了那样的功能,不知是怎么做到的?用SPY++看到桌面图标在一个SysListview32控件中,但是改变这个控件DC的背景模式为透明,或用Listview_setbkcolor设置为NULL,都不能实现。listview控件中图标的文字背景是如果设置的呢?我在MSDN中没找到相关内容。
另外,要考虑到活动桌面的影响。就我所知,Windows优化大师中的类似功能在开启活动桌面后有问题。
另外,要考虑到活动桌面的影响。就我所知,Windows优化大师中的类似功能在开启活动桌面后有问题。
BOOL SetBkColor( COLORREF cr );Return ValueNonzero if successful; otherwise zero.ParameterscrBackground color to set, or the CLR_NONE value for no background color. List view controls with background colors redraw themselves significantly faster than those without background colors. For information, seeCOLORREF in the Platform SDK.
#include <stdio.h>HWND GetDeskWnd()
{
HWND hWnd; hWnd = GetDesktopWindow();
if ((hWnd = FindWindowEx(hWnd, 0, "Progman", "Program Manager")) == 0)
return NULL; if ((hWnd = FindWindowEx(hWnd, 0, "SHELLDLL_DefView", NULL)) == 0)
return NULL; if ((hWnd = FindWindowEx(hWnd, 0, "SysListView32", NULL)) == 0)
return NULL;
return hWnd;
}int main(void)
{
HWND hWnd;
hWnd = GetDeskWnd();
if(hWnd)
{// Change icon text attributes
SendMessage(hWnd, 0x1026, 0, 0xffffffff); // Turn background to transparent
SendMessage(hWnd, 0x1024, 0, 0x000000ff); // Turn foregound to white InvalidateRect(hWnd, NULL, TRUE); // Repaint
}
return 0;
} // main()
0x1024 LVM_SETTEXTCOLOR
下有关于桌面背景的键值:Background,它是一个字符串,如“58 110 165”指定RGB。而图标文字背景与其相同。
每次刷新桌面时,系统将重新读取该值并得到COLORREF值来重新设置桌面图标的文字背景。问题在于CLR_NONE是0xffffffff,而从Background值得到的COLORREF值取值范围在0x00000000~0x00ffffff。所以使文字背景透明后要想刷新时仍能保持,没有一劳永逸的办法,除非crack刷新桌面时调用的函数。不然就必须定时或通过过滤消息来设置文字背景透明。
至于活动桌面的问题,还没想通。