1

Topic: Why dialogue of a choice of files floats behind other windows?

Hello.
Question such: From VB6 I cause dialogue of discovery of a file (for example file Excel)
I do so:
Application. Dialogs (xlDialogOpen)
Or
fileToOpen = Application. GetOpenFilename ("Documents MSExcel (*.xls), *.xls, (*.xlsx), *.xlsx")
But a hitch that dialogues of a choice of a file float BEHIND the main form, and frequently and BEHIND all windows which are opened at present on the screen. What for nonsense? How to be?
It happens, after compilation in exe. If to launch from editor VB6 that the form of dialogue as well as it is necessary appears over remaining windows.
The forum like esteemed, but the answer and did not find.
Very much I hope for your help.

2

Re: Why dialogue of a choice of files floats behind other windows?

So it is necessary to deduce an ex-fur-tree on the foreground.
And generally, what for from VB6 to use  dialogue if it has the?

3

Re: Why dialogue of a choice of files floats behind other windows?

And  good dialogue VB6 do not show. And that worked from VBA Excel earlier and such problem did not arise, and a choice of files from VB6 I face for the first time.

4

Re: Why dialogue of a choice of files floats behind other windows?

Found here such method:
Dim WSHShell, folder
Set WSHShell = CreateObject ("Shell.application")
folder = WSHShell.browseforfolder (0, "Auai? iaiee", 0)
, But besides it is a directory choice, instead of a file.

5

Re: Why dialogue of a choice of files floats behind other windows?

And this method returns only folder name, instead of a way entirely.

6

Re: Why dialogue of a choice of files floats behind other windows?

It hesitates.

7

Re: Why dialogue of a choice of files floats behind other windows?

Antonariy wrote:

it hesitates.

I generally and thought at first smile))

8

Re: Why dialogue of a choice of files floats behind other windows?

Alexxx96;
Fasten with VB6, as a last resort skip on VB.Net.

Attribute VB_Name = "basFile"
Option Explicit
Public Declare Function CopyFile& Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long)
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (ofn As OPENFILENAME) As Boolean
Public Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (ofn As OPENFILENAME) As Boolean
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
stFilter As String
stCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
strFile As String
nMaxFile As Long
stFileTitle As String
nMaxFileTitle As Long
stInitialDir As String
strTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
stDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Public Enum OFN_FLAGS
OFN_READONLY = &H1
OFN_OVERWRITEPROMPT = &H2
OFN_HIDEREADONLY = &H4
OFN_NOCHANGEDIR = &H8
OFN_SHOWHELP = &H10
OFN_ENABLEHOOK = &H20
OFN_ENABLETEMPLATE = &H40
OFN_ENABLETEMPLATEHANDLE = &H80
OFN_NOVALIDATE = &H100
OFN_ALLOWMULTISELECT = &H200
OFN_EXTENSIONDIFFERENT = &H400
OFN_PATHMUSTEXIST = &H800
OFN_FILEMUSTEXIST = &H1000
OFN_CREATEPROMPT = &H2000
OFN_SHAREAWARE = &H4000
OFN_NOREADONLYRETURN = &H8000
OFN_NOTESTFILECREATE = &H10000
OFN_NONETWORKBUTTON = &H20000
OFN_NOLONGNAMES = &H40000
OFN_EXPLORER = &H80000
OFN_NODEREFERENCELINKS = &H100000
OFN_LONGNAMES = &H200000
End Enum
Public Function FileOpenSave (Optional ByRef flags As Long = 0&, Optional ByVal InitialDir As Variant, Optional ByVal Filter As String = vbNullString, Optional ByVal FilterIndex As Long = 1, Optional ByVal DefaultExt As String = vbNullString, Optional ByVal FileName As String = vbNullString, Optional ByVal DialogTitle As String = vbNullString, Optional ByVal hwnd As Long =-1, Optional ByVal OpenFile As Boolean = True) As String
Dim ofn As OPENFILENAME
Dim stFileName As String
Dim stFileTitle As String
Dim fResult As Boolean
' Give the dialog a caption title.
If IsMissing (InitialDir) Then InitialDir = CurDir
If (hwnd =-1) Then hwnd = 0
' Allocate string space for the returned strings.
stFileName = Left $ (FileName AND String $ (256, vbNullChar), 256)
stFileTitle = String $ (256, vbNullChar)
With ofn
.lStructSize = Len (ofn)
.hwndOwner = hwnd
.stFilter = Filter
.nFilterIndex = FilterIndex
.strFile = stFileName
.nMaxFile = Len (stFileName)
.stFileTitle = stFileTitle
.nMaxFileTitle = Len (stFileTitle)
.strTitle = DialogTitle
.flags = flags
.stDefExt = DefaultExt
.stInitialDir = InitialDir
.hInstance = 0
.stCustomFilter = String $ (255, vbNullChar)
.nMaxCustFilter = 255
.lpfnHook = 0
End With
If OpenFile Then
fResult = GetOpenFileName (ofn)
Else
fResult = GetSaveFileName (ofn)
End If
If fResult Then
flags = ofn.flags
FileOpenSave = Left $ (ofn.strFile, InStr (1, ofn.strFile, vbNullChar, vbBinaryCompare) - 1)
End If
End Function
Public Function adhFileExists (sFN) As Boolean
Dim s As String
On Error Resume Next
s = Dir (sFN, vbHidden Or vbSystem Or vbArchive Or vbReadOnly)
adhFileExists = ((Len (s)> 0) And (Err. Number = 0))
Err. Clear
End Function

