|
|

Introduction
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?
- An HTML file composed of image, sound, GIF animation, link,...
- 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" >
</a></p>
How to create a Resource-Only DLL?
- Run VC++.
- Click New on the File menu and then choose MFC AppWizard (dll); name it "ResOnly"
- Click finish button in next step.
- In ResourceView tab right-click on the root branch.
- Choose the Import... command.
- Import your HTML file; note only the HTML file.
- Click Save All on the File menu and then close VC++.
- Go to the folder that contains HTML file and all its needed files and copy all files to VC++ project folder (ResOnly).
- 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"
BG.gif HTML DISCARDABLE "BG.gif"
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"
WMPAUD7.WAV HTML DISCARDABLE "WMPAUD7.WAV"
pupil.gif HTML DISCARDABLE "pupil.gif"
whites.gif HTML DISCARDABLE "whites.gif"
////////////////////
- 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?
- Run VC++.
- Choose New on the File menu and then choose MFC AppWizard (exe).
- In step1 dialogbox, select Single document and press next button till step6. Now you choose
CHtmlView as Base Class; then press Finish button.
- Open
CHtmlView derived class; in my project "CShowcaseView".
- In
OnInitialUpdate() member function, instead of default parameter of Navigate2 type give: res:
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:".
- In ClassView panel, right-click on the C...View (e.g.
CShowcaseView) and select Add Virtual Function... command.
- 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.
- 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 www.pishro-narmafzar.com
| You must Sign In to use this message board. |
|
| | Msgs 1 to 19 of 19 (Total in Forum: 19) (Refresh) | FirstPrevNext |
|
|
 |
|
|
Hi I am relatively new at DLL programming, but I have seen/done importing a MFC DLL into a .NET application, by creating a wrapper. I now wanted to go the other way...
Given my .NET DLL (a VB.DLL) how do I use it in MFC?
Thanks.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
The steps to be followed and given are very poor and incomplete. Please give proper guidance and mention all the steps, including all the ones missing above.
Regards, Kunal
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi.....
I'm from Viet Nam. I'm studying about DLL. I make a dll with its form inside. And in my main form, when user press an button, i explicit load and show the form of DLL (depend on dll, we'll have many diffirence interfaces )...
But, I don't know how to make it in VC++ . Do I make wrong ideas??? Can you help me??? And if you can, please give me with a project . Thanks first.
((( SORRY WITH MY ENGISH )))
Odin_vn
|
| Sign In·View Thread·PermaLink | 1.00/5 (3 votes) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
I have a problem that when click an "execute" button, the MessageBox appear normally. But when I click OK, the main frame does not fresh and has a blank space on it ! How can I solve this problem ? Thanks !
Hello World
|
| Sign In·View Thread·PermaLink | 1.75/5 (3 votes) |
|
|
|
 |
|
|
Im trying to get this swift file url: http://www.capitalprophetrecords.com/downloads/be_easy.swf to become embedded in my web page so it starts as soon as people visit my site. thanks
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
I would like to know if it is possible to embed swf files into a dll. I tried the format you specified but cannot get it to work. Would appreciate it a lot if u could reply to this.
Thanks
|
| Sign In·View Thread·PermaLink | 2.00/5 (2 votes) |
|
|
|
 |
|
|
Hi, I solved my problem but: I want to know can I put a file in my resource list after releasing the app? Cheers, MILAD.
Every new thing you learn,Gives you a new personality.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
salam, Kheili manoon az emailetoon, kary ke man mikham bekonam ine: man 2 ta DLL daram va yek file exe, dar yeki az dll ha (res.dll) tamame resource ham mesle Dialogha,Bitmapha va ... ast, Dar oon yeki dll tamame codeha hastan ke be in dialog rabt daran va file EXE vazifeie rabt dadane anasore dll aval ro ba dovomi dare, Har 2 dll ham az noe ATL mibashand. Lotfan agar mitoonin komak konin. Har nazary bedin mipaziram,
Cheers, MILAD. G.K.Z
|
| Sign In·View Thread·PermaLink | 1.00/5 (4 votes) |
|
|
|
 |
|
|
Hi Dear MILAD I dont know exactly about your project but i guess that will be benefical below solution : This code read resources from another dll file
Example code :
BOOL CMyApp::InitInstance()// Exe File {
HINSTANCE hRes = NULL; hRes= LoadLibrary("Res.dll"); if(hRes) AfxSetResourceHandle(hRes); return CWinApp::InitInstance(); }
Best Regards M.Komeily Managing Director Pishro Narmafzar director@pishro-narmafzar.com www.pishro-narmafzar.com

|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
|
Hi, I am very glad that I see another Iranian in the codeproject. And I have some problems here, I you can help me about resource-only dlls please send me an e-mail. It is very importatnt. Thanks.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
You probably forgot to mention that to build Resource only DLLs you have to specify the /NOENTRY linker option to prevent the linker from linking a reference to _main into the DLL.
In VC6 you have to add it manually. Go to Project | Settings | Select the dll project | go to Link tab | in project options add the /NOENTRY option. In VC.NET 2003 Select the dll project, go to Project | Properties | Linker | Advanced, and change the Resource Only DLL option to Yes(/NOENTRY). (I think the same applies to previous VS.NET versions)

Check MSDN link [^] and [^]
...Plug & Pray...
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
dear Dimitris thanx, it wasn't forgot, i try to omit difficulty and present my articles simpler. for this sake it omited because it don't cause problem. thanx again for your accuracy
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
it was greet. but i cant using swf file imported to my resource-only dll. how i achieve it? thanks alot
|
| Sign In·View Thread·PermaLink | 1.14/5 (4 votes) |
|
|
|
 |
|
|
hi mahmood i follow your articles and learnt DLL's with them. this one is very excellent. i hope you write more article about DLL's best regards
|
| Sign In·View Thread·PermaLink | 2.62/5 (7 votes) |
|
|
|
 |
|
|
General News Question Answer Joke Rant Admin
|