Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

commondialog via api call?

Posted on 2002-06-12
6
Medium Priority
?
309 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 200 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

916 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