473,383 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

getting compiler error in LoadImage in VC 8

86
Expand|Select|Wrap|Line Numbers
  1. HBITMAP patternBMP =NULL;
  2.  
  3. patternBMP = (HBITMAP)LoadImge(hInstance, "bitmap.bmp", IMAGE_BITMAP,0,0,LR_LOADFROFILE);
  4.  
  5.  
getting a compiler error
error C2664: 'LoadImageW' : cannot convert parameter 2 from 'const char [11]' to 'LPCWSTR'

but it should take an array of charecter for the name of the bitmap....it should work but it is not....don't know why!!!!1
Sep 1 '07 #1
4 3268
ayan4u
86
ok what i found is that the problem lies in the unicode feature of VS 8...
as by default UNICODE is enabled it takes LoadImage as LoadImageW instead of LoadImageA....

now i tried to check for unicode feature by
Expand|Select|Wrap|Line Numbers
  1. #ifdef UNICODE
  2. #undef UNICODE
  3. ....
  4. my code goes here
  5.  .....
  6. #endif
  7.  
but with no result.....to get the thing compiled i had to explicitly use LoadImageA
Sep 1 '07 #2
ayan4u
86
just giving a bump.....can someone help me regarding this.....
Sep 1 '07 #3
ayan4u
86
????????..no reply...
Sep 2 '07 #4
weaknessforcats
9,208 Expert Mod 8TB
This code:

HBITMAP patternBMP =NULL;

patternBMP = (HBITMAP)LoadImge(hInstance, "bitmap.bmp", IMAGE_BITMAP,0,0,LR_LOADFROFILE);
doesn't work because you are not following th rthe TCHAR mappings.

There is no function named LoadImage. There is only LoadImageA that uses a LPCSTR argument and LoadImageW that uses an LPCWTSR. LoadImage itself is a macro. It resolves to LoadImageA if you build with ASCII and resolves to LoadImageW when you build with Unicode.

You need to a) set your character set.
b) call LoadImage using a TCHAR mapping

Your code should be:

Expand|Select|Wrap|Line Numbers
  1. HBITMAP patternBMP =NULL;
  2.  
  3. patternBMP = (HBITMAP)LoadImge(hInstance, TEXT("bitmap.bmp"), IMAGE_BITMAP,0,0,LR_LOADFROFILE);
  4.  
The character set used is in your Project Properties->Congifuration Properties->General->character set in the rigtht pane.

You do not use:
#ifdef UNICODE
#undef UNICODE
....
my code goes here
.....
#endif
You should be using a _tmain() rather than a main().
Sep 2 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When...
2
by: Xzyx987X | last post by:
Sorry if this is off topic for this group, but I couln't find any place better for directing question on Windows API programming. Here's the problem, I am calling the SetDlgItemText() function to...
1
by: Jigar Mehta | last post by:
Hye friends!! Jigar Mehta from India. Currently I am loading one BMP file around 2.5 MB from the disk from my VC program and show it to its DC... But while CBitmap object tries to load it by...
0
by: Carles | last post by:
Hi, Currently, I use a cDIB class to manage all color depth DIBs. But now I would like to avoid selecting my hDIB into a DC, and process all through manipulating data directly from/through...
12
by: Premal | last post by:
Hi, I tried to make delete operator private for my class. Strangely it is giving me error if I compile that code in VC++.NET. But it compiles successfully on VC++6.o. Can anybody give me inputs...
10
by: sachinv1821 | last post by:
hi , i am Getting this Error fatal error C1189: #error : "eh.h is only for C++!" my Problem is i am Having C++ librabry and Appropriate .h file i want to Access Them is .c File Files..... to Be...
3
by: TEST | last post by:
I am saving images out from a camera to bmp using directshow. I can open these images in mspaint or any other image program without a problem. Using: HBITMAP h_Bitmap; h_Bitmap =...
5
by: RomeoPapacy | last post by:
I'm trying to write what should be a very simple program - a system tray based menu to allow me to quickly access files in a folder (for me a bunch of disc images). Unfotunately i'm stumped near...
3
by: uday1302 | last post by:
Hi Dear, Here I am trying to upload a photo. protected void LoadImage() { string UserName = Session.ToString(); byte Data = Profile.GetImageData(UserName);...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.