Use. net sdk creation control in C,

Source: Internet
Author: User

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:

  • Hostapp. cs
  • Makefile

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.

Related Article

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.