How much is the control panel (continued)

zhaozj2021-02-16  55

How much is the control panel (continued)

How does VCL provide support for the Control Panel?

Tell how to write the original control panel program, below I will introduce how the VCL supports writing control panel programs. It mainly introduces a CTLPANEL unit and the TappletApplication and TappletModule class. TappletApplication represents a CPL file, which represents a control panel component, with the help of these two classes, you can easily complete the control panel program encoding. Strange, how do you know, in fact, just click "Project / View Soure" to open the project source code, you can find the statement "#include " indicates that it introduces the CTLPAnel unit and continues to track the CTLPanel unit. That is to open the CTLPanel.hpp file), you will find the definition of TappletApplication and TappletModule, which is defined as follows:

Class PascalImplementation TappletApplication: PUBLIC CLASSES :: Tcomponent

{

Typedef classes :: tComponent inherited

Private:

UNSIGNED FCONTROLPANELHANDLE;

Classes :: tlist * fmodules;

. . . . . .

}

Class PascalImplementation TappletModule: PUBLIC CLASSES :: TDATAMODULE

{

Typedef classes :: tdataModule inherited

Private:

TactivateEvent fonactivate;

TSTopevent Fonstop;

. . . . . .

}

This step is not lost as a good way to learn.

Program example of a control panel under VCL support: Show your machine name

The steps are as follows:

1. Select the "file / new" option of C Builder to enable the "New Items" dialog (as shown in the figure below) Select "Control Panel Application" to establish a control panel application, the CPL file.

2. Set the icon in the property appleticon, set the title in CAPTION, such as: "Show your machine name"

1. Fill in the following code to get the machine name at the ACTIVATE event.

Void __fastcall tappletModule1 :: AppleTModuleActivate (TOBJECT * SENDER,

INT DATA

{

LPTSTR LPBUFFER = New char [256];

LPDWORD NSIZE = New Unsigned Long (256);

GetComputername (lpbuffer, nsize);

ShowMessage ("Your Computer Name:" Ansistring (LPBuffer));

DELETE LPBUFFER;

DELETE NSIZE;

}

Figure 1-2 "New Items" dialog

Tip: Select the right button in "Applet Module", you will have a shortcut menu, you can simply complete the "installation", "delete", without having to complete the compilation of the control panel program through the "Batch File" as the above example. , Test and other functions

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

New Post(0)