|
No one can help with either problem? If something is confusing, let me know!
|
|
|
|
|
I have created a form with a picturebox. How do i display a bitmap file in my system into the picturebox?
|
|
|
|
|
LoadImage will load a bmp file for you, then you'll have a HBITMAP to pass to the picture box. If you want to load other formats, you'll need GDI+ or a third party library.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
lets say i want to put the codes into class CFormView
so the codes in CFormView should be
CProjectView::CFormView()
{
strPictureName = _T("C:\\Documents and Settings\\My Documents\\Blue hills.bmp");
HBITMAP hbp = (HBITMAP)::LoadImage( NULL, strPictureName, IMAGE_BITMAP, 0, 0,
LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE );
m_Picture.SetBitmap(hbp);
}
am i correct? btw what is LoadImage? do i need to include a code for it?
|
|
|
|
|
Looks right - LoadImage is a windows API.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
but when i run the program, there is nothing in the picturebox..
Do i have to type anything to include LoadImage in the codes?
|
|
|
|
|
Again, no. If you couldn't see it, it wouldn't compile. If you step through, what does LoadImage return ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
|
|
And also you you can use of CImage class for load graphic files(bmp,jpg,...)
|
|
|
|
|
Is that in MFC ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
From the MSDN:
You can use CImage from either MFC or ATL.
|
|
|
|
|
When did that come in, was it 2005 or 2003 ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
|
how to use CImage in MFC?
|
|
|
|
|
CImage m_Image;
m_Image.Load(yourfile);
m_Image.BitBlt(GetDC()->m_hDC,0,0,640,480,0,0);
you must inlcude AtlImage.h
|
|
|
|
|
but how do i load the image into the picturebox that i have created?
Picturebox variables
CStatic m_Picture
CString m_strPictureName
|
|
|
|
|
oops.. just saw that you are using VS2003.. i am using 6.0 though
|
|
|
|
|
I forgot VC6.0 but if I remember in VC6.0 you can use of CImage(I know you can use of it but I forgot class name) and I think that header was picture.h(not sure) in VC6.0
|
|
|
|
|
After you read your file you can attach a hbitmap to your control
CStatic t;
t.SetBitmap(hbitmap);
|
|
|
|
|
|
You can use of Christian Graus answer
|
|
|
|
|
Is there a way to replace the textbox that is being used when editing a CTreeCtrl's label in place?
Thanks,
Jon
|
|
|
|
|
|
Replacing it with a combo box, a date picker (for dates), etc.
|
|
|
|