Thread: Something to do with painting???

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    44

    Unhappy Something to do with painting???

    Hi there,

    I've got the following:

    Code:
    if(pMsgDet->message==WM_NCPAINT){
    
         //the code from http://support.microsoft.com:80/supp...NoWebContent=1 WM_NCPAINT part ONLY!
    
    }
    
    if(pMsgDet->message==WM_NCACTIVATE){
         SendMessage(pMsgDet->hwnd,WM_NCPAINT,0,0);
    }
    However, I never see the text that is meant to be shown unless I resize the window and it just reverts back to what it was...


    Anybody?

  2. #2
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Perhaps the return value for WM_NCACTIVATE isn't proper. From MSDN:

    "Return Value

    When the wParam parameter is FALSE, an application should return TRUE to indicate that the system should proceed with the default processing, or it should return FALSE to prevent the title bar or icon from being deactivated. When wParam is TRUE, the return value is ignored.
    "

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    44
    Hmm....what would I need to put to keep my text there then? I've tried it returning FALSE to make sure that the window doesn't deactivate (i.e. when my text disappears) but it just ain't working

    Thanks for the reply!

  4. #4
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    If you are drawing on the non-client area part of a window, and it is being overwritten by Windows, then Windows does not know that it is NOT supposed to handle the default action for painting in the non-client area part of the window. This is probably a result of an improper return value. Please check the return values (all of them - for WM_NCPAINT, as well). You need to tell Windows that you have handled the message, and therefore the default processing need not be run.

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    44
    Well after a bit of research and some work...I'm now subclassing the window and am using (sorry in advance for the bad formatting...):


    Code:
    LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ 
    
    	HDC hDC;
    	RECT rc1,rc2;
    	int x,y;
    
    	switch(uMsg){
       case WM_NCACTIVATE:
          if ((BOOL)wParam == FALSE)
          {
             DefWindowProc( hwnd, uMsg, wParam, lParam );
          // Add code here to draw caption when window is inactive.
    
             return TRUE;
          }
          // Fall through if wParam == TRUE, i.e., window is active.
    
          case WM_NCPAINT:
          // Let Windows do what it usually does. Let the window caption
          // be empty to avoid any Windows-initiated caption bar drawing
    
             DefWindowProc( hwnd, uMsg, wParam, lParam );
             hDC = GetWindowDC( hwnd );
             GetWindowRect( hwnd, (LPRECT)&rc2 );
    
          // Compute the caption bar's origin. This window has a system box
          // a minimize box, a maximize box, and has a resizeable frame
    
             x = GetSystemMetrics( SM_CXSIZE ) +
                 GetSystemMetrics( SM_CXBORDER ) +
                 GetSystemMetrics( SM_CXFRAME );
             y = GetSystemMetrics( SM_CYFRAME );
             rc1.left = x;
             rc1.top = y;
    
          // 2*x gives twice the bitmap+border+frame size. Since there are
          // only two bitmaps, two borders, and one frame at the end of the
          // caption bar, subtract a frame to account for this.
    
             rc1.right = rc2.right - rc2.left - 2*x -
                         GetSystemMetrics( SM_CXFRAME );
             rc1.bottom = GetSystemMetrics( SM_CYSIZE );
    
          // Render the caption. Use the active caption color as the text
          // background.
    
             SetBkColor( hDC, GetSysColor(COLOR_ACTIVECAPTION) );
             DrawText( hDC, (LPSTR)"Left Justified Caption", -1,
                     (LPRECT)&rc1, DT_LEFT );
            ReleaseDC( hwnd, hDC );
            break;
    	}
    }
    which is pulled straight from the MSDN site, but the thing is painting the text but it is not painting the rest of the
    window, which really messes up the program...any ideas?

    Thanks!
    Last edited by Unimatrix_001; 07-28-2003 at 12:02 AM.

  6. #6
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Originally posted by Unimatrix_001
    Code:
          // Add code here to draw caption when window is inactive.
    Did you add code to where the comments request it be added?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Painting
    By prongs_386 in forum Windows Programming
    Replies: 12
    Last Post: 05-04-2007, 05:07 AM
  2. mouse messages, painting, tabs
    By ZeroG in forum Windows Programming
    Replies: 0
    Last Post: 06-20-2005, 03:51 AM
  3. smoother painting
    By underthesun in forum Windows Programming
    Replies: 2
    Last Post: 01-22-2005, 03:46 AM
  4. My newest digital painting - work in progress
    By jdinger in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 07-17-2004, 08:22 PM
  5. Question about painting
    By Ariod in forum Windows Programming
    Replies: 10
    Last Post: 08-24-2003, 01:36 PM