Solved

commondialog via api call?

Posted on 2002-06-12
6
298 Views
Last Modified: 2010-05-02
I want to create the fileopen dialog but licensing with the activex presents a problem. Got any code to share?
0
Comment
Question by:tcurtin
6 Comments
 
LVL 5

Accepted Solution

by:
rpai earned 50 total points
ID: 7073678
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 7073831
%listening
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7073896
Please maintain your open questions:
Questions Asked 19
Last 10 Grades Given B C A A A B A A A C  
Question Grading Record 12 Answers Graded / 12 Answers Received


Anthony
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 6

Expert Comment

by:xSinbad
ID: 7074288
Have a look at this code:



Type CMDLG_FILENAME
    lStructSize As Long
    hWndOwner As Long
    hInstance As Long
    lpstrsFilter As String
    lpstrCustomsFilter As String
    nMaxCustsFilter As Long
    nsFilterIndex 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

Declare Function GetOpenFileNameA Lib "COMDLG32.DLL" (tFilename As CMDLG_FILENAME) As Integer


Const CMDLG_OFN_READONLY = &H1
Const CMDLG_OFN_OVERWRITEPROMPT = &H2
Const CMDLG_OFN_HIDEREADONLY = &H4
Const CMDLG_OFN_NOCHANGEDIR = &H8
Const CMDLG_OFN_SHOWHELP = &H10
Const CMDLG_OFN_ENABLEHOOK = &H20
Const CMDLG_OFN_ENABLETEMPLATE = &H40
Const CMDLG_OFN_ENABLETEMPLATEHANDLE = &H80
Const CMDLG_OFN_NOVALIDATE = &H100
Const CMDLG_OFN_ALLOWMULTISELECT = &H200
Const CMDLG_OFN_EXTENSIONDIFFERENT = &H400
Const CMDLG_OFN_PATHMUSTEXIST = &H800
Const CMDLG_OFN_FILEMUSTEXIST = &H1000
Const CMDLG_OFN_CREATEPROMPT = &H2000
Const CMDLG_OFN_SHAREAWARE = &H4000
Const CMDLG_OFN_NOREADONLYRETURN = &H8000
Const CMDLG_OFN_NOTESTFILECREATE = &H10000

Const CMDLG_OFN_SHAREFALLTHROUGH = 2
Const CMDLG_OFN_SHARENOWARN = 1
Const CMDLG_OFN_SHAREWARN = 0

Function gsWinDlgOpen(hWnd As Long, sTitel As String, sFilter As String, sCurDir As String) As String

   Dim tFilename As CMDLG_FILENAME
   Dim sFilename As String
   Dim sFiletitel As String
   Dim sDefExt As String

   sTitel = sTitel + Chr$(0)
   sFilter = sFilter & "Alle Dateien (*.*)" & Chr$(0) & "*.*" & Chr$(0) & Chr$(0)
   sFilename = Chr$(0) & Space$(255) & Chr$(0)
   sFiletitel = Chr$(0) & Space$(255) & Chr$(0)
   sDefExt = Chr$(0)
   sCurDir = gvntNull2Arg(sCurDir, CurDir$) & Chr$(0)

   tFilename.lStructSize = Len(tFilename)
   tFilename.hWndOwner = hWnd
   tFilename.lpstrsFilter = sFilter
   tFilename.nsFilterIndex = 1
   tFilename.lpstrFile = sFilename
   tFilename.nMaxFile = Len(sFilename)
   tFilename.lpstrFileTitle = sFiletitel
   tFilename.nMaxFileTitle = Len(sFiletitel)
   tFilename.lpstrTitle = sTitel
   tFilename.Flags = CMDLG_OFN_FILEMUSTEXIST Or CMDLG_OFN_HIDEREADONLY
   tFilename.lpstrInitialDir = sCurDir

   If GetOpenFileName(tFilename) <> 0 Then
       gsWinDlgOpen = gsTrim(tFilename.lpstrFile)
   Else
       gsWinDlgOpen = ""
   End If

End Function
Function gsTrim(s As String) As String

   gsTrim = Trim$(Left$(s, InStr(1, s & Chr$(0), Chr$(0), 0) - 1))

End Function

Function gvntNull2Arg(vntExp As Variant, vntPara As Variant) As Variant

   If gbNull(vntExp) Then
       gvntNull2Arg = vntPara
   Else
       gvntNull2Arg = vntExp
   End If
End Function

Function gbNull(vnt As Variant) As Integer

   On Error GoTo gbNullError

   Select Case VarType(vnt)
   Case V_NULL, V_EMPTY
       gbNull = True
   Case V_STRING
       gbNull = (Len(gsTrim(CStr(vnt))) = 0)
   Case V_DATE
       gbNull = False
   Case Else
       gbNull = (vnt = 0)
   End Select

gbNullExit:
   Exit Function

gbNullError:
   gbNull = True
   Resume gbNullExit

End Function


Public Function GetOpenFileName(tFilename As CMDLG_FILENAME) As Integer
   GetOpenFileName = GetOpenFileNameA(tFilename)
End Function


' ***    Usage   ***
' strFile = gsWinDlgOpen((Me.hWnd), "Select file", "*" & Chr$(0) & "*" & Chr$(0), strData)


0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7900080
Hi tcurtin,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept rpai's comment(s) as an answer.

tcurtin, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7978219
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question