An invalid toolbar is clicked in vb.net.

Source: Internet
Author: User


When you write a program, you will encounter problems where the existing control cannot meet the requirements. In this case, you need to use a third-party control or rewrite the existing control by yourself. I won't say much about the former. I want to find it online, in the company, and in the students. What if it is written by yourself? My experience is as follows:
1. view the requirements. Know what you want to do and what features you need to complete. Take the following code as an example: requirement-the toolbarbutton must be available. When the left-click toolbarbutton, the main program will pass certain conditions (such as whether the user follows the prescribed steps) determine whether to ignore the message. The interface should remain unchanged after the message is ignored.
2. Search for gaps. Find out the difference between the desired function and the existing control. Take the following code as an example: in the toolbar of an existing control, the button will be reflected by clicking the available toolbarbutton with the left button. The requirement is that it will not be reflected.
3. Find out how to implement the gaps of existing controls. Take the following code as an example: the toolbar does not use the onpaint method that can be rewritten during the painting process. Therefore, the onpaint method cannot be rewritten. Where can I extract the re-painting information? WndProc.
4. design the class interface. The reason why we need to rewrite the existing control is that we need to use the functions that it does not currently have, so designing the interface is very helpful for future changes. Take the following code as an example: the event parameters provided to the main program include toolbarbuttons. In the future, the main program may need to make some judgments or modify some appearances Based on the left and right keys of the mouse.
5. Start encoding. Standardize as much as possible for future modification and viewing.
The Code is as follows:
Public Class clsToolBar
Inherits ToolBar
Public Event PreviewButtonClick As PreviewButtonClickHandler
Private m_blnCanDown As Boolean = True
Private Function ZGetMouseDownButton (ByVal point As Point) As ToolBarButton
For Each _ tbtn As ToolBarButton In Me. Buttons

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.