Windows Control Library (Digital Clock)
| Download Source : DigitalClock |
| Creating a new Control |
|
A windows control library is like an Active X Control that you have been developing using VC++. In the VS .NET IDE environment, controls can be found by clicking the toolbox icon. Windows controls can be either UI controls like "Edit" , "Label" , "ListBox" etc (Found under the Windows Forms Tab ) or non UI controls like Timers ( found under the Components Tab).To create a control under the VS .NET IDE environment , create a new project of the type Windows Control Library.
|
|
Within the control , use the Paint event to do all the drawing. |
| private void UserControl1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { cc.Set_Time(hour , min , sec ,e.ClipRectangle ,e.Graphics, foreColor ); } |
|
A timer is used to update the current time every second and invalidate the control. |
| private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { RefreshTime(ref hour , ref min ,ref sec); Invalidate() ; } |
| Adding the control to ToolBox List |
|
Once the control is created you can add the control to the ToolBox ( Windows Forms tab ) by right clicking on the toolbox and selecting the "Customize Toolbox.. / .Net Framework Components Tab". Browse for the DLL that you have created and click OK.
|
| Using the Control |
|
The "User Control" will be added to the end of the list. Once you have added the control to the ToolBox , just drag and drop the control into the Windows Form.
You can use the property tab to set the fore color and the back color of the control. |
| Special Note : I would like to thank Nila Costin-Gabriel for his article on ActiveX control under http://www.codeproject.com. His article Digital Clock & Timer ActiveX Control has been developed using the VC++ 6.0 environment. This article is like a conversion of the VC++ article to VC#. |




30. Aug, 2006 by 

.






No comments yet... Be the first to leave a reply!