![]() |
![]() |
#1 | ||
General Manager
Join Date: Oct 2000
Location: The Satellite of Love
|
OT: MFC related Programming Question
I want to load small bitmap images of flags and display them.
Code:
m_FlagOne and m_FlagTwo are CStatic controls. The above code works fine. I have the Afghanistan.bmp file in the same directory as the .exe (or in the same directory as the code when running from VC++) and the image loads up and displays fine. The problem comes when I do this: Code:
(The two SetBitmap lines for the static controls stayed the same) I create a subdirectory and place all of the flag images there and try to load one up. The above will not work. So I thought I had to provide the entire line, so to test it I created a directory call Flags at the C:\ and did this: Code:
And it still won't work. It would seem stupid to put 100+ flag images into the same directory as the .exe, and I don't want to have to load them all as resourses. Is there a better way to load bitmaps from file and be able to get them from a different directory? |
||
![]() |
![]() |
![]() |
#2 |
Grizzled Veteran
Join Date: Dec 2002
Location: Little Rock, AR
|
I am studying GDI functions right now. If I come across anything, I will let you know.
__________________
Xbox 360 Gamer Tag: GoldenEagle014 |
![]() |
![]() |
![]() |
#3 |
SI Games
Join Date: Oct 2000
Location: Melbourne, FL
|
I've always used my own bitmap loading/rendering functions so aren't familiar with the ones you're using I'm afraid - first thought is that some string functions expect format information after a backslash character, ie. use of "\n" as a new line character etc. ... if this is the case in LoadImage then you'll need to use:
"C:\\Flags\\" To define the directory, as if '\' is used as a format specifier the first one will be ignored by the system. No idea if this will help or not (as I indicated I haven't used that function myself) ... Marc |
![]() |
![]() |
![]() |
#4 |
General Manager
Join Date: Oct 2000
Location: The Satellite of Love
|
Nah, didn't work. I have my own class that loads bitmaps too, but I'm not sure how I would use it with the CStatic class, or any other MFC control, so I just did it the way to book said to.
|
![]() |
![]() |
![]() |
#5 |
Pro Starter
Join Date: Oct 2000
Location: Cary, NC
|
Do you care what OS you run on? Try the "CImage" class. But several functions use GDI+, so you may limit what it can run on (XP mainly).
Marc is right, you need to double-up backslashes when specifying strings, otherwise it thinks it's an escape character. What does GetLastError() say?
__________________
-- Greg -- Author of various FOF utilities |
![]() |
![]() |
![]() |
#6 |
General Manager
Join Date: Oct 2000
Location: The Satellite of Love
|
Actually, I just tried it out, and the double slash thing is working now. Thanks for the help. No idea why it didn't work the first time I tried it...probably some stupid mundane detail.
![]() Thanks guys. |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|