OnNcPaint not called when dialog gains focus
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: OnNcPaint not called when dialog gains focus

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    221

    Question OnNcPaint not called when dialog gains focus

    I have an MFC dialog-based application. I have overridden the OnNcPaint method and draw some images in the non-client area of the dialog. It works just fine when, for example, some other window is in front of my dialog and that window is moved off of my dialog. But when my dialog actually gains focus, as when I click on its entry in the taskbar or click directly on my dialog, my OnNcPaint does not get called and instead it draws the default, standard images in the non-client area (i.e. the border, the title bar, etc.). How do I get it to call my overridden OnNcPaint when the dialog gains focus, so that I can assure that my painting occurs instaed of the default painting?

    - Roger Garrett

  2. #2
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863

    Re: OnNcPaint not called when dialog gains focus

    Lets see it has been a long while since I did this.

    You need to handle four messages to modify the nonclient area.

    1. WM_NCACTIVE, overide this to paint the NC area when the application is about to become inactive. just let the default occur if the dialog is becoming active.

    2. WM_NCPAINT. this is where you put the code for your active dialog nc area

    3. WM_SETTEXT. Send a WM_NCPAINT message to the dialog

    4. WM_SYSCOMMAND. Send a WM_NCPAINT message to the dialog aftier calling the default implementation.
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

  3. #3
    Join Date
    Mar 2013
    Posts
    4

    Re: OnNcPaint not called when dialog gains focus

    I developed a dialog box where it launches in full screen mode and I removed the system menu and used an image which acts like a button, when user clicks on it, it restore to normal mode. I have used OnNCPaint to draw the image on the dialog box. This works good in Windows 7 and earlier versions. But the image is not getting displayed in Window 8. Do I need to take care of anything else?

  4. #4
    Join Date
    Mar 2013
    Posts
    4

    Re: OnNcPaint not called when dialog gains focus

    *in windows 8 operating system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center