制作文件打开对话框 [英] Making a file open dialog

查看:75
本文介绍了制作文件打开对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已完成所有操作,直到浏览按钮为止.文件的路径是由浏览按钮指定的,因此在单击确定按钮时,它应显示由浏览按钮指定的图像.所以我将OK按钮的代码编写为

I have done all the things till the browse button. the path of file is given by browse button, so on clicking the ok button it should display the image that is given by browse button. so i write code for OK button as

void CFileOpenDlg::OnBnClickedButton2()
{
    CRect r;
    CBitmap* m_bitmap;
    CDC dc, *pDC;
    BITMAP bmp;

    m_bitmap = new CBitmap();
    m_bitmap->LoadBitmapW(IDB_BITMAP1);
    m_bitmap->GetBitmap(&bmp);
    pDC = this->GetDC();
    dc.CreateCompatibleDC(pDC);
    dc.SelectObject(m_bitmap);
    pDC->BitBlt(200, 200, bmp.bmWidth, bmp.bmHeight, &dc,0 , 0, SRCCOPY);
    m_bitmap->DeleteObject();
    m_bitmap->Detach()
}


我收到此错误.


I am getting this error.

error C2065:''IDB_BITMAP'' : undeclared identifier


我的错是什么? :doh:
等待您的回复...........


Wwhat''s my mistake in it? :doh:
waiting for ur reply...........

推荐答案

我认为您尚未包含包含对此内容的引用的资源文件(位图.
I think you''ve not included the resource file that includes a reference to this (poorly named) bitmap.



请确保您已了解LoadBitmap()函数的用法:LoadBitmap函数从模块的可执行文件中加载指定的位图资源.
无法从文件加载位图.
您可以使用LoadImage()而不是LoadBitmap()从外部文件加载位图资源(仅WinNT支持).或者,打开一个文件并使用CreateDIBitmap()读取它.
我认为最好的方法是使用Image类(GDI +)加载图像文件,唯一要做的就是在堆栈中分配一个Image对象(调用该对象的ctor(path)).

无论如何,参考文档是u的最好朋友,在使用之前,请先了解您想使用的任何内容.

please make sure you have understanded the usage of LoadBitmap() function: The LoadBitmap function loads the specified bitmap resource from a module''s executable file.
it CAN NOT load a bitmap from files.
u can use LoadImage() instead of LoadBitmap() to loading a bitmap resource from a external file(Only support from WinNT). Or, open a file and read it with CreateDIBitmap().
the best way i think is use the Image class(GDI+) to load a image file, the only thing need you to do is allocate a Image object in stack( call the ctor(path) of the object ).

any way, the reference document is the best friend of u, please understand any thing you want to use before you use it.


这篇关于制作文件打开对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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