Using BCB to develop control Panel programs

Source: Internet
Author: User

Not long ago, Inprise Company (formerly Borland Company) officially announced Delphi version 5.0, its development wizards support the "Control Panel program (CPL)" framework of the generation, using it can quickly and easily develop CPL programs. Is it possible to develop CPL programs in the existing Borland C + + Builder?

A CPL program is a variant of a dynamic-link library (DLL), except that the extension is. cpl, the entry function is Cplapplet () instead of DllEntryPoint () (Not DllEntryPoint (), or not compiled). We just select "file|" in BCB4.0. New ... "Open the Development Wizard, select" DLL "to build a DLL framework, and add a function cplapplet () to it. In order to quickly explain the problem, the author first gave a simple example of the program, and then to explain.

#include <vcl.h>
#include <cpl.h>
#include <cplext.h>
#pragma hdrstop
Useres ("My.res");//This is the resource file I joined, which has an icon
extern "C" __declspec (dllexport) long CALLBACK __stdcall Cplapplet (HWND hwndcpl,uint, Umsg,lparam lparam1,lparam lParam2) ;
int WINAPI DllEntryPoint (hinstance hinst, unsigned long reason, void*)
{
return 1;
}
Long CALLBACK __declspec (dllexport) __stdcall Cplapplet (HWND hwndcpl,uint, Umsg,lparam lparam1,lparam lParam2)
{
LPNEWCPLINFO Mycpl;//lpnewcplinfo structure can be viewed in CPL.H header file
Long result=0;
Switch (UMSG)//Judge the message coming from
{
Case cpl_init://The first message that is generated when the control panel is tuned in
Result=1;
Break
Case cpl_getcount://The second message, which is generated when the control panel is tuned in
Result=1;
Break
Case cpl_inquire://The third information, when the Control Panel query is generated
result=0;
Break
Case cpl_newinquire://The third information, when the Control Panel query is generated
Mycpl=lpnewcplinfo (LPARAM2);//pass the pointer in lParam2 to MYCPL
Mycpl->dwsize=sizeof (Newcplinfo);
mycpl->dwflags=0;//flag variable is generally set to 0
mycpl->dwhelpcontext=0;//help handles are typically set to 0
mycpl->ldata=0;
mycpl->hicon= (HICON) LoadIcon (hinstance, "Myicon");
mycpl->szhelpfile[0]= ' n '/help file
Strcopy (Mycpl->szname, "BCB Control Panel Demo Program")//Description text displayed under icon
Strcopy (Mycpl->szinfo, "Develop your own Control Panel program with BCB");//description information displayed in the Control Panel status bar
result=0;
Break
Case cpl_dblclk://When the icon is double-clicked
ShowMessage ("This is a CPL test procedure");
result=0;
Break
Case cpl_stop://occurs when the user closes a program of their own
Result=1;
Break
Case cpl_exit://occurs when the control panel is closed, and the system uses FreeLibrary () to release
result=0;
Break
Default
Break
}
return result;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.