dialog box for the first time using VB, want to do a stack dialog box program.
Just want to label controls, but don't want to put controls on each page in one main control. You want to organize each page using a form or propertypage.
After a large number of experiments and csdn on the friendship of colleagues to help, slightly small into, do not dare to enjoy alone, put here, a discussion. I hope that we have a better way.
Step 1 Declares the following description
Public Declare Function setparent Lib "user32" (ByVal hwndchild as Long, ByVal hwndnewparent as long) as long
Public Declare Function SetWindowLong Lib "user32" Alias "Setwindowlonga" (ByVal hwnd as Long, ByVal nindex as Long, ByVal Dwnewlong as long) as long
Public Declare Function GetWindowLong Lib "user32" Alias "Getwindowlonga" (ByVal hwnd as Long, ByVal nindex as Long) as Lo Ng
Step 2 Place the Frame control (Fracontainer) on the main form to place the container for the stacked page
Step 3 Establish function initializepage
Private Sub initializepage (frmpage as Form, hwndparent as Long)
Dim Dwstyle as Long
SetParent Frmpage.hwnd, hWndParent
End Sub
Step 4 creates the page Form1 and Form2 that need to be toggled, modifies to no border, and changes the corresponding starting property (StartUpPosition) to Manual,left top is 0
Step 5 Establish a page initialization function
Public Sub initializepages ()
Set Frm1 = New Form1
Set Frm2 = New Form2
Initializepage Frm1, FrmMain.fraContainer.hwnd
Initializepage Frm2, FrmMain.fraContainer.hwnd
End Sub
Step 6 Create a global variable frmactive save the currently active page
Step 7 to establish a toggle page switching function
Public Sub changepage (Frmchange as Form)
If Frmchange is nothing Then Exit Sub
If not frmactive are nothing Then
If Frmactive.hwnd <> Frmchange.hwnd Then
Frmactive.hide
Frmchange.show 0, Me
Set frmactive = Frmchange
End If
Else
Frmchange.show 0, Me
Set frmactive = Frmchange
End If
End Sub
Step 8 Add the following code to the unload in the main page
Unload Frm1
Unload Frm2
Set Frm1 = Nothing
Set Frm2 = Nothing
So a code that can switch two pages is complete, but there are some questions
1. There is no corresponding handler function for each page to cut out.
2. The page has no focus.
To cut out the problem, would like to use the following way, from the form to derive a Propertyform class, and then add the onsetactive and OnKillActive functions, and then all the pages from this class generation, but do not know how to do, hehe. The function of VB is still weak point. C + + I can do whatever, VB will not have no way. :)
Hope VB Master can advise
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