The system menu gets corrupted when a file is dropped onto a MFC MDI application in Print Preview mode (250365)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- the operating system: Microsoft Windows XP Professional
- the operating system: Microsoft Windows XP Home Edition
This article was previously published under Q250365 SYMPTOMS When you try to open a file from Windows Explorer or use a
drag-and-drop operation to move the file while the file's associated MFC MDI
application is in Print Preview mode, one of the following symptoms are
observed:
- If the child window for which Print Preview is being shown
is not maximized then the menu for the new child window is created on the top
of the Print Preview window.
- If the MDI child window is maximized and in Print Preview
mode then the two sets of the system menu and the Minimize/Maximize/Close buttons are seen.
CAUSE The application is supposed to close the print preview
window and switch to the MDI child window that was created for opening this
file. But the application is not able to switch to the associated view.
RESOLUTION One way to work around this problem is to close the Print
Preview window before creating a new window for the file being opened or
dropped. The following code shows how this can be done:
- Add the following line of code to the Stdafx.h file:
#include <afxpriv.h> - Create a handler for the WM_DROPFILES message in your CMainFrame class and copy the following code in there.
void CMainFrame::OnDropFiles(HDROP hDropInfo)
{
CView* pView = GetActiveView();
if (pView && pView->IsKindOf(RUNTIME_CLASS(CPreviewView)))
{
CPreviewView* pView = (CPreviewView *)GetActiveView();
SendMessage(WM_COMMAND, AFX_ID_PREVIEW_CLOSE);
}
CMDIFrameWnd::OnDropFiles(hDropInfo);
}
- Override the OnDDECommand virtual function in your application class and copy the following
code there:
BOOL CQ250365App::OnDDECommand(LPTSTR lpszCommand)
{
CMainFrame* pFrame = (CMainFrame *)AfxGetMainWnd();
CView* pView = pFrame->GetActiveView();
if (pView && pView->IsKindOf(RUNTIME_CLASS(CPreviewView)))
{
CPreviewView* pView = (CPreviewView *)pFrame->GetActiveView();
pFrame->SendMessage(WM_COMMAND, AFX_ID_PREVIEW_CLOSE);
}
return CWinApp::OnDDECommand(lpszCommand);
}
STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed at the beginning of this article.
REFERENCES For more information go to MSDN Help and search on
OnDropFiles and OnDDECommand.
Modification Type: | Major | Last Reviewed: | 4/28/2005 |
---|
Keywords: | kbtshoot kbprb kbGDI kbMenu kbpending kbprint KbUIDesign KB250365 kbAudDeveloper |
---|
|