1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

doubt in handling OnNcPaint( )

Discussion in 'MFC' started by palz, Jan 21, 2010.

  1. palz

    palz New Member

    Joined:
    Jan 13, 2010
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    India
    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:
      
    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);
      ReleaseDC(dc);
    }
    
    
     
  2. Gene Poole

    Gene Poole New Member

    Joined:
    Nov 10, 2009
    Messages:
    93
    Likes Received:
    5
    Trophy Points:
    0
    Your mixing the CDC class with HDC handles and that won't work by forcing casts. Try replacing your first line with:

    Code:
      HDC dc = GetWindowDC()->m_hDC;
    
    and your last line with this:
    Code:
      ::ReleaseDC(m_hWnd,dc);
    
     
    Last edited: Jan 21, 2010
  3. palz

    palz New Member

    Joined:
    Jan 13, 2010
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    India
    thank u .its working.:)
     

Share This Page