Use. net sdk creation control in C,
Download Sample project-8 Kb
Introduction
In this tutorial, I will use the. NET architecture to create a simple clock control example, which is a clock that displays the current time,
I will instruct the reader to set a second and display the number of minutes.
The highlights of this article are the key points for creating this control. You can refer to the code here. The fastest way to create a control is to copy it from here
Sample Code of a beian control:
..Program FilesNGWSSDKSamplesQuickStartwinformssamplesCsWritingControlshelloworldcontrol
Copy the directoryMyControlDirectory
..Program FilesNGWSSDKSamplesQuickStartwinformssamplesCsWritingControlsMyControl
Rename the Hellowordlcontrol file in the directory to myControl.
- Helloworldcontrol. cs-> mycontrol. cs
- Helloworldcontrol. src-> mycontrol. src
Change helloworldcontrol in the following files to myControl:
Open the console window and enter nmake all. The following two files will be created:
- MyControl.exe-The application that hosts the control
- MyControl. DLL-The actual control.
Now the basic framework code has been established. We can test it by running mycontrol.exe.
Now we can start to write our control.
Other valuable aspects in the Code are: the object is built on the stack and does not need to perform the delete operation like in C ++. The garbage in NWGS
The collection function recycles objects allocated with NEW.
For example:
{ // ... Some code SolidBrush brush = new SolidBrush(Color.White) // Scope ends... no delete operator needed for brush}
Another feature of C # changes the value of a variable when calling a function.
See the following code:
CalculatePoint(ptStart, out ptEnd,(st.wHour*5)+(st.wMinute/12), false, rc);
Note:OutParameter.
We can define it as follows:
protected void CalculatePoint(Point pStart, out Point pEnd, int nPos, bool bFlag, Rectangle rc)
Mycontrol.exe has been created. Another test control method is to run WinDes.exe and create a new C # Win32Form,
Select Edit/Add under the Library menu and select mycontrol. dll.