| |

Visual-Basic EinsteigerGLEICHES PROBLEM ( | |  | Autor: xverbatim | Datum: 20.12.07 15:41 |
| Hi,
hmm...
ich habe das jetzt in If Right$(sFile, 4) = ".abc" Then ...
geändert, verhält sich aber genauso wie vorher....
also wenn ich im DialogspeicherControl bin, einen Namen anklicke (also eine Datei, die schon mal gespeichert wurde soll überschrieben werden), heißt die Datei dann
blabla.abc.abc
klicke ich nochmal auf den namen und speichern wie oben speichert er mir das so
blabla.abc.abc.abc
usw.
achso, wenn ich einen komplett neuen Namen eingebe zum speichern,
habe ich nur den namen im dialogfeld und den extender(der nicht angezeigt wird)...soll heißen, beim ersten mal wenn ich speichere läuft alles ok...
das problem ist beim überschreiben und dann hängt er mir immer .abc ran...
@BASTler
"kannst du mal ShowSaveDlg und SplitFileFromPath erklären?"
sind die Windowseigenen DialogControls aufgerufen über API
somit brauche ich kein Control in der IDE...(siehe Code unten)
Gruß Xverbatim
MODUL:
code]
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
Private Const OFN_READONLY = &H1
Private Const OFN_OVERWRITEPROMPT = &H2
Private Const OFN_HIDEREADONLY = &H4
Private Const OFN_NOCHANGEDIR = &H8
Private Const OFN_SHOWHELP = &H10
Private Const OFN_ENABLEHOOK = &H20
Private Const OFN_ENABLETEMPLATE = &H40
Private Const OFN_ENABLETEMPLATEHANDLE = &H80
Private Const OFN_NOVALIDATE = &H100
Private Const OFN_ALLOWMULTISELECT = &H200
Private Const OFN_EXTENSIONDIFFERENT = &H400
Private Const OFN_PATHMUSTEXIST = &H800
Private Const OFN_FILEMUSTEXIST = &H1000
Private Const OFN_CREATEPROMPT = &H2000
Private Const OFN_SHAREAWARE = &H4000
Private Const OFN_NOREADONLYRETURN = &H8000
Private Const OFN_NOTESTFILECREATE = &H10000
Private Const OFN_NONETWORKBUTTON = &H20000
Private Const OFN_NOLONGNAMES = &H40000
Private Const OFN_EXPLORER = &H80000
Private Const OFN_NODEREFERENCELINKS = &H100000
Private Const OFN_LONGNAMES = &H200000
Private Const OFN_SHAREFALLTHROUGH = 2
Private Const OFN_SHARENOWARN = 1
Private Const OFN_SHAREWARN = 0
Private Declare Function GetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) _
As Long
Private Declare Function GetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) _
As Long
'Öffnen-Dialog
Public Function ShowOpenDlg(f As Form, strFilter As String, _
strTitel As String, strInitDir As String) As String
Dim lngOpenFileName As OPENFILENAME
Dim lngAnt As Long
With lngOpenFileName
.lStructSize = Len(lngOpenFileName)
.hwndOwner = f.hWnd
.hInstance = App.hInstance
If Right$(strFilter, 1) <> "|" Then _
strFilter = strFilter + "|"
For lngAnt = 1 To Len(strFilter)
If Mid$(strFilter, lngAnt, 1) = "|" Then _
Mid$(strFilter, lngAnt, 1) = Chr$(0)
Next
.lpstrFilter = strFilter
.lpstrFile = Space$(254)
.nMaxFile = 255
.lpstrFileTitle = Space$(254)
.nMaxFileTitle = 255
.lpstrInitialDir = strInitDir
.lpstrTitle = strTitel
.flags = OFN_HIDEREADONLY Or OFN_FILEMUSTEXIST
lngAnt = GetOpenFileName(lngOpenFileName)
If (lngAnt) Then
ShowOpenDlg = Trim$(.lpstrFile)
Else
ShowOpenDlg = ""
End If
End With
End Function
'Speichern-Dialog
Public Function ShowSaveDlg(f As Form, strFilter As String, _
strTitel As String, strInitDir As String) As String
Dim lngOpenFileName As OPENFILENAME
Dim lngAnt As Long
With lngOpenFileName
.lStructSize = Len(lngOpenFileName)
.hwndOwner = f.hWnd
.hInstance = App.hInstance
If Right$(strFilter, 1) <> "|" Then _
strFilter = strFilter + "|"
For lngAnt = 1 To Len(strFilter)
If Mid$(strFilter, lngAnt, 1) = "|" Then _
Mid$(strFilter, lngAnt, 1) = Chr$(0)
Next
.lpstrFilter = strFilter
.lpstrFile = Space$(254)
.nMaxFile = 255
.lpstrFileTitle = Space$(254)
.nMaxFileTitle = 255
.lpstrInitialDir = strInitDir
.lpstrTitle = strTitel
.flags = OFN_HIDEREADONLY Or OFN_OVERWRITEPROMPT Or _
OFN_CREATEPROMPT
lngAnt = GetSaveFileName(lngOpenFileName)
If (lngAnt) Then
ShowSaveDlg = Trim$(.lpstrFile)
Else
ShowSaveDlg = ""
End If
End With
End FunctionInteressante Lerntools auf
www.abc-braintools.de.vu
|  |
 | Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
  |
|
vb@rchiv CD Vol.6 vb@rchiv Vol.6
Geballtes Wissen aus mehr als 8 Jahren vb@rchiv!
Online-Update-Funktion Entwickler-Vollversionen u.v.m.Jetzt zugreifen Tipp des Monats Oktober 2025 Matthias KozlowskiUmlaute konvertierenErsetzt die Umlaute in einer Zeichenkette durch die entsprechenden Doppelbuchstaben (aus ä wird ae, usw.) sevZIP40 Pro DLL 
Zippen und Unzippen wie die Profis!
Mit nur wenigen Zeilen Code statten Sie Ihre Anwendungen ab sofort mit schnellen Zip- und Unzip-Funktionen aus. Hierbei lassen sich entweder einzelnen Dateien oder auch gesamte Ordner zippen bzw. entpacken. Weitere Infos
|
|
|
Copyright ©2000-2025 vb@rchiv Dieter Otter Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.
Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel
|
|