扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:mynote 来源:blog 2007年10月19日
关键字: Visual C++ 定制 标题栏
extern "C" BOOL __declspec(dllexport) InstallCallWndHook() { g_hCallWndProc = SetWindowsHookEx(WH_CALLWNDPROC, CallWndProc, AfxGetInstanceHandle(),GetCurrentThreadId()); if (NULL == g_hCallWndProc) return FALSE; else return TRUE; } |
#pragma data_seg("Shared") static HHOOK g_hCallWndProc; #pragma data_seg() |
extern "C" void __declspec(dllexport) UnInstallCallWndHook() { if (g_hCallWndProc != NULL) { UnhookWindowsHookEx(g_hCallWndProc); g_hCallWndProc = NULL; } } |
LRESULT __declspec(dllexport) CALLBACK CallWndProc( int code, // hook code WPARAM wParam, // undefined LPARAM lParam // address of structure with message data (CWPSTRUCT) ) { DWORD dwThreadID = (DWORD)wParam; LPCWPSTRUCT pCwpStruct = LPCWPSTRUCT(lParam); if (HC_ACTION == code) { if ((pCwpStruct->message == WM_MOUSEMOVE) || (pCwpStruct->message == WM_SETCURSOR) || (pCwpStruct->message == WM_NCHITTEST) || (pCwpStruct->message == WM_KICKIDLE) || (pCwpStruct->message == WM_NCMOUSEMOVE) || (pCwpStruct->message == WM_MOUSEACTIVATE) || (pCwpStruct->message > WM_USER)); else DrawFrame(pCwpStruct); } return CallNextHookEx(g_hCallWndProc, code, wParam, lParam); } |
char szClassName[128] = {0}; ::GetClassName(pCwpStruct->hwnd, szClassName, sizeof(szClassName)); if (strcmp(szClassName, "#32770") != 0) return ; |
if (bActive) hBitmap = (HBITMAP)::LoadImage(NULL, _T("active.bmp"), IMAGE_BITMAP, nWidth, nHeight, LR_LOADFROMFILE); else hBitmap = (HBITMAP)::LoadImage(NULL, _T("inactive.bmp"), IMAGE_BITMAP, nWidth, nHeight, LR_LOADFROMFILE); if (NULL == hBitmap) { DrawTitleBar(dcWin, rcNcClient, 0); } else { dcMem = ::CreateCompatibleDC(dcWin); hOldBitmap = (HBITMAP)::SelectObject(dcMem, hBitmap); ::StretchBlt(dcWin,0,0,nWidth, nHeight,dcMem,0,0,nWidth, nHeight,SRCCOPY); ::SelectObject(dcMem, hOldBitmap); ::DeleteDC(dcMem); } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者