Solved

unsupported operation was attempted

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pressing cancel button with C# UI Automation 3 70
Replacement selected text 2 62
WinWaitActive parameters 12 31
has77  challenge 9 85
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.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

825 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