Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

unsupported operation was attempted

Posted on 2002-03-23
4
Medium Priority
?
1,465 Views
Last Modified: 2013-11-20
Hi,

I am trying to load in a set of images dynamically at runtime.

I have set message box's to display the path and name of the file has it loads (for testing) and the strings are correct and relevant to the executable.

But I keep getting an: 'unsupported operation was attempted' error.

Anyone help us out?

Thanks in advance.

     CDialog::OnInitDialog();
     
     // Set image box images
     
     CString Pic = "";
     CString PicCopy = "";
     
     CString Level = "";
     CString Stage = "";
     
     Level.Format("images\\Level%d",LevelNumber);

     Stage.Format("\\Pic%d",StageNumber);

     PicCopy = Pic;

     Pic += (CString)Level + "\\Pic1.bmp";

     m_Pic1.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));
     m_Pic7.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));

     MessageBox(CString(Pic));
     
     Pic = PicCopy;

     Pic += (CString)Level + "\\Pic2.bmp";

     m_Pic2.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));
     m_Pic8.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));

     MessageBox(CString(Pic));

     Pic = PicCopy;

     Pic += (CString)Level + "\\Pic3.bmp";

     m_Pic3.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));
     m_Pic9.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));

     MessageBox(CString(Pic));

     Pic = PicCopy;

     Pic += (CString)Level + "\\Pic4.bmp";

     m_Pic4.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));
     m_Pic10.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));

     MessageBox(CString(Pic));

     Pic = PicCopy;

     Pic += (CString)Level + "\\Pic5.bmp";

     m_Pic5.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));
     m_Pic11.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));

     MessageBox(CString(Pic));

     Pic = PicCopy;

     Pic += (CString)Level + "\\Pic9.bmp";

     m_Pic6.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));
     m_Pic12.SetBitmap((HBITMAP)LoadImage(NULL,Pic,
     IMAGE_BITMAP,125,125,LR_DEFAULTCOLOR|LR_DEFAULTSIZE|LR_LOADFROMFILE|LR_CREATEDIBSECTION));

0
Comment
Question by:ukking
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
job_s earned 80 total points
ID: 6890750
I didn't get ur problem but I have one advice If U don't mind .
U r using CString call casting in many areas of this much code( actualy no need for that ).

MessageBox(CString(Pic));

pic is already a CString object so why ur using
CString(Pic) ???????



0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6890812
Where are you getting the error?
Do you get it on every run?

Also, you should use AfxMessageBox();
0
 

Author Comment

by:ukking
ID: 6890844
I found out that I had allocated a string object to something when I shouldn't of.

You can have the points
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6890849
Are you talking about the
   CString(Pic)
or something else?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question