#Include once "window9.bi"

Dim Shared ofn  As OPENFILENAME
Function SaveFileRequester Alias "SaveFileRequester"(ByVal Title As String,ByVal curentdir As String, ByVal Pattern As String, ByVal defaultsetpattern As bool,ByVal templateName As String = "") As String export
	Dim ofn       As OPENFILENAME
	Dim filename  As ZString * MAX_PATH+1
	Dim fbguiTemp As Integer
	Dim DefExt As String*10
	filename = templateName
	With ofn
		.hwndOwner        = 0
		.lStructSize      = SizeOf(OPENFILENAME)
		.lpstrFilter      = Cast(LPCTSTR,StrPtr(Pattern))
		.lpstrFile        = StrPtr(filename)
		.nMaxFile         = SizeOf(filename)
		.lpstrFileTitle   = Cast(LPTSTR,StrPtr(Title))
		.nMaxFileTitle    = SizeOf(Title)
		.lpstrInitialDir  = Cast(LPCTSTR,StrPtr(curentdir))
		.lpstrTitle       = Cast(LPCTSTR,StrPtr(Title))
		.Flags            = OFN_EXPLORER Or OFN_FILEMUSTEXIST Or OFN_OVERWRITEPROMPT
		If defaultsetpattern=1 Then
			.lpstrDefExt = StrPtr(DefExt)
		EndIf	
	End With
	if( GetSaveFileName( @ofn ) = 0 ) then
		Return ""
	Else
		Return filename
	end If
End Function
