From: Ivar on
Hi all.

Yes I am using good ol VB6.
Can anyone do this and see if you get the same result.
The example taken straight from AllAPI example of bringing up the open\save
dialog box.
I create a little exe and run it on Winders XP and Vista and all works as
expected. But if I run the exe on my Winders 7 64bit machine where VB6 is
not installed the program goes straight to the msgbox saying cancelled was
pressed.
Is this a Winders 7 issue or a 64 bit issue.
Any suggestion for a work around
AllAPI Example Code Below
Thanks
Ivar

Option Explicit

Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private 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

Private Sub Command1_Click()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam(a)Allapi.net
Dim OFName As OPENFILENAME
OFName.lStructSize = Len(OFName)
'Set the parent window
OFName.hwndOwner = Me.hWnd
'Set the application's instance
OFName.hInstance = App.hInstance
'Select a filter
OFName.lpstrFilter = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0)
+ "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
'create a buffer for the file
OFName.lpstrFile = Space$(254)
'set the maximum length of a returned file
OFName.nMaxFile = 255
'Create a buffer for the file title
OFName.lpstrFileTitle = Space$(254)
'Set the maximum length of a returned file title
OFName.nMaxFileTitle = 255
'Set the initial directory
OFName.lpstrInitialDir = "C:\"
'Set the title
OFName.lpstrTitle = "Open File - KPD-Team 1998"
'No flags
OFName.flags = 0

'Show the 'Open File'-dialog
If GetOpenFileName(OFName) Then
MsgBox "File to Open: " + Trim$(OFName.lpstrFile)
Else
MsgBox "Cancel was pressed"
End If
End Sub

From: Dee Earley on
On 16/02/2010 11:35, Ivar wrote:
> Hi all.
>
> Yes I am using good ol VB6.
> Can anyone do this and see if you get the same result.
> The example taken straight from AllAPI example of bringing up the
> open\save dialog box.
> I create a little exe and run it on Winders XP and Vista and all works
> as expected. But if I run the exe on my Winders 7 64bit machine where
> VB6 is not installed the program goes straight to the msgbox saying
> cancelled was pressed.

It won't always appear if the initial dir is inaccessible.
Try checking Err.LastDllError to see why it failed.

--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems
From: Ivar on
Done a bit more digging
CommDlgExtendedError returns 2, = CDERR_INITIAZATION
According to MSDN CDERR_INITIAZATION =
The common dialog function failed during initialization. This error often
occurs when sufficient memory is not available.
Can anyone else duplicate this.

Ivar


From: MikeD on


"Ivar" <ivar.ekstrome000r(a)ntlworld.com> wrote in message
news:OqxJ1wvrKHA.5356(a)TK2MSFTNGP02.phx.gbl...
> Hi all.
>
> Yes I am using good ol VB6.
> Can anyone do this and see if you get the same result.
> The example taken straight from AllAPI example of bringing up the
> open\save dialog box.
> I create a little exe and run it on Winders XP and Vista and all works as
> expected. But if I run the exe on my Winders 7 64bit machine where VB6 is
> not installed the program goes straight to the msgbox saying cancelled was
> pressed.
> Is this a Winders 7 issue or a 64 bit issue.
> Any suggestion for a work around
> AllAPI Example Code Below
> Thanks
> Ivar
>


Must be something to do with your system. That code worked fine for me on
Win7 64 bit.

--
Mike


From: Ivar on
I installed VB6 on to my new machine, I click on File\Open and nothing
happens, no dialog box appears! Looks like MikeD was right, it's a Winders
thing. Anyone got any idea what I can do to fix this?
Thanks

Ivar

 |  Next  |  Last
Pages: 1 2
Prev: RIP DLLHelp
Next: Using DIR() to read a directory.