窗口的蓝色标题条一般是20-30pixel的高度。我用HIDE_TITLE实际上可以将标题条隐藏。不过由于一些特殊的要求,现在不能隐藏标题条,而是要将标题条变成很小,但是仍然保留标题条。(原因是隐藏了标题条后,傻乎乎的ATI显卡竟然认为这个程序是全屏幕的应用程序,而不是windowed 程序。)因此我需要保留标题条,但是使蓝色标题条的高度变为2-3pixel高,不知道大侠有没有办法。请给个例程吧。非常感谢。
调试欢乐多
{
// TODO: Add your message handler code here and/or call default
bCalcValidRects = FALSE;
lpncsp->rgrc[0].top -= 5;
CDialog::OnNcCalcSize(bCalcValidRects, lpncsp);
}上段代码可以实现, 将标题栏的高度减小 5 PIXEL
{
CDialog::OnNcCalcSize(bCalcValidRects, lpncsp);
NCCALCSIZE_PARAMS *ncParam;
ncParam=(NCCALCSIZE_PARAMS*)lpncsp;
ncParam->rgrc[0].top=ncParam->rgrc[0].top-15; }
{
CDC *pDC=GetWindowDC();
CRect rect;
GetClientRect(&rect);
rect.bottom=rect.top+28;
DrawTitleBar(pDC,rect);
rect.DeflateRect(3,4,0,4);
if(m_csIcon.hIcon )
{
DrawIconEx(pDC->m_hDC,rect.left,rect.top,m_csIcon.hIcon,rect.Height(),rect.Height(),0,0,DI_NORMAL);
}
rect.OffsetRect(28,0);
DrawTheText(pDC,rect,m_strTitleText); //Draw the CloseBox
GetClientRect(&rect);
if(m_pBmpClose->m_hObject==NULL)
{
m_pBmpClose=new CBitmap;
m_pBmpClose->LoadBitmap(IDB_BITMAP1);//21*21
}
rect.left=rect.right-21;
rect.OffsetRect(-2,3);
m_rectClose.CopyRect(&rect);
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
MemDC.SelectObject(m_pBmpClose);
pDC->BitBlt(rect.left,rect.top,21,21,&MemDC,0,0,SRCCOPY); //First we draw the border
CRect temp;
GetClientRect(&temp);
temp.top+=28;
DrawXPBorder(pDC,temp);
}void CXPStyleDialog::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
CDialog::OnNcLButtonDown(nHitTest, point);
ScreenToClient(&point);
GetClientRect(&m_rectClose);
m_rectClose.left=m_rectClose.right-21;
m_rectClose.OffsetRect(-5,2);
if(m_rectClose.PtInRect(point))
{
SendMessage(WM_SYSCOMMAND,SC_CLOSE,MAKELPARAM(0,0));//Send message to close the dialog
return;
}
}BOOL CXPStyleDialog::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}UINT CXPStyleDialog::OnNcHitTest(CPoint point)
{
CRect rect;
GetClientRect(&rect);
rect.bottom=rect.top+28;
ScreenToClient(&point); if(rect.PtInRect(point))
return HTCAPTION;
else
return CDialog::OnNcHitTest(point);
}
你可以试试用WH_GETMESSAGE钩子,把你的代码到插入其它进程空间,然后再在那个进程挂上相应的消息钩子,比如WH_CBT钩子可以在activating, creating, destroying, minimizing, maximizing, moving, or sizing a window之前被调用,
或者改变它的的消息机制,改变它的消息流程到自已的函数中由你控制,=======一些想法,做起来可能比较麻烦!