void
void

Reputation: 386

get a resource path in MFC

I am trying to build HTML in my MFC application using class CHtmlEditView. So I want to add an image, currently I am using <img align=\"baseline\" alt=\"\" src=\"C:\\cry.png\" border=\"0\" hspace=\"0\"> and its working all fine.

Now, I have to replace this src=\"C:\\cry.png\" local path. So I have added this to resources and <img align=\"baseline\" alt=\"\" src=\"\\res\\smiley.png\" border=\"0\" hspace=\"0\"> its not getting image path. I am not sure how to give a path a image from resources. I have seen LoadBitmap() and LoadImage() but do know how to get a relative path of resource.

Upvotes: 1

Views: 450

Answers (1)

Andrew Komiagin
Andrew Komiagin

Reputation: 6556

Your target URL will be something like this: res://yourapplication.exe/agent.png

Please note that you will need to import your image resources just like this:

  • Go to Resource View
  • right click and select Import context menu option
  • select your image file

Please note that as the result you should have the following in your .rc file:

STARTPAGE.HTML          HTML                    "res\\startpag.htm"
AGENT.PNG               HTML                    "res\\agent.png"

Upvotes: 1

Related Questions