9

Re: Why dialogue of a choice of files floats behind other windows?

It is such HUGE code for the sake of that what all that in VB6 to select a file? (Now it is clear why VB6 it was bent)
Anyway thanks, but I am afraid that I will not understand it.
I at all the programmer by training, simply play about sometimes VBA and VB6.
And on is easier in any way it is impossible to implement?

10

Re: Why dialogue of a choice of files floats behind other windows?

Alexxx96 wrote:

It is such HUGE code for the sake of that what all that in VB6 to select a file? (Now it is clear why VB6 it was bent)

on with ++ the code for a file choice would be same or even more, it is not clear, why with ++ was not bent.

11

Re: Why dialogue of a choice of files floats behind other windows?

Alexxx96;
Yes nothing was bent. For each task the tool.
Well also it is necessary to develop somehow, and to play about - it what for?
The code above is the code of the unit, simply throw it in the project in the form of the separate unit.
The call code about the such:

sFilter = "Batch file (*.vba)" BOTH Chr $ (0) AND "*.vba" AND Chr $ (0) AND "All Files (*. *)" AND Chr $ (0) AND "*. *" AND Chr $ (0)
sBatchFileName = FileOpenSave (OFN_OVERWRITEPROMPT, CurDir $, sFilter, ".vba", "Select Batch file",-1, True)
If sBatchFileName = "" Then Exit Function

12

Re: Why dialogue of a choice of files floats behind other windows?

Alexxx96 wrote:

Found here such method:
Dim WSHShell, folder
Set WSHShell = CreateObject ("Shell.application")
folder = WSHShell.browseforfolder (0, "Auai? iaiee", 0)
, But besides it is a directory choice, instead of a file.

it and for files, like, is suitable

Sub test ()
' Flags for the options parameter
Const BIF_returnonlyfsdirs = &H1
Const BIF_dontgobelowdomain = &H2
Const BIF_statustext = &H4
Const BIF_returnfsancestors = &H8
Const BIF_editbox = &H10
Const BIF_validate = &H20
Const BIF_browseforcomputer = &H1000
Const BIF_browseforprinter = &H2000
Const BIF_browseincludefiles = &H4000
'
Set WshShell = CreateObject ("Shell. Application")
Set oItem = WshShell. BrowseForFolder (_
&H0, "Select a file or folder to copy", _
BIF_returnonlyfsdirs +>>> BIF_browseincludefiles <<<, "C: \")
Debug. Print oItem. Self. Path
End Sub

But works somehow very strange...
From the same directory, files htm, zip, xls - selects;
And on dll, exe, cmd, bat - falls with "Method ' BrowseForFolder ' of object ' IShellDispatch5 ' failed"

13

Re: Why dialogue of a choice of files floats behind other windows?

Alexxx96 wrote:

And  good dialogue VB6

and than regular CommonDialog it is bad?

14

Re: Why dialogue of a choice of files floats behind other windows?

to by-pass;
Thanks, now understood. All earned. I think this variant really most optimal in view of the stability.
to BrowseForFolder,
Really, it appears it is possible to select also files (did not know, thanks for the help) but as it is noted work not so stablly. Though if as in my case, files Excel a variant quite working are subject to a choice only.
to Shocker. Pro;
Regular CommonDialog can and it is not bad, but how it to find? At me Visual basic portable and there such I did not find. What references should be connected that appeared CommonDialog?

15

Re: Why dialogue of a choice of files floats behind other windows?

It in components

16

Re: Why dialogue of a choice of files floats behind other windows?

Shocker. Pro;
Any more I do not remember, but unless this  will not need to be registered then if someone to transfer ?

17

Re: Why dialogue of a choice of files floats behind other windows?

by-pass;
It is necessary.

18

Re: Why dialogue of a choice of files floats behind other windows?

Shocker. Pro;
At me such in a component is not present. Probably from for that that at me portable.
Downloaded comdlg32.ocx, the component appeared, but produces an error that that with licensing (at me win 8, can with it it is connected, and can not that downloaded)
And time is clarified that this OCX on other computers should be registered still while alternatives to a variant offered, by-pass th I do not see.

19

Re: Why dialogue of a choice of files floats behind other windows?

Alexxx96;
The registration question dares simply - creation .
Another matter that if is planned to transfer a software written on VB6 on the side it is possible  additional errors at the customer. And the first impression spoiled  of any errors, it is very fraught...
I such solve testing for virtual machines, but these superfluous "" - it is necessary?
And all the same, why VB6?

20

Re: Why dialogue of a choice of files floats behind other windows?

by-pass wrote:

Alexxx96;
......
And all the same, why VB6?

Operation at me economic and consequently the main my means it Excel and VBA, and VBA and VB6 is relatives.
Only from VBA an EXE file not to make, and from VB6 to make. And exe it is necessary what someone's playful pens from adjacent departments spoiled nothing in the code. In the beginning I solved it sent a file on handling is easier-me and I processed him macroes VBA, but now to time became .
Well and except syntax  I in general of anything also do not know that: (((