Solved

unsupported operation was attempted

Posted on 2002-03-23
4
1,458 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

623 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