Dialogs and Message Boxes in VB6
From Free Knowledge Base- The DUCK Project: information for everyone
- The FileOpen method calls VBGetOpenFileName, which calls Windows GetOpenFileName.
- The FileSaveAs method calls VBGetSaveFileName, which calls Windows GetSaveFileName.
- The FilePrint method calls VBPrintDlg, which calls Windows PrintDlg.
- The FilePageSetup method calls VBPageSetupDlg, which calls Windows PageSetupDlg.
- The OptionFont method calls VBChooseFont, which calls Windows ChooseFont.
- The OptionColor method calls VBChooseColor, which calls Windows ChooseColor.
Private Sub mnuFileOpen_Click() If edit.DirtyDialog Then edit.FileOpen dropFile.Text = edit.filename SetTextMode edit.TextMode End Sub
After checking that the current file is saved, call the FileOpen method of the XEditor object. FileOpen in turn calls VBGetOpenFileName:
Function FileOpen() As Boolean Dim f As Boolean, sFile As String, fReadOnly As Boolean f = VBGetOpenFileName( _ FileName:=sFile, _ ReadOnly:=fReadOnly, _ Filter:=FilterString, _ Owner:=hWnd) If f And sFile <> sEmpty Then TextMode = Not IsRTF(sFile) LoadFile sFile If fReadOnly Then Locked = True FileOpen = True End If End Function
Pass the result to the LoadFile method.
References
You may install the Common Dialog ActiveX Component - comdlg32.ocx - in the ToolBox or use the CDCOpenSave.cls file*
asterik * - class in S2Album