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
Solved

commondialog via api call?

Posted on 2002-06-12
6
300 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 65
Run code from text file in vb 1 71
Formula problem with Excel attachment 6 38
Sub or Function is not defined 6 43
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

791 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