浏览图像编码错误 [英] Browse Image coding error

查看:85
本文介绍了浏览图像编码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用下面的代码..
但是当我调试..
它有此---->错误1错误结果-1从''''
返回 谁能帮忙.


Hi, i have try to use the code below..
but when i debug..
it have this ---->Error 1 Error result -1 returned from ''''
can anyone help please.


IMPLEMENT_DYNAMIC(CImageImportDlg, CFileDialog)

static char BASED_CODE szFilter[] = "Picture Files (*.jpg;*.gif;*.bmp;*.png)|*.jpg;*.gif;*.bmp;*.png|All Files (*.*)|*.*||";

void CImageImportDlg::CHookShellWnd::SetOwner(CImageImportDlg *pOwner)
{
    ASSERT(pOwner);
    ASSERT_KINDOF(CImageImportDlg, pOwner);

    m_pOwner = pOwner;
}


BOOL CImageImportDlg::CHookShellWnd::OnCommand(WPARAM /*wParam*/, LPARAM lParam)
{
    //  TRACE("wp(%d), lp(%x)\n", wParam, lParam);
    return CWnd::OnCommand(0, lParam);
}


BOOL CImageImportDlg::CHookShellWnd::OnNotify(WPARAM, LPARAM lParam, LRESULT *pResult)
{
    LPNMLISTVIEW pLVHdr = reinterpret_cast<LPNMLISTVIEW>(lParam);

    if (pLVHdr->hdr.code == LVN_ITEMCHANGED && (pLVHdr->uChanged & LVIF_STATE))
    {
        if (pLVHdr->iItem != -1)
        {
            //  It''s a valid listview index so we attach the
            //  the handle of the window that sent the message
            //  to a local CListCtrl object for easy access.
            CListCtrl     ctl;
            LPCITEMIDLIST pidl;
            TCHAR         tszBuffer[_MAX_PATH],
                          tszFileName[_MAX_PATH],
                          tszExtension[_MAX_EXT];
            CString       csTemp;

            ctl.Attach(pLVHdr->hdr.hwndFrom);
            pidl = (LPCITEMIDLIST) ctl.GetItemData(pLVHdr->iItem);
            SHGetPathFromIDList(pidl, tszBuffer);
            _tsplitpath(tszBuffer, NULL, NULL, tszFileName, tszExtension);
            csTemp.Format(_T("%s%s"), tszFileName, tszExtension);

            //  Update our parent window
            if (m_pOwner->m_nPrevSelection != pLVHdr->iItem)
                m_pOwner->UpdatePreview(csTemp);

            //  Be certain we detach the handle before the CListCtrl
            //  object goes out of scope (else the underlying List View
            //  will be deleted, which is NOT what we want).
            ctl.Detach();
        }
        else
            m_pOwner->UpdatePreview(_T(""));
    }

    return *pResult = 0;
}


CImageImportDlg::CImageImportDlg(LPCTSTR lpszDefExt, LPCTSTR lpszFileName, DWORD dwFlags, CWnd* pParentWnd) : CFileDialog(TRUE, lpszDefExt, lpszFileName, dwFlags, szFilter, pParentWnd)
{
    m_ofn.Flags |= OFN_ENABLETEMPLATE | OFN_ALLOWMULTISELECT | OFN_ENABLESIZING;
    m_ofn.hInstance = AfxGetInstanceHandle();
    m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_IMAGEPREVIEWDLG);

    //  Provide a big buffer for returned filenames
    m_ofn.lpstrFile = new TCHAR[10000];
    m_ofn.nMaxFile = 10000;
    memset(m_ofn.lpstrFile, 0, countof(m_ofn.lpstrFile));

    m_nPrevSelection = -1;
}


CImageImportDlg::~CImageImportDlg()
{
    delete m_ofn.lpstrFile;
}


BEGIN_MESSAGE_MAP(CImageImportDlg, CFileDialog)
END_MESSAGE_MAP()

INT_PTR CImageImportDlg::DoModal()
{
    INT_PTR status = CFileDialog::DoModal();

    m_preview.Close();
    return status;
}


BOOL CImageImportDlg::OnNotify(WPARAM, LPARAM lp, LRESULT *pResult)
{
    LPOFNOTIFY of = (LPOFNOTIFY) lp;
    CString    csTemp;
    TCHAR      tszBuffer[_MAX_PATH];

    switch (of->hdr.code)
    {
    case CDN_SELCHANGE:
        if (CommDlg_OpenSave_GetSpec(GetParent()->GetSafeHwnd(), tszBuffer, countof(tszBuffer)) > 0)
            TRACE("%s\n", tszBuffer);

        break;

    case CDN_FOLDERCHANGE:
        //  Once we get this notification our old subclassing of
        //  the SHELL window is lost, so we have to
        //  subclass it again. (Changing the folder causes a
        //  destroy and recreate of the SHELL window).
        if (m_wndHook.GetSafeHwnd() != HWND(NULL))
            m_wndHook.UnsubclassWindow();

        m_wndHook.SubclassWindow(GetParent()->GetDlgItem(lst2)->GetSafeHwnd());
        UpdatePreview(_T(""));
        break;
    }

    *pResult = 0;
    return FALSE;
}


void CImageImportDlg::DoDataExchange(CDataExchange *pDX)
{
    CFileDialog::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_IMAGEPREVIEW, m_preview);
    DDX_Text(pDX, IDC_PREVIEWNAME, m_csPreviewName);
}


// CImageImportDlg message handlers
BOOL CImageImportDlg::OnInitDialog()
{
    CFileDialog::OnInitDialog();

    m_preview.Create();
    m_wndHook.SetOwner(this);

    //  It''s an import dialog so change the button text on
    //  the open button to say "Import"
    GetParent()->GetDlgItem(IDOK)->SetWindowText(_T("Import"));
    GetParent()->SetWindowText(_T("Import Pictures"));
    return TRUE;
}


void CImageImportDlg::UpdatePreview(LPCTSTR szFilename)
{
    ASSERT(szFilename);
    ASSERT(AfxIsValidString(szFilename));

    m_csPreviewName = szFilename;
    m_preview.SetFilename(GetFolderPath() + _T("\\") + m_csPreviewName);
    UpdateData(FALSE);
}

推荐答案

EruEru写道:

但是当我调试时. br/> 它具有从''''返回的错误1错误结果-1

but when i debug..
it have this ---->Error 1 Error result -1 returned from ''''



无法从您的描述中猜测发生了什么.该错误在哪个程序行上发生,并且消息的全文是什么?



It is impossible to guess what is happening from your description. On which program line does this error occur and what is the full text of the message?


这篇关于浏览图像编码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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