Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problems with OnNcCreate()

Problems with OnNcCreate()

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestionlearning
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mspb
    wrote on last edited by
    #1

    We are changing the style of our MFC app to be the "XP Style" - mainly this was done by setting the manifest using a #pragma comment in stdafx.h. The problem we have is that edit fields created in Dialogs using the resource editor have a blue border to them, whereas dynamically-created ones have a black border. I had planned to get around this by subclassing CEdit and overriding OnNcPaint() and OnNcCreate(). The OnNcPaint() works fine - as the mouse passes over the entryfield the border colour is changed to the blue as required. However, the field is still initially created with the black border, so I had expected to also need to override OnNcCreate(): BOOL CXPEdit::OnNcCreate(LPCREATESTRUCT lpcs) { CEdit::OnNcCreate(lpcs); OnNcPaint(); return TRUE; } However this doesn't seem to work. I do have the "ON_WM_NCCREATE()" and the method is definitely called, it just doesn't repaint the border. I tried adding Invalidate() and UpdateWindow() to no avail. Any ideas? Thanks -M.

    K M D 3 Replies Last reply
    0
    • M mspb

      We are changing the style of our MFC app to be the "XP Style" - mainly this was done by setting the manifest using a #pragma comment in stdafx.h. The problem we have is that edit fields created in Dialogs using the resource editor have a blue border to them, whereas dynamically-created ones have a black border. I had planned to get around this by subclassing CEdit and overriding OnNcPaint() and OnNcCreate(). The OnNcPaint() works fine - as the mouse passes over the entryfield the border colour is changed to the blue as required. However, the field is still initially created with the black border, so I had expected to also need to override OnNcCreate(): BOOL CXPEdit::OnNcCreate(LPCREATESTRUCT lpcs) { CEdit::OnNcCreate(lpcs); OnNcPaint(); return TRUE; } However this doesn't seem to work. I do have the "ON_WM_NCCREATE()" and the method is definitely called, it just doesn't repaint the border. I tried adding Invalidate() and UpdateWindow() to no avail. Any ideas? Thanks -M.

      K Offline
      K Offline
      KingsGambit
      wrote on last edited by
      #2

      May be you can consider using an owner drawn edit box.

      1 Reply Last reply
      0
      • M mspb

        We are changing the style of our MFC app to be the "XP Style" - mainly this was done by setting the manifest using a #pragma comment in stdafx.h. The problem we have is that edit fields created in Dialogs using the resource editor have a blue border to them, whereas dynamically-created ones have a black border. I had planned to get around this by subclassing CEdit and overriding OnNcPaint() and OnNcCreate(). The OnNcPaint() works fine - as the mouse passes over the entryfield the border colour is changed to the blue as required. However, the field is still initially created with the black border, so I had expected to also need to override OnNcCreate(): BOOL CXPEdit::OnNcCreate(LPCREATESTRUCT lpcs) { CEdit::OnNcCreate(lpcs); OnNcPaint(); return TRUE; } However this doesn't seem to work. I do have the "ON_WM_NCCREATE()" and the method is definitely called, it just doesn't repaint the border. I tried adding Invalidate() and UpdateWindow() to no avail. Any ideas? Thanks -M.

        M Offline
        M Offline
        mspb
        wrote on last edited by
        #3

        Well I've managed to get around the problem as I got the dynamic edit control to draw the same by adding the ClientEdge extended style and removing the border. However, it doesn't explain the problem above still!

        1 Reply Last reply
        0
        • M mspb

          We are changing the style of our MFC app to be the "XP Style" - mainly this was done by setting the manifest using a #pragma comment in stdafx.h. The problem we have is that edit fields created in Dialogs using the resource editor have a blue border to them, whereas dynamically-created ones have a black border. I had planned to get around this by subclassing CEdit and overriding OnNcPaint() and OnNcCreate(). The OnNcPaint() works fine - as the mouse passes over the entryfield the border colour is changed to the blue as required. However, the field is still initially created with the black border, so I had expected to also need to override OnNcCreate(): BOOL CXPEdit::OnNcCreate(LPCREATESTRUCT lpcs) { CEdit::OnNcCreate(lpcs); OnNcPaint(); return TRUE; } However this doesn't seem to work. I do have the "ON_WM_NCCREATE()" and the method is definitely called, it just doesn't repaint the border. I tried adding Invalidate() and UpdateWindow() to no avail. Any ideas? Thanks -M.

          D Offline
          D Offline
          Damir Valiulin
          wrote on last edited by
          #4

          That's weird... Try calling: // pWnd -> handle to edit control pWnd->SendMessage(WM_THEMECHANGED, 0, 0); pWnd->SendMessage(WM_NCPAINT, 0, 0); after you create those edit controls dinamically

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups