Click here to Skip to main content
15,885,366 members
Articles / Desktop Programming / MFC
Article

CDHtmlDialog with CSS, JavaScript and images

Rate me:
Please Sign up or sign in to vote.
4.72/5 (14 votes)
28 Dec 20031 min read 220.7K   4.7K   42   13
An article on how to use CSS, JavaScript and images in resource with CDHtmlDialog in VC++ .NET

Image 1

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


Written By
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHow to make the dialog fit web pages of different sizes ? Pin
namilantu30-May-16 23:01
namilantu30-May-16 23:01 
GeneralCalling javascript function Pin
Nico Cuppen7-Mar-09 1:03
Nico Cuppen7-Mar-09 1:03 
GeneralRe: Calling javascript function Pin
TURK7-Jun-09 8:37
TURK7-Jun-09 8:37 
Generalvery good! Pin
samsong8-Oct-06 16:24
samsong8-Oct-06 16:24 
Generalrefreshing...很高兴看到中文……呵呵…… Pin
iTreeSoft26-Mar-08 3:50
iTreeSoft26-Mar-08 3:50 
GeneralRe: refreshing...很高兴看到中文……呵呵…… Pin
RickyJiao5-Oct-08 22:45
RickyJiao5-Oct-08 22:45 
GeneralAdding Flash File to Resources Pin
naumankhan1-Mar-05 23:15
naumankhan1-Mar-05 23:15 
GeneralI am preparing a new sample to use HTML page as skin. Pin
iTreeSoft21-Oct-04 4:02
iTreeSoft21-Oct-04 4:02 
GeneralIt's here Pin
iTreeSoft21-Oct-04 15:02
iTreeSoft21-Oct-04 15:02 
Dialog with HTML skin using CDHtmlDialog and SetWindowRgn[^]

Smile | :)
GeneralImage is not Adding to HTML Pin
pubududilena26-Jul-04 19:14
pubududilena26-Jul-04 19:14 
Generaltest it in plain html file first Pin
pengok29-Sep-04 21:45
pengok29-Sep-04 21:45 
GeneralCDHTMLDialog + Frameset Pin
Kene14-Jan-04 2:37
Kene14-Jan-04 2:37 
Generaltry to use DIV instead of frames. Pin
Anonymous15-Jan-04 0:47
Anonymous15-Jan-04 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.