Click here to Skip to main content
13,297,266 members (62,350 online)
Click here to Skip to main content
Add your own
alternative version


105 bookmarked
Posted 17 Mar 2005

DLLs are Simple! Part 4

, 17 Mar 2005
Rate this:
Please Sign up or sign in to vote.
This article describes how to create a Resource-Only DLL and how to using it for creating multimedia applications.

Sample Image - pic.gif


As you know, creating multimedia applications with special effect like sound, animation, web-link and so on is time-consuming. But there is a method that is rapid and engaging.

Method is : Using Resource-Only DLL.

A resource-only DLL is a DLL that contains nothing but resources, such as icons, bitmaps, strings, and dialog boxes.

What is necessary?

  1. An HTML file composed of image, sound, GIF animation, link,...
  2. Bring the HTML file and all its needed files together in a folder.

Note: In your HTML file, create two buttons with links "exit" and "execute" like below :

<p><a hidefocuse href="execute">
<img border="0" src="ExecNorm.gif" ALT="This may execute somethings" 

style="cursor: hand; position: absolute; z-index: 1; left: 45; top: 120"

onmouseover="this.src='ExecHot.gif'" onmouseout="this.src='ExecNorm.gif'" 

width="75" height="43" >

How to create a Resource-Only DLL?

  1. Run VC++.
  2. Click New on the File menu and then choose MFC AppWizard (dll); name it "ResOnly"
  3. Click finish button in next step.
  4. In ResourceView tab right-click on the root branch.
  5. Choose the Import... command.
  6. Import your HTML file; note only the HTML file.
  7. Click Save All on the File menu and then close VC++.
  8. Go to the folder that contains HTML file and all its needed files and copy all files to VC++ project folder (ResOnly).
  9. In ResOnly project folder find .rc file and open it with notepad; point to HTML section. Now convert:
    "IDR_HTML1     HTML     DISCARDABLE     "Skin.htm"
    TO :
    "Skin.htm         HTML     DISCARDABLE     "Skin.htm"

    Then add all needed files for imported HTML just below it:

    Skin.htm HTML DISCARDABLE "Skin.htm"
    c.gif HTML DISCARDABLE "c.gif"
    ExecHot.gif HTML DISCARDABLE "ExecHot.gif"
    ExecNorm.gif HTML DISCARDABLE "ExecNorm.gif"
    ExitHot.gif HTML DISCARDABLE "ExitHot.gif"
    ExitNorm.gif HTML DISCARDABLE "ExitNorm.gif"
    pupil.gif HTML DISCARDABLE "pupil.gif"
    whites.gif HTML DISCARDABLE "whites.gif"
  10. Save and close notepad and open VC++ Project (ResOnly). Press Build button. Now you have a DLL containing resources; in fact, it is the "Resource-Only DLL".

How to use created Resource-Only DLL in multimedia App?

  1. Run VC++.
  2. Choose New on the File menu and then choose MFC AppWizard (exe).
  3. In step1 dialogbox, select Single document and press next button till step6. Now you choose CHtmlView as Base Class; then press Finish button.
  4. Open CHtmlView derived class; in my project "CShowcaseView".
  5. In OnInitialUpdate() member function, instead of default parameter of Navigate2 type give:
    res:// [Resource-Only Dll Name] // [Html file name]

    e.g. : res://ResOnly.dll//Skin.htm

    What is OnInitialUpdate()?

    This member function is called by the framework after the view is first attached to the document, but before the view is initially displayed. Here you call Navigate2 function and force view for representing Skin.htm file. By "res:", you can refer to an HTML page embedded in the resources of a dynamic-link library (.dll) file. It is a protocol like "http:".

  6. In ClassView panel, right-click on the C...View (e.g. CShowcaseView) and select Add Virtual Function... command.
  7. In related dialogbox choose OnBeforeNavigate2 and press Add and Edit button. OnBeforeNavigate2 member function is called by the framework to cause an event to fire before a navigation occurs in the web browser. By this function, we can lead web browser to the URL we want.

    OnBeforeNavigate2 have some parameters. First of all is target URL to navigate to, and end of all is a pointer to a cancel flag; an application can set this parameter to nonzero to cancel the navigation operation.

  8. Type the below code snippet after TODO comment:
    CString url=lpszURL;
    if (url.Right(4) == _T("exit"))
         *pbCancel = TRUE;
         keybd_event( VK_MENU, 0, 0, 0 );
         keybd_event( VK_F4, 0, 0, 0 );
         keybd_event( VK_F4, 0, KEYEVENTF_KEYUP, 0 );
         keybd_event( VK_MENU, 0, KEYEVENTF_KEYUP, 0 );
     else if(url.Right(7) == _T("execute"))
         *pbCancel = TRUE;
         MessageBox("This button could execute some commands.");

