Solved

unsupported operation was attempted

Posted on 2002-03-23
4
1,453 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 40 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now