mfcmdicwnd

In my MFC application I create a new child window. When I drag it to a new location the outline is not drawn during the drag, so n visual feedback


This is part of a large MFC application that uses the MDI architecture. It is written using Microsoft Visual Studio 2019.

I want to create a window to display the first few lines of a text file so the user can make decisions about parsing it. The new window does not fit into the overall Document/View architecture and so I have made the desktop window its parent. The window is created OK, successfully locates itself at the top left of the screen and displays the first few lines of the text file. However, when I drag it to a new location its outline is not drawn during the drag, although it ends up in the intended place, and so there is no visual feedback for the user.

Here's the code that creates the window:

CWnd *parent = GetDesktopWindow();
int w = GetSystemMetrics(SM_CXFULLSCREEN) / 3;
int h = GetSystemMetrics(SM_CYFULLSCREEN) / 4;
CString title;
title.Format("Previewing first %d lines of file", m_nPreviewLines);
// fpw is of locally defined type CFilePreviewWnd, which is derived directly from CWnd.
fpw->Create(
    AfxRegisterWndClass(CS_NOCLOSE, 0, (HBRUSH) ::GetStockObject(WHITE_BRUSH) ), 
    title,
    WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | WS_OVERLAPPEDWINDOW,
    CRect(0, 0, w, h), 
    parent, 
    ID_FILE_PREVIEW_WND);

I have played around with various combinations of the WS_ and CS_ styles without success. It seems to me that the non-client parts of the window are not being updated during the drag operation.

I assume I'm missing something basic here. Any clarification would be appreciated.


Solution

  • As I thought, quite simple really. All that was needed was to use WS_POPUPWINDOW, and CreatEx rather than Create. That way I can make the invoking dialog box the parent. Nick; thanks again for your guidance.