★★如何用 HOOK 截获 LVM_SETTEXTBKCOLOR 消息(桌面图标文字背景刷新)(有代码)????
MPU 2003-09-14 04:35:02 $如何截获“截获 LVM_SETTEXTBKCOLOR 消息(桌面图标文字背景刷新)”,
写了一个桌面图标透明的程序(有代码),但桌面刷新后就又要运行程序,不爽。
估计用系统钩子搞吧。
有高手告诉一下吧!
谢谢!
!!!!!!!!!!!!!!!下面代码搞不定,有人帮忙吗!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// 桌面图标文字背景透明.cpp : Defines the entry point for the application.
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <commctrl.h>
HWND hWindow;
HHOOK g_Hook = NULL;
LRESULT CALLBACK GetMsgProc(int code,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
g_Hook = SetWindowsHookEx(WH_GETMESSAGE,GetMsgProc,hInstance,0);
MessageBox (NULL,TEXT("想截获刷新消息,使桌面图标文字透明"),TEXT("桌面图标文字透明"),MB_OK);
UnhookWindowsHookEx(g_Hook);
return 0;
}
LRESULT CALLBACK GetMsgProc(int code,WPARAM wParam,LPARAM lParam)
{
switch (code)
{
case LVM_SETTEXTBKCOLOR: //想截获的消息
//下面是"桌面图标文字背景透明"的代码!!
hWindow = FindWindow("Progman", "Program Manager");
hWindow = FindWindowEx(hWindow, 0, "SHELLDLL_DefView", "");
hWindow = FindWindowEx(hWindow, 0, "SysListView32", "");
SendMessage(hWindow, LVM_SETTEXTBKCOLOR, 0, 0xffffffff);
// Turn background to transparent
InvalidateRect(NULL, NULL, TRUE); // Repaint
break;
}
return CallNextHookEx(NULL, code, wParam, lParam);
}