| |||||
|
|
Hi all, Today we will look at something called as Control Panel Applets. We all must have used the control panel hundreds of times. The icons shown in the control panel are called as Control Panel Applets. These are nothing but simple Win32 DLL's renamed to .cpl extension and exporting just one single function always named as CPlApplet. These DLLs need to be present in the system32 folder of Windows installation for the control panel to pick them up. When control panel starts, it looks for all the .cpl extension files in this folder. It loads them one by one and retrieves the function pointer to CPlApplet exported function. Once this is done, the control panel calls the CPlApplet function passing it different messages. For example after loading the dll, control panel calls this function with CPL_INIT message, when user double clicks a control panel applet, the control panel calls the message passing CPL_DBLCLK message and so on. All the messages have some associated data to be passed to the function. You can lookup the declaration of this function in MSDN. MSDN also lists and describes all the control panel messages in detail. Here are the steps one should follow for developing a control panel applet.1. Write a simple win 32 application. 2. Export a function strictly named CPlApplet. There should be no name mangling etc. 3. Handle different messages in this function. Look at all the messages to be handled, in MSDN. It is not a requirement to handle all the messages, it all depends on what the control panel applet is supposed to do.4. Put the DLL in system32 folder. Many times it's a requirement of a system application to invoke a certain control panel applet programmatically. This can be done using ShellExecute() API which launches an application associated with a given file extension. For example if you call ShellExecute("open", "file.doc"...) this will launch MS Word (or any program associated with doc files) and open file.doc in it. Since cpl file extension is associated with control panel, this same API can be used to launch different control panel applets programmatically. For example, to launch display settings you will call ShellExecute("open", "desk.cpl"....) and this will launch the display properties page.Excercises: 1. Write a control panel applet which shows it's icon in control panel, and once user double clicks the icon, displays certain dialog box.2. Study different control panel messages and the CPlApplet() API documentation. 3. Study ShellExecute() function, and it's usages. This should be sufficient for this week, we will try to cover some other topic next week. Thanks, -Farooque
|