15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


OnNcPaint question

Jean-Francois Cordier -- cordierj@chor.ucl.ac.be
Wednesday, January 24, 1996

I'm subclassing the CFrameWnd to have the title bar text left justifed and
add help in it (a la AmiPro). I found a good article on how to use
WM_NCPAINT message on MSDN. The technique used in this article is to call
the default handler (DefWndProc) and then paint the title bar ourself. The
problem is then that the title bar is drawn twice which results in flicker.
In the article, there's a workaround proposal: use ExcludeClipRect to clip
the titlebar.

1st I must say that though ClassWizard told me not to call the based class
in my OnNcPaint(), if I didn't the frame wasn't painted

2nd, I tried to use ExcludeClipRect before calling CFrameWnd::OnNcPaint but
it does work there's still a flicker (titlebar drawn twice)

void CMainWindow::OnNcPaint()
{

    CWindowDC dc(this); // Get a DC
    CRect  fillRect;    // The caption rect area

    //     [some stuff that calculates the fillRect size]
   
    dc.ExcludeClipRect(fillRect);
    
    CFrameWnd::OnNcPaint();

    CRgn rgn;
    rgn.CreateRectRgnIndirect(fillRect);
    dc.SelectClipRgn(&rgn);
    
    //  [some stuff drawing the title bar using dc and fillRect]; 
	

    // Do not call CFrameWnd ::OnNcPaint() for painting messages 

 // The above message was added by ClassWizard but I dunno why!
}

It seems ExcludeClipRect() doesn't work on the default handler! However it
works on my code because I need to re-create a Clipping Region
(SelectClipRgn) to have my code working (titlebar drawn).

How can I tell CFrameWnd::OnNcPaint() not to paint in fillRect? How can I
use ExcludeClipRect on CFrameWnd::OnNcPaint() ?

Thanks a lot for your help,

        Jean-Francois.
--------------------------------------------------------------------------
Jean-Francois Cordier (a.k.a. Dji)    Office : +32 10 47.87.58
Universite Catholique de Louvain      Home   : +32 10 45.60.18
Laboratoire ORSY                      Fax    : +32 10 47.20.48/41.68
1, pl. L. Pasteur                     WWW    : http://c227b.chor.ucl.ac.be/
1348 Louvain-la-Neuve (BELGIUM)       Email  : cordierj@chor.ucl.ac.be






Mike Blaszczak -- mikeblas@interserv.com
Saturday, January 27, 1996

On Wed, 24 Jan 1996, Jean-Francois Cordier  wrote:

>2nd, I tried to use ExcludeClipRect before calling CFrameWnd::OnNcPaint but
>it does work there's still a flicker (titlebar drawn twice)

ExcludeClipRect isn't working because you're setting up the clipping 
rectangle in the DC that you're using, not the DC that Windows ends up using.

.B ekiM
--
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");




Jean-Francois Cordier -- cordierj@chor.ucl.ac.be
Monday, January 29, 1996

At 12:56 27/01/1996 -0800, you wrote:
>On Wed, 24 Jan 1996, Jean-Francois Cordier  wrote:
>
>>2nd, I tried to use ExcludeClipRect before calling CFrameWnd::OnNcPaint but
>>it does work there's still a flicker (titlebar drawn twice)
>
>ExcludeClipRect isn't working because you're setting up the clipping 
>rectangle in the DC that you're using, not the DC that Windows ends up using.
>
Is there a way then to get the DC Windows will use?

Thanks a lot.

        Jean-Francois





| Вернуться в корень Архива |