Use third-party controls to implement QQ vertical menu in VB

xiaoxiao2021-03-06  40

Developer Network> Development Tools> Development Columns> VB> Text Download Third Party Controls This article: VerticalMenu Example: QQ is one of the software we often use. I believe that everyone is familiar with QQ. In this, I recommend a third-party control VerticalMenu that can easily achieve this similar to the QQ vertical menu in VB. Below I will tell the example (developing the environment for Visual Basic 6.0, WindowsXP) to use the method of using the VerticalMenu control development program. (1) The load of the VerticalMenu control runs Visual Basic 6.0 and create a new project. Then select "Engineering (P)" -> "Parts" in the menu to display the Parts dialog, as shown in Figure 1.

figure 1

Click the "Browse (B)" button to find the VertMenu.ocx file from the folder where the VerticalMenu control is stored, and add it to the list of available controls. Click the "OK" button to close the "Part" dialog. The VerticalMenu control appears in the toolbox. Figure 2

figure 2

(2) The setting of the common attribute of the VerticalMenu control is selected in the toolbox, put it on the new project of FORM1. Adjust the size. Figure 3

image 3

Then right click on this control. The property page dialog of VerticalMenu will pop up. Figure 4

Figure 4

⒈ Property Description: Menues Menucur: The menu number currently setting (the default number from 1) MENUSMAX: ​​Total menu Number MenuStartup: The number of menus displayed by default when the program is running MenuObjects menuCaption: The name of the current menu Menultemcur: Current setting ITEM serial number (Default number from 1) MENUIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIITEMPICTENMPICE: Current Item icon ⒉ Property specific settings First step first on the Properties page "Menues" tab Enter 3 in Menusmax, indicating that there are 3 menu clauses. After clicking the "Apply" button, the menu will become 3. They are "Menu1", "Menu2", "Menu3". Then click the MenuObjects tab, and the menu "Menu1" is renamed "The First Menu" in MenuCaption. Go back to the Menues tab, change 1 to 2 in Menucur, indicating that the second menu is currently set. Click the MenuObjects tab, and the menu "Menu2" is renamed "Second Menu" in MenuCaption. Similarly, Menu3 is also renamed. Figure 5.

Figure 5

If you set more menus, you can change each menu menu name. Set the menu, the second step is the menu item item Item under each menu. Set the Item method and the setting menu. First enter the number of Items of the current menu in the MenuItemMax under the MenuObjects tab. Here we enter 4. It can be seen that Items of the first menu immediately become 4 after clicking "Application". The number of Items under the other menu, you can enter the menu serial number you want to set before you want to enter the menu serial number below MenuCur. Each Item in each menu can be renamed and replaced with it. First, enter the item serial number (starting from 1) in the MenulTemcur in the Property Page MenuObjects tab, then go to the MenuiteMobjects tab, change the name in MenulTemCAption, click the "Browse" button next to MenuItemPicture to select the ICO icon file to change Current Item icon. Figure 6 Figure 6

(3) Write an event response code interface design, the key is that the event can be generated by clicking Each ITEM icon. Here is mainly implemented by the MenuiteMClick event provided by VerticalMenu. Write the following code in MenuItemClick. The Menunumber in the code is the first menu (starting from 1), and the menuItem represents the first few Items under the current menu. (Also starting from 1). After adding the following code, click the item icon under each menu, you can respond to the corresponding event J

Private Sub VerticalMenu1_MenuItemClick (MenuNumber As Long, MenuItem As Long) If MenuNumber = 1 Then If MenuItem = 1 Then Form2.Show If MenuItem = 2 Then MsgBox "you press b",, "VerticalMenu" If MenuItem = 3 Then MsgBox "you Press C "," VerticalMenu "if MenuItem = 4 damGBox" You press D "," VerticalMenu "end ifif MenuNumber = 2 Then if MenuItem = 1 Then Msgbox" You Press E "," VerticalMenu "End IFIF Menumber = 3 Then IF MenuItem = 1 Then Msgbox "You Press F", "VerticalMenu" end ingnd sub

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

New Post(0)