It is clear, it tests URL. If the last segment was "exit", it would have terminated program; but it was "execute"; it does something that you want.

Now it is ready. If you act correctly, that must be like my demo exe file.

Thankfully greet guru Paul DiLascia.

Don't remember to visit my website


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

Mahmoud Komeily
Web Developer
Iran (Islamic Republic of) Iran (Islamic Republic of)
I born in tehran at 1975
and began programming with commodore 64
I established "Pishro Narmafzar Iran" Corporation in 2001.
i'm expert in VC++, VC#, MS SQL Server, ASP .NET & have developed :
1-Persian Photoshop (fully localized)
2-Persian Freehand (fully localized)
3-Pardis (persian/arabic typing in graphical and video editing programs include : Ulead video studio,Ulead media studio,Pinnacle studio, Premiere, Flash, Freehand, 3D Max, Auto CAD, Photoshop, CorelDraw, Ulead Cool 3D,...)
Pardis is only persian/arabic typing tool for Ulead Video Studio in world.
Mahmoud komeily, mahmood komeili, محمود کمیلی

You may also be interested in...

Comments and Discussions

GeneralMy vote of 4 Pin
mengxingxia17-Sep-12 23:42
membermengxingxia17-Sep-12 23:42 
Generalopening a webpage on button click Pin
hanna besty11-May-10 3:58
memberhanna besty11-May-10 3:58 
Questionhow to press Alter + F4 programmatically in vc++ Pin
sooraj panwar14-Aug-09 4:54
membersooraj panwar14-Aug-09 4:54 
Generalhmmm ...not enough :( Pin
SumanBalakrishnan26-Jun-09 2:02
memberSumanBalakrishnan26-Jun-09 2:02 
QuestionHow to import a .NET DLL into MFC Pin
G_T12-Oct-07 1:15
memberG_T12-Oct-07 1:15 
GeneralPoor briefing and guidance Pin
kunal.tawde21-Sep-07 2:42
memberkunal.tawde21-Sep-07 2:42 
QuestionHow to Show Form of a DLL Pin
Odin_vn26-Jul-06 19:45
memberOdin_vn26-Jul-06 19:45 
AnswerRe: How to Show Form of a DLL Pin
Mahmood Komeily31-Jul-06 1:30
memberMahmood Komeily31-Jul-06 1:30 
AnswerRe: How to Show Form of a DLL Pin
john_den2-Mar-07 1:29
memberjohn_den2-Mar-07 1:29 
GeneralNice but Pin
voicoi2-Sep-05 2:45
membervoicoi2-Sep-05 2:45 
Generalswf file Pin
Anonymous29-Jul-05 6:36
sussAnonymous29-Jul-05 6:36 
Generalembedding swf files into dll Pin
bpendekanti@ag.com18-Jul-05 9:52
memberbpendekanti@ag.com18-Jul-05 9:52 
GeneralI solved my problem! Pin
dSolariuM13-Jul-05 20:28
memberdSolariuM13-Jul-05 20:28 
GeneralRe: I solved my problem! Pin
Mahmood Komeily15-Jul-05 8:48
memberMahmood Komeily15-Jul-05 8:48 
GeneralMy Question is: Pin
dSolariuM10-Jul-05 23:24
memberdSolariuM10-Jul-05 23:24 
GeneralYour answer is : Pin
Mahmood Komeily11-Jul-05 12:20
memberMahmood Komeily11-Jul-05 12:20 
GeneralI am happy. Pin
dSolariuM9-Jul-05 20:14
memberdSolariuM9-Jul-05 20:14 
GeneralUsing Resource-Only DLL in C# or VB.Net Pin
saaronny23-May-05 21:42
membersaaronny23-May-05 21:42 
GeneralOne more thing Pin
Dimitris Vassiliades23-Mar-05 21:16
memberDimitris Vassiliades23-Mar-05 21:16 
GeneralRe: One more thing Pin
Mahmood Komeily1-Apr-05 11:20
memberMahmood Komeily1-Apr-05 11:20 
GeneralDLLs are simple too efficient with your article. Pin
mike brain17-Mar-05 13:17
membermike brain17-Mar-05 13:17 
Questionhow to embed .swf files into dll's? Pin
sara jones17-Mar-05 13:01
membersara jones17-Mar-05 13:01 
Generalthis is very excellent Pin
rasen williams17-Mar-05 12:29
memberrasen williams17-Mar-05 12:29 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 17 Mar 2005
Article Copyright 2005 by Mahmoud Komeily
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid