Use BCB to make a control board program

zhaozj2021-02-08  237

Develop control panel programs with BCB

Not long ago, Inprise (original Borland) officially announced the Delphi version 5.0, which supports the generation of the "Control Panel Program (CPL)" framework, using it to develop CPL programs quickly and easily. So can you develop a CPL program in existing Borland C Builder 4.0? The CPL program is a modification of the dynamic link library (DLL), but the extension is .cpl, the entry function is cplapplet () instead of dllenTryPoint (), or not DLLENTRYPOINT (), otherwise can't compile). We only need to select "File | New ..." in BCB4.0 to open the Development Wizard, select "DLL" to generate a DLL framework and add a function cplapplet (). In order to quickly illustrate the problem, the author first gives a simplest example, and then you will later.

#include #include #include #pragma hdrstopuseres ("my.res"); // This is the resource file I joined, with 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 view long result = 0 in the cpl.h header; Switch (UMSG) // judges the information {CASE CPL_INIT: / / The first information, generates result = 1 when the control panel is transferred; Break; Case CPL_GETCOUNT: // The second message is generated when the control panel is transferred to the result = 1; Break; Case CPL_INQUIRE: // Third Information, generating result = 0 when the control panel query; Break; Case CPL_Newinquire: // Third information, generate mycpl = lpnewcplinfo (lparam2) when the control panel queries; // Pass the pointer in lparam2 to mycpl mycpl-> Dwsize = sizeof (newcplinfo); mycpl-> dwflags = 0; // flag variable is typically set to 0 mycpl-> dwhelpContext = 0; // Help handle is typically set to 0 mycpl-> ldata = 0; Mycp L-> Hicon = (Hicon) Loadicon (Hinstance, "Myicon"); mycpl-> szhelpfile [0] = '/ 0'; // Help file strcopy (mycpl-> szname, "BCB Control Panel Demo Program"); / / Displayed under the icon Strcopy (MyCPL-> Szinfo, "Develop your own Control Panel with BCB"); // In the Control Panel status bar, the description information result = 0; Break; Case CPL_DBLCLK: / / When the icon is double-bit, showMessage ("This is a CPL Trial"); result = 0; Break; Case CPL_Stop: // Generates Result = 1 when the user closes the programs; Break; Case CPL_EXIT: // When control When the panel is closed, the system uses freeelibrary () release result = 0; Break; Default: Break;

转载请注明原文地址:https://www.9cbs.com/read-3208.html

New Post(0)