LRESULT CALLBACK LinkButton::SubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { LinkButton *iam = (LinkButton *)GetWindowLong(hwnd, GWL_USERDATA); switch (msg) { case WM_PAINT: { PAINTSTRUCT ps; HDC dc = BeginPaint(hwnd, &ps); iam->paint(dc); EndPaint(hwnd, &ps); return 0; } case WM_LBUTTONDOWN: { iam->press(); return 0; } } // Call the original window procedure for default processing. return CallWindowProc(iam->wndproc, hwnd, msg, wParam, lParam); }