|
-
Mar 10th, 2000, 10:22 AM
#1
Thread Starter
Addicted Member
Once I select to add the Microsoft Common Dialog Control 5.0 (SP2) and then try to add it to a form I get the following error message. "License Information for this component could not be found. You do not have an appropriate license to use this functionality in the design environment." I cannot figure out why I am still getting this message. The CommonDialog control worked before I had to reinstall Windows 98. I have tried uninstalling and reinstalling with no luck. I know that it has to do with registering the control in the registry but don't know how to fix it. Has anyone else run into a similar problem and fixed it? Any ideas on what needs to be done? Any help is greatly appreciated as I use this frequently use this control!
-
Mar 10th, 2000, 11:05 AM
#2
Lively Member
well one way around that problem is to not use inlcude the ocx in ur project. instead use the following code to call up the commondialog function
-=put code in module=-
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
Enum DialogMode
OpenMode = &H0 'retuens 0
SaveMode = &H1 'returns 1
End Enum
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
Function CommonDialog(zDialogMode As DialogMode, zOwner As Form, zInitialDir As String, zDialogTitle As String, zExtension As String, zExtensionTitle As String) As String
If zInitialDir = "" Then zInitialDir = CurDir
Dim ofn As OPENFILENAME
ofn.lStructSize = Len(ofn)
ofn.hwndOwner = zOwner.hWnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = zExtensionTitle + " " + "(" + zExtension + ")" + Chr$(0) + zExtension + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
ofn.lpstrFile = Space$(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space$(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = zInitialDir
ofn.lpstrTitle = zDialogTitle
ofn.flags = 0
Dim a As Long
If zDialogMode = OpenMode Then
a = GetOpenFileName(ofn)
ElseIf zDialogMode = SaveMode Then
a = GetSaveFileName(ofn)
Else
MsgBox "Must have a dialog mode.", vbApplicationModal + vbCritical, "CommonDialog Error"
Exit Function
End If
Dim zDialogFileName As String
zDialogFileName = Trim$(ofn.lpstrFile)
If a = 1 Then '1 denotes value when open/save
CommonDialog = Trim(zDialogFileName)
Else
CommonDialog = ""
End If
End Function
-=put code in form=-
Private Sub Form_Load()
MsgBox CommonDialog(OpenMode, Me, "", "Open file...", "*.bat", "Batch Files")
End Sub
well hope it helps 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|