Solved

commondialog via api call?

Posted on 2002-06-12
6
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

763 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