VB uses a method of stacking dialog

xiaoxiao2021-03-06  36

Use VB for the first time, want to make a program of a stack dialog.

Just want to label the control, but don't want to put the controls on each page in a primary control. Want to use each page to organize.

After a large number of experiments and friendship help from Tongren on 9CBS, there is slightly small, don't exclusive, put it here, throwing bricks. I hope everyone has a better way.

STEP 1 declarations as follows

Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPublic Declare Function SetWindowLong Lib "user32" Alias ​​"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPublic Declare function GetWindowLong Lib "user32" Alias ​​"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongStep 2 placed Frame control (fraContainer) on the main form, placing the container in Step 3 establish the function of the page stack InitializePagePrivate Sub InitializePage (frmPage As Form, hWndParent As Long) Dim dwStyle As Long Load frmPage dwStyle = GetWindowLong (frmPage.hwnd, -16) dwStyle = dwStyle Or & H40000000 SetWindowLong frmPage.hwnd, -16, dwStyle SetParent frmPage.hwnd, hWndParentEnd SubStep 4 the requirement for Switching page Form1 and Form2, modify the border, and change the corresponding startup attribute to Manual, LEFT TOP is 0STEP 5 Creating Page Initial Sub INITIAALIZEPAGES () SETFRM1 = New Form1 set frm2 = new Form2 InitializePage FRM1, frmmain.fracontainer.hwnd Initialization FRM2, frmmain.fracontainer.hw ndEnd SubStep 6 frmActive page established global variable stored in the currently active page Step 7 to establish a switching function to switch Public Sub ChangePage (frmChange as Form) If frmChange Is Nothing Then Exit Sub If Not frmActive Is 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 IfEnd SubStep 8 in the adding the following code Unload Unload the Home page frm1 Unload frm2 Set frm1 = Nothing Set frm2 = Nothing such a code that can switch two pages is completed, but there are some problems, 1. There is no corresponding processing function when cutting out each page. 2. There is no focus of the page.

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

New Post(0)