Click here to Skip to main content
6,596,602 members and growing! (20,695 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » MFC » MFC/ATL for VC++ 7     Intermediate

CDHtmlDialog with CSS, JavaScript and images

By iTreeSoft

An article on how to use CSS, JavaScript and images in resource with CDHtmlDialog in VC++ .NET
VC7, VC7.1, Windows, .NET, MFC, VS.NET2003, Dev
Posted:28 Dec 2003
Views:56,147
Bookmarked:24 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
12 votes for this article.
Popularity: 4.14 Rating: 3.84 out of 5
2 votes, 16.7%
1

2
1 vote, 8.3%
3
2 votes, 16.7%
4
7 votes, 58.3%
5

Introduction

This article shows how to use CSS, JavaScript and images in resource with CDHtmlDialog in VC++ .NET. I build this project with VC++ 7.1(VS .NET 2003), and it should also work with VC++ 7.0(VS .NET 2002).

Background

CDHtmlDialog is a new class, in MFC 7.x, that enables dialog to use HTML files as resource.

Steps

For example, if there are lines below in the raw HTML file,

<SCRIPT src="layout.js" type=text/javascript></SCRIPT>
<link type="text/css" rel="stylesheet" href="classic.css" />
<img src="showit.gif">

To use CSS files, JavaScript files and images in resource, you must convert all links in HTML file to be the resource numbers.

  • Step 1 - Add the 3 files: layout.js, classic.css and showit.gif to the resource of your VC++ 7.x project in a custom resource type named "CUS", for example.
  • Step 2 - Record the 3 resource IDs for the 3 files: IDR_CUS1, IDR_CUS2, IDR_CUS3.
  • Step 3 - Find the 3 resource numbers for the 3 IDs in resource.h
    #define IDR_CUS1                        131
    #define IDR_CUS2                        132
    #define IDR_CUS3                        133
  • Step 4 - Modify the lines in HTML file to be:
    <SCRIPT src="res:/CUS/#131" type=text/javascript></SCRIPT>
    <link type="text/css" rel="stylesheet" href="res:/CUS/#132" />
    <img src="res:/CUS/#133">

Then your HTML dialog can make use of those three files in the resource of the executable file.

:-) Good luck.

And this is my first article on CodeProject.com.

Welcome to my page iTreeSoft.

History

  • 29 Dec 2003

    • Initial release. :)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

iTreeSoft


Member

Occupation: Web Developer
Location: China China

Other popular MFC articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 12 of 12 (Total in Forum: 12) (Refresh)FirstPrevNext
GeneralCalling javascript function PinmemberNico Cuppen2:03 7 Mar '09  
GeneralRe: Calling javascript function PinmemberTURK9:37 7 Jun '09  
Generalvery good! Pinmembersamsong17:24 8 Oct '06  
Generalrefreshing...很高兴看到中文……呵呵…… PinmemberiTreeSoft4:50 26 Mar '08  
GeneralRe: refreshing...很高兴看到中文……呵呵…… PinmemberJoeJiao23:45 5 Oct '08  
GeneralAdding Flash File to Resources PinsussNauman Khan0:15 2 Mar '05  
GeneralI am preparing a new sample to use HTML page as skin. PinmemberiTreeSoft5:02 21 Oct '04  
GeneralIt's here PinmemberiTreeSoft16:02 21 Oct '04  
GeneralImage is not Adding to HTML Pinsusspubba20:14 26 Jul '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 28 Dec 2003
Editor: Nishant Sivakumar
Copyright 2003 by iTreeSoft
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project