Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

unsupported operation was attempted

Posted on 2002-03-23
4
Medium Priority
?
1,459 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 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

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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

719 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