Click here to Skip to main content
15,900,906 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ question Pin
Alex_Y28-Jul-06 1:57
Alex_Y28-Jul-06 1:57 
GeneralRe: C++ question Pin
Zac Howland28-Jul-06 8:58
Zac Howland28-Jul-06 8:58 
Questionfunction header = 0 Pin
Jay0327-Jul-06 8:38
Jay0327-Jul-06 8:38 
AnswerRe: function header = 0 Pin
valikac27-Jul-06 9:03
valikac27-Jul-06 9:03 
GeneralRe: function header = 0 Pin
Jay0327-Jul-06 9:04
Jay0327-Jul-06 9:04 
GeneralRe: function header = 0 Pin
Alex_Y27-Jul-06 9:15
Alex_Y27-Jul-06 9:15 
AnswerRe: function header = 0 Pin
markkuk27-Jul-06 11:42
markkuk27-Jul-06 11:42 
QuestionHow to Load Bitmap in CImageList from outside????? [modified] Pin
MacGadger27-Jul-06 8:00
MacGadger27-Jul-06 8:00 
Hello , i want to load the .BMP File of Image File in CImageList from my Hard drive , but when i load it to CImageList and reads and copy the Bitmap to a CBitmap Object the program crashes on the Run , can anyone help me in this Frown | :( , i tried to load image list this way -->>:
////////////////////////////////////////////////////
////////////////////////////////////////////
////////////////////////////////////

BOOL CXXXDlg::OnInitDialog()
{
..................
..........

// CImageList to load bitmap from Outside
CImageList m_imgList;
m_imgList.Create("C:\\xxxx.bmp" , 64 , 32, RGB(255,0,255));

//Copies the Single Frame from the Image List to CBitmap
CBitmap mBmp;
GetImageFromList(&m_imgList , 1 , &mBmp);

and

CBitmap *mBmp = new CBitmap;
GetImageFromList(&m_imgList , 1 , mBmp);

...........
.................
}

void CXXXDlg::GetImageFromList(CImageList *lstImages, int nImage,
CBitmap *destBitmap)
{

//First we want to create a temporary image list we can manipulate
CImageList tmpList;
tmpList.Create(lstImages);

//Then swap the requested image to the first spot in the list
tmpList.Copy( 0, nImage, ILCF_SWAP );

//Now we need to get som information about the image
IMAGEINFO lastImage;
tmpList.GetImageInfo(0,&lastImage);

//Heres where it gets fun
//Create a Compatible Device Context using
//the valid DC of your calling window
CDC dcMem; dcMem.CreateCompatibleDC (GetWindowDC());

//This rect simply stored the size of the image we need
CRect rect (lastImage.rcImage);

//Using the bitmap passed in, Create a bitmap
//compatible with the window DC
//We also know that the bitmap needs to be a certain size.
destBitmap->CreateCompatibleBitmap (this->GetWindowDC(),
rect.Width (), rect.Height ());

//Select the new destination bitmap into the DC we created above
CBitmap* pBmpOld = dcMem.SelectObject (destBitmap);

//This call apparently "draws" the bitmap from the list,
//onto the new destination bitmap
tmpList.DrawIndirect (&dcMem, 0, CPoint (0, 0),
CSize (rect.Width (), rect.Height ()), CPoint (0, 0));


//cleanup by reselecting the old bitmap object into the DC
dcMem.SelectObject (pBmpOld);

}

/////////////////////////////////////////////////////////
///////////////////////////////////////////////
/////////////////////////////////////////

and when i run this APP, its crashes ; please tell me whts wrong with the CODE, and tell me how to load Bitmap from the Hard Drive Frown | :( i realyy need it Frown | :(

Thnx...

-- modified at 14:02 Thursday 27th July, 2006
QuestionRe: How to Load Bitmap in CImageList from outside????? Pin
Hamid_RT27-Jul-06 22:44
Hamid_RT27-Jul-06 22:44 
QuestionMAKEWORD macro Pin
kitty527-Jul-06 7:51
kitty527-Jul-06 7:51 
AnswerRe: MAKEWORD macro Pin
toxcct27-Jul-06 7:58
toxcct27-Jul-06 7:58 
AnswerRe: MAKEWORD macro Pin
kitty527-Jul-06 8:11
kitty527-Jul-06 8:11 
QuestionMS Access and CFileDialog conflict. Pin
na.nu27-Jul-06 7:50
na.nu27-Jul-06 7:50 
QuestionRe: MS Access and CFileDialog conflict. Pin
David Crow27-Jul-06 8:15
David Crow27-Jul-06 8:15 
AnswerRe: MS Access and CFileDialog conflict. Pin
Steve S27-Jul-06 21:51
Steve S27-Jul-06 21:51 
QuestionRe: MS Access and CFileDialog conflict. Pin
na.nu3-Aug-06 6:30
na.nu3-Aug-06 6:30 
AnswerRe: MS Access and CFileDialog conflict. Pin
Steve S9-Aug-06 1:52
Steve S9-Aug-06 1:52 
QuestionOpinions wanted Pin
Wes Aday27-Jul-06 4:40
professionalWes Aday27-Jul-06 4:40 
AnswerRe: Opinions wanted Pin
David Crow27-Jul-06 4:46
David Crow27-Jul-06 4:46 
AnswerRe: Opinions wanted Pin
#realJSOP27-Jul-06 4:46
professional#realJSOP27-Jul-06 4:46 
AnswerRe: Opinions wanted Pin
toxcct27-Jul-06 4:54
toxcct27-Jul-06 4:54 
AnswerRe: Opinions wanted Pin
megaadam27-Jul-06 5:05
professionalmegaadam27-Jul-06 5:05 
AnswerRe: Opinions wanted Pin
Rob Caldecott27-Jul-06 5:25
Rob Caldecott27-Jul-06 5:25 
AnswerRe: Opinions wanted Pin
Nemanja Trifunovic27-Jul-06 5:26
Nemanja Trifunovic27-Jul-06 5:26 
GeneralRe: Opinions wanted Pin
toxcct27-Jul-06 5:36
toxcct27-Jul-06 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.