Problems with OnNcCreate()
-
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.
-
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.
May be you can consider using an owner drawn edit box.
-
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.
-
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.
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