Basic Ideas:
1. First, write a basic dynamic link library (DLL). I am talking about a DLL that is not a static interface. If you don't understand what I mean, it doesn't matter if I post a connection, learn more
Dynamic Link Library learning example: http://wiki.forum.nokia.com/index.php/%E4%BD%BF%E7%94%A8RLibrary%E5%8A%A0%E8%BD%BDDLL
Reminder: You can directly create a DLL project and change it to the same thing as in the above link example. That's what I did.
2. After writing this example, you will be half done (haha). Then you need to learn how to use resources like RSC (that is, the RSS resources we generally use ), this is basically similar to the EXE program in the GUI,
A. You can create an RSS file and a name for the recursive file in the data directory of your DLL, but do not abstract it too much.
B. What do I write in it after the creation. The Code is as follows:
In the RSS file:
# Include <Eikon. RH>
# Include <avkon. RSG>
# Include <avkon. RH>
# Include <appinfo. RH>
# Include <commondialogs. HRH> // enumerations
# Include <commondialogs. RH> // resource structures
# Include "**. rls"
These header files need to be included. You can copy these files from the EXE file.
Write the following content:
Resource rss_signature
{
}
Resource tbuf r_title_addcomp {Buf = qtn_title_addcomp ;}
Here:
# Define qtn_title_addcomp "helloworld"
In this way, the RSS file is ready.
C. We also need to write something in the MMP file to generate the RSC file, because the RSC file is actually loaded when we load it (the code will explain later)
The Code is as follows:
Sourcepath ../Data
Start resource *. RSS // the same file name as the RSS file you wrote in Data
Header
Target mreader_0xe56cc67a // here, the name can be obtained randomly, but it is not easy to mix with others. I copy the name directly from the exe.
Targetpath resource/apps
End // Resource
D. Compile and right-click the project point freeze export. If there is no err, you can search the SDK directory and you will find two RSC files, this indicates that your RSS file has generated the RSC file normally.
It's successful, huh, huh. If it is not generated, congratulations, debugging errors by yourself. Debugging errors are a very important learning process. I hope you don't get bored ..
E. If all of the above are correct, I will continue to talk about using these resources in the project. This will be different from the GUI exe program at the beginning. The difference is that when we use resources in the GUI, the system
Load it for me, but we need to load it in the DLL. I won't say much about the detailed introduction of this article, which can be found on Google or Nokia wiki. Paste the key code.
Tchar DRV = "Z ";
_ Clustering (kreourse, ": // resource // apps // mreader_0xe56cc67a.rsc ");
Dllpath. append (DRV );
Dllpath. append (kreourse );
Irscoffset = ceikonenv: static ()-> addresourcefilel (dllpath );
This is to load resources. It is generally written in the DLL entry, which means it is called when the DLL is loaded. Here, dllpath is the path of RSC, And I provide a path on the simulator. If it is on a real machine
Here, the DRV parameter needs to be changed to the drive letter you installed.
Here, the irscoffset is a tint type, which is used to uninstall this resource.
The subsequent resource usage is the same as that in the GUI. It also uses stingloader: load (resource ID );
After using the SDK, You Need To uninstall the DLL resources. The Code is as follows:
Ceikonenv: static ()-> deleteresourcefile (irscoffset );
F. Then you can use a cakninformationnote dialog box to display this resource. You can refer to the use of handlecommandl in the Appui of the GUI program.
If it is displayed, congratulations on your success. If it fails, debug... Haha
Note: If you are familiar with the above operations, you can copy the RSS recursive file of the GUI You Want To modify directly, and then comment out the section of the program icon in the RSS file, can be used directly
The deletion code is as follows:
Resource localisable_app_info r_localisable_app_info
{
Short_caption = qtn_caption_string;
Caption_and_icon =
Caption_and_icon_info
{
Caption = qtn_caption_string;
Number_of_icons = 1;
Icon_file = "// resource // apps // mreader_0xe56cc67a.mif ";
// Icon_file = "// resource // apps // mreader_0xe56cc67_aif.mbm ";
};
}
This section.
3. It is fortunate to use images in the program. This is exactly the same as in the GUI. You can copy the image directly to the DLL.
Note: although it is the same, there is still a bit uncomfortable, such as when we re-package the EXE program, these image resources are usually packaged into the directory of the UID corresponding to the private file of the exe,
However, when the DLL is installed, it does not create its own private directory, so there are some problems and you do not know where to package it. (I mean for security reasons, to avoid being modified by users.
Or other application modifications are usually stored in the private directory. If you don't consider this, you can directly package these images in any public directory, so you don't have to worry about it ).
Here are a few references (which I will handle ):
A. Add these images to the GUI program that pulls the DLL to put it in its private directory. When the DLL is loaded, access the private directory of the GUI. This method is feasible, but there is a problem in the DLL
An error occurred during the update. If image resources are updated, the entire exe program needs to be updated, which is generally not allowed.
B. Write it in another drive letter during installation. when calling the dll gui to load the DLL, write these image resources to the private directory of the GUI program.
C. In the program, define the image as an array or Buf in the form of _ L or # define to pay a variable, and then directly write these items into a file and restore them to an image during running., loading
This image
4. All these resources are finished. If you want to add view and container to the DLL, this is also simple. You can directly copy these files to the DLL, then simulate the Appui In the GUI at the DLL Interface
Call, which may not be clear. Check the Code:
Class mdllintface
{
Public:
Virtual void great (caknviewappui * aappuipoint) = 0;
Virtual void activeview () = 0;
Virtual void destory () = 0;
};
A. Create
This is a DLL interface I have defined. The first function is to initialize the view in your DLL and add them to the view server. This is the meaning of the parameters of the great function, if you have other requirements, you can
Request modification interface.
The Code is as follows:
Void hellodll: Great (caknviewappui * aappuipoint)
{
Cview * view = new (eleave) cview;
Aappuipoint-> addviewl (View );
Appuipoint = aappuipoint; // Save the UI pointer here, which will be used later
}
This also plays a role. When the DLL is started, the subsequent buttons and other events will not be handled by the DLL. You know that you have destroyed the DLL.
B. Activate
Generally, in this case, you must not only have a view for your DLL type, but also for others. Therefore, when you start your DLL, you must not only great, but also activate it, this method is often used in our GUI.
The Code is as follows:
Void hellodll: activeview ()
{
Appuipoint-> activatelocalviewl (ehello_world); // The UID of the interface, which is the same as that in the GUI.
}
C. Destroy
The destory () function is something your DLL needs to destroy at the end of the DLL,
I have written a lot. To be honest, I understand things very well and cannot describe them in words. It is a little slow for people to type. I don't want to write it. Some other things may encounter some different problems, so I need to communicate with each other at this time.
If we have brothers and sisters who want to do this, we can communicate with each other.
Make a small advertisement:
Communication Group: 81389623 (devdiv.net)
95051085 (I am the Administrator)
You can also communicate with the devdiv.net forum.
Hope mark is benevolent. Don't give me harmony... I hate it !!!