Share via


Unable to add a simple BMP to a dialog box

Question

Wednesday, December 18, 2019 10:42 PM

Hi.

I have a very simple task at hand: create an app (actually I need a DLL) that pops up a dialog with a "blinking led", which means I need a white circle and a red circle to interchange according to function calls.

I started by just creating a project, and dialog box, and then I tried to add a BMP to the dialog. There are many tutorials but VS 2019 (community) does not look like any of those. I am faced with problems no matter what i try:

1. Some tutorials say to use the "Picture Box" element from the toolbox and add it into the dialog. But I only have "Picture Control" and it works differently. There is no visible way to associate a picture, except manipulating the properties. Alas, in the properties I can't see BMPs i added as resources...

2. When adding a BMP (import) it is not assigned with an ID. I don't see how I can change that. That explains #1, maybe.

3. So instead of importing, I added a BMP internally in VS and painted it. These do get IDs, but when I add them to the dialog I get a black internal box with a fixed size. The BMP is not showed in it, nothing.

4. trying to somehow get to "Picture Box" I opened the toolbox configuration. An item named "Picture box" is ticked! And I can't see "Picture Control" there... In the toolbox itself, as mentioned, I have only "Picture Control"...

Would appreciate your help.

Thanks.

All replies (5)

Thursday, December 19, 2019 4:52 AM âś…Answered

Hi sourcewielder,

Welcome to MSDN forum.

According to your description, it seems that you want to add bitmap in MFC dialog window. 

We recommend you could follow these steps to do it:

  1. right-click project -> Add -> Resource...
  2. select Bitmap -> Import, select existing bmp on your disk
  3. **modify the Bitmap ID **                                                                     
  4. drag picture control into dialog window, modify the properties of it like below

Any feedback will be expected.

Best Regards,

Dylan

MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]


Wednesday, December 18, 2019 10:55 PM

In which language ?

There are plenty of methods to load/display bitmaps

For example in .NET, it it s very simple : Loading and Displaying Bitmaps

(for blinking, you just add a timer )

In C++, LoadImage or WIC for JPG/GIF/... (How to Load a Bitmap from a Resource)


Friday, December 20, 2019 12:50 AM

Thank you for the quick response. I'll try that.


Friday, December 20, 2019 1:04 AM

Thank you for the quick response. Strangely, in the editor window the bitmap is not rendered and I see a white box (see below). Only when I "Test dialog" I can see my bitmap in place. Do you know why?

I tried to attach images but it seems my account is not yet verified, whatever that means. :-)

Thanks again.


Friday, December 20, 2019 1:14 AM

OK, doing the same thing with an imported BMP (thanks to you I know how to properly assign the ID) it works.

Thanks!