![]() |
OT: MFC related Programming Question
I want to load small bitmap images of flags and display them.
Code:
// Load bitmap file to use 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:
// Load bitmap file to use (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:
// Load bitmap file to use 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? |
I am studying GDI functions right now. If I come across anything, I will let you know.
|
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 |
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.
|
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? |
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. |
All times are GMT -5. The time now is 01:28 AM. |
Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.