|
// subclass.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
static WNDPROC oldstaticproc;
static int nCtrlID;
long __stdcall StaticProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CTLCOLORSTATIC: //WM_CTLCOLOREDIT:
if(GetDlgCtrlID((HWND)lParam) == nCtrlID)
{
//SetBkMode((HDC)wParam, TRANSPARENT);
SetBkMode((HDC)wParam, OPAQUE);
return (INT_PTR)(HBRUSH)GetStockObject(DC_BRUSH);
}
case WM_COMMAND:
if(LOWORD(wParam) == nCtrlID)
{
if(HIWORD(wParam) == EN_SETFOCUS)
{
SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(nCtrlID, EN_CHANGE),(LPARAM)GetDlgItem(hwnd, nCtrlID));
}
else if(HIWORD(wParam) == EN_KILLFOCUS)
{
SendMessage(GetDlgItem(hwnd, nCtrlID),EM_HIDEBALLOONTIP,0,0);
}
}
case WM_HELP:
LPHELPINFO lphlp = (LPHELPINFO)lParam;
if(wParam == 0 && lphlp != 0)
{
if(GetDlgCtrlID((HWND)lphlp->hItemHandle) == nCtrlID)
{
SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(nCtrlID,EN_CHANGE),(LPARAM)GetDlgItem(hwnd, nCtrlID));
}
}
}
return CallWindowProc(oldstaticproc, hwnd, msg, wParam, lParam);
}
extern "C" __declspec(dllexport) void SubClassWindowProc(HWND hWnd,int nvarCtrlID)
{
oldstaticproc = (WNDPROC)SetWindowLong(hWnd, GWL_WNDPROC, (LONG)StaticProc);
nCtrlID = nvarCtrlID;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.