创建CFrameWnd会产生优先机会-为什么? [英] Create CFrameWnd gives first-chance exceptions--why?

查看:38
本文介绍了创建CFrameWnd会产生优先机会-为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用基于CFrameWnd的代码编写一个在可滚动窗口中绘制的简单MFC应用程序.下面的代码改编自Prosise使用MFC编程Windows",第二版,第89ff页.

I'm attempting to write a simple MFC app that draws in a scrollable window, using code based on CFrameWnd. The code below is adapted from Prosise "Programming Windows with MFC", 2nd ed, pp 89ff.

当我在调试器中运行它时,我得到了两个优先机会异常.如果我忽略这些,则窗口将按预期显示,并且可以在其中绘制.如果启用对"C ++异常"的中断,则会得到一个仅是内部"代码的堆栈,而我没有源代码.通过逐步执行代码,我发现在对CreateWindowEx的调用中CWnd :: CreateEx中发生了异常.

When I run this in the debugger, I get two first-chance exceptions. If I ignore these, the window appears as expected, and I can draw in it. If I enable break on "C++ exceptions", I get a stack which is only "internal" code, for which I do not have the source. By stepping through the code, I find that the exceptions occur in CWnd::CreateEx, in the call to CreateWindowEx.

此代码有什么问题?64位Windows 7,Visual Studio 2013更新4.这是一个调试版本x64,使用静态库中的MFC,多字节字符集和多线程调试运行时(/MTd).

What is wrong with this code? 64-bit Windows 7, Visual Studio 2013 update 4. This is a debug build, x64, using MFC in a static library, using multi-byte character set, with the multi-threaded debug runtime (/MTd).

// Viewer.h
#include <afxwin.h>

// Adapted from Prosise "Programming Windows with MFC", 2nd ed, pp 89ff.
class CViewerApp : public CWinApp
{
public:
    virtual BOOL InitInstance();

};

class CMainWindow : public CFrameWnd
{
public:
    CMainWindow();
protected:
    afx_msg void OnPaint();
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnHScroll(UINT nCode, UINT nPos, CScrollBar *pScrollBar);
    afx_msg void OnVScroll(UINT nCode, UINT nPos, CScrollBar *pScrollBar);

public:

    DECLARE_MESSAGE_MAP()
};

// Viewer.cpp: Display
#include <afxwin.h>
#include "Viewer.h"

CViewerApp myApp;

BOOL CViewerApp::InitInstance()
{
    m_pMainWnd = new CMainWindow;
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();

    return TRUE;
}
BEGIN_MESSAGE_MAP(CMainWindow, CFrameWnd)
    ON_WM_CREATE()
    ON_WM_SIZE()
    ON_WM_PAINT()
    ON_WM_HSCROLL()
    ON_WM_VSCROLL()
END_MESSAGE_MAP()

CMainWindow::CMainWindow()
{
    Create(NULL, "Viewer", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL | WS_MAXIMIZE);
}

int CMainWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if(CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    return 0;
}

void CMainWindow::OnPaint()
{
}

void CMainWindow::OnSize(UINT nType, int cx, int cy)
{
    //TO DO
}
void CMainWindow::OnHScroll(UINT nCode, UINT nPos, CScrollBar *pScrollBar)
{
}

void CMainWindow::OnVScroll(UINT nCode, UINT nPos, CScrollBar *pScrollBar)
{
}

推荐答案

由于@IInspectable和@David Ching的有用建议,我得以找到问题的原因.这是一个名为"Premier Voice"的软件,该软件最近在我不知情的情况下安装.

Thanks to the useful suggestions from @IInspectable and @David Ching, I was able to track down the cause of the problem. It was a piece of software called "Premier Voice", which was installed recently without my knowledge.

我使用Process Explorer跟踪pmls64.dll的使用情况,并使用Task Manager和自动运行程序来查找可执行文件.该程序安装在Programs(x86)自己的文件夹中,并且进行了卸载,这是我使用的.然后,我不得不手动删除Programs(x86)中的文件夹,并删除几个注册表项.

I used Process Explorer to trace the usage of pmls64.dll, and Task Manager and autoruns to locate the executables. The program was installed in Programs(x86) in its own folder, and had an uninstall, which I used. I then had to manually delete the folder in Programs(x86), and delete several registry keys.

此外,该程序在Firefox上安装了一个插件(同样未经许可),我必须手动将其删除.

In addition, this program installed an add-on to Firefox (again without permission), which I had to remove manually.

除了在我自己的软件中引起的异常外,我怀疑Premier Voice是今天弹出的一个窗口,询问我该计算机的每个用户的出生日期和性别.

Besides the exceptions it was causing in my own software, I suspect Premier Voice was what popped up a window today asking me for the date of birth and gender of each user of this computer.

这篇关于创建CFrameWnd会产生优先机会-为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