////////////////////////////
// An extended multi-line caption class with fixes for the Windows 95/NT caption
// overwrite 'feature' that causes a normal window caption to be drawn
// when non-client area mouse activity occurs after the system menu has been
// displayed.
//
// Author: Dave Lorde (dlorde@cix.compulink.co.uk)
//
// Copyright January 2000
//
#include "StdAfx.h"
#include "MultiLineCaptionEx.h"
#include "SuppressStyle.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNAMIC(CMultiLineCaptionEx, CMultiLineCaption);
namespace {
const int CaptionMouseClick = 0xF012;
}
CMultiLineCaptionEx::CMultiLineCaptionEx(int maxLines)
:CMultiLineCaption(maxLines)
{}
LRESULT CMultiLineCaptionEx::WindowProc(UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg)
{
case WM_SETCURSOR:
return OnSetCursor( (HWND)wp, LOWORD(lp), HIWORD(lp) );
case WM_SYSCOMMAND:
OnSysCommand(wp, lp );
return 0;
case WM_SIZE:
OnSize((UINT)wp, LOWORD(lp), HIWORD(lp));
return 0;
case WM_INITMENUPOPUP:
OnInitMenuPopup( CMenu::FromHandle((HMENU)wp), LOWORD(lp), HIWORD(lp));
return 0;
}
// I don't handle it: pass along
return CMultiLineCaption::WindowProc(msg, wp, lp);
}
void CMultiLineCaptionEx::OnSysCommand(UINT nID, LPARAM lp)
{
// I don't know why, but clicking on the caption triggers a SysCommand
// with ID 0xf12. Unless the caption is painted before handling it,
// the nasty caption line shows
if (nID == CaptionMouseClick)
PaintCaption();
Default();
}
BOOL CMultiLineCaptionEx::OnSetCursor( HWND hWnd, UINT nHitTest, UINT message )
{
LRESULT res = 0;
{
SuppressStyle ss(hWnd, WS_VISIBLE);
res = Default();
if (nHitTest != HTHSCROLL && nHitTest != HTVSCROLL && nHitTest != HTSYSMENU &&
nHitTest != HTTRANSPARENT && nHitTest != HTNOWHERE && nHitTest != HTCLIENT)
{
PaintCaption();
}
}
return res;
}
void CMultiLineCaptionEx::OnSize(UINT nType, int cx, int cy)
{
// SuppressStyle ss(m_pWndHooked->m_hWnd, WS_VISIBLE);
// Default();
CMultiLineCaption::OnSize(nType, cx, cy);
// PaintCaption();
}
void CMultiLineCaptionEx::OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu)
{
SuppressStyle ss(m_pWndHooked->m_hWnd, WS_VISIBLE);
Default();
PaintCaption();
}