' =========================================== ' Module1.BAS 【开始】 ' ------------------------------------------- Option Explicit Declare Function GetOpenFileName _ Lib "comdlg32.dll" Alias "GetOpenFileNameA" _ (pOpenfilename As OPENFILENAME) As Long Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type ' ------------------------------------------- ' Module1.BAS 【结束】 ' =========================================== ' : ' =========================================== ' 通用对话框⑴ 【开始】 ' ------------------------------------------- Option Explicit Private Sub Form_Load() Me.Width = 8000 Me.Height = 4500 Text1.Text = "" Text2.Text = "" End Sub Private Sub Form_Resize() On Error Resume Next Dim n1&, n2& n1 = Me.Width n2 = Me.Height n1 = IIf(n1 < 8000, 8000, n1) n2 = IIf(n2 < 4500, 4500, n2) Me.Width = n1 Me.Height = n2 Text1.Width = n1 - 2100 Command1.Left = n1 - 1640 Text2.Width = n1 - 660 Text2.Height = n2 - 1245 End Sub Private Sub Command1_MouseMove( _ Button As Integer, Shift As Integer, _ X As Single, Y As Single) Command1.SetFocus End Sub Private Sub Command1_Click() Dim ofn As OPENFILENAME Dim rtn As String Dim cWJ As String Dim cTS As String ofn.lStructSize = Len(ofn) ofn.hwndOwner = Me.hWnd ofn.hInstance = App.hInstance ofn.lpstrFilter = "所有文件(*.*)" ofn.lpstrFile = Space(254) ofn.nMaxFile = 255 ofn.lpstrFileTitle = Space(254) ofn.nMaxFileTitle = 255 ofn.lpstrInitialDir = App.Path ofn.lpstrTitle = "打开文件" ofn.flags = 6148 rtn = GetOpenFileName(ofn) If rtn >= 1 Then Text1.Text = ofn.lpstrFile cWJ = Trim(Text1.Text) Text2.Text = "" If Dir(cWJ, vbHidden) <> "" Then Open cWJ For Input As #1 Do While Not (EOF(1)) Line Input #1, cTS If EOF(1) Then Text2.Text = Text2.Text & cTS Else Text2.Text = Text2.Text & cTS & vbCrLf End If Loop Close #1 End If Else Text1.Text = "" End If End Sub ' ------------------------------------------- ' 通用对话框⑴ 【结束】 ' ===========================================