Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   doubt in handling OnNcPaint( ) (http://www.go4expert.com/forums/doubt-handling-onncpaint-t20727/)

palz 21Jan2010 19:04

doubt in handling OnNcPaint( )
i have tied to a rectangle in caption bar of window but this doesn't work .am i doing any mistake.plz correct me .

Code: MFC

void CMainWnd::OnNcPaint( )
    CDC dc = (CDC)GetWindowDC();
    RECT rectMine = {30,3,100,20};
    FillRect(dc, &rectMine, (HBRUSH)GetStockObject(DKGRAY_BRUSH));
    SetBkMode(dc, TRANSPARENT);
SetTextColor(dc, RGB(255, 0,0));
   DrawText(dc, "My Dialog", strlen("My Dialog"), &rectMine, 0);

Gene Poole 21Jan2010 19:42

Re: doubt in handling OnNcPaint( )
Your mixing the CDC class with HDC handles and that won't work by forcing casts. Try replacing your first line with:


  HDC dc = GetWindowDC()->m_hDC;
and your last line with this:


palz 21Jan2010 23:46

Re: doubt in handling OnNcPaint( )
thank u .its working.:)

All times are GMT +5.5. The time now is 07:09.