on 03-04-2009 8:37 AM
Hi collegues !
Could you point me please, how i can show Save File Dialogue window, so i could prompt my users to choose file where they would like to save data
Best regards
Hi I want to know the files to be imported for commondialog
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
========
Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
Select Case pVal.ItemUID
Case "Btnbrowse"
Me.OpenFile()
end select
Private Sub *OpenFile*(ByRef BubbleEvent As Boolean)
Try
ShowFolderBrowserThread = New Threading.Thread(AddressOf ShowFolderBrowser)
If ShowFolderBrowserThread.ThreadState = ThreadState.Unstarted Then ShowFolderBrowserThread.SetApartmentState(ApartmentState.STA)
ShowFolderBrowserThread.Start()
ElseIf ShowFolderBrowserThread.ThreadState = ThreadState.Stopped Then
ShowFolderBrowserThread.Start()
ShowFolderBrowserThread.Join()
End If
Catch ex As Exception
sbo_application.MessageBox("SaveFile" & ex.Message)
End Try
Private Sub ShowFolderBrowser()
Dim MyTest As New SaveFileDialog
Dim MyProcs() As System.Diagnostics.Process
Dim filename As String
MyProcs = process.GetProcessesByName("SAP Business One")
If MyProcs.Length = 1 Then
For i As Integer = 0 To MyProcs.Length - 1
'// WindowWraper concepts are used to access open dialogue box of windows
Dim MyWindow As New WindowWrapper(MyProcs(i).MainWindowHandle)
MyTest.Filter = "Excel files (*.xls)|*.xls|Document files (*.doc)|*.doc|Presentation (*.ppt)|*.ppt|Adobe PDF Files (*.pdf)|*.pdf|Text Documents (*.txt)|*.txt" '|All Files (*.)|.*"
'MyTest.InitialDirectory = "C:\Program Files\SAP\SAP Business One\Attachments"
'// Initial path for open dialogue box
'// We can change as per the requirements
MyTest.InitialDirectory = "C:\Program Files\SAP\SAP Business One\Attachments"
If MyTest.ShowDialog(MyWindow) = DialogResult.OK Then
filename = MyTest.FileName
.your validations........
.
.
Else
System.Windows.Forms.Application.ExitThread()
End If
end sub
Public Class WindowWrapper
Implements System.Windows.Forms.IWin32Window
Private _hwnd As IntPtr
Public Sub New(ByVal handle As IntPtr)
_hwnd = handle
End Sub
Public ReadOnly Property Handle() As System.IntPtr Implements System.Windows.Forms.IWin32Window.Handle
Get
Return _hwnd
End Get
End Property
End Class
To open the file you can use the follwing code on display button pressed.
Private Sub *fileopen*(ByVal filename As String)
'// Opening specified document with reference to the filename distributed
Try
System.Diagnostics.Process.Start(filename)
Catch ex As Exception
sbo_application.StatusBar.SetText("File Not Found in Specified Path:" & filename, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error)
End Try
End Sub
========
Public Sub SBO_ManageItemEvent( _
ByVal FormUID As String, _
ByRef pVal As SAPbouiCOM.ItemEvent, _
ByRef BubbleEvent As Boolean _
) ' Item Event Handler
Dim oForm As SAPbouiCOM.Form
oForm = SBO_Application.Forms.Item(FormUID)
Select Case pVal.EventType
Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED
Select Case pVal.ItemUID
Case "btnBrowse" ' Select file
If Not pVal.BeforeAction Then
Call ShowFolderBrowser(oForm)
End If
End Select
End Select
oForm = Nothing
End Sub
Private Sub ShowFolderBrowser(ByRef oForm As SAPbouiCOM.Form)
Try
' ++++++++++++++++++++++++++++++++++++++++++++++++++
' I'm using default path...
' ++++++++++++++++++++++++++++++++++++++++++++++++++
Dim sPath As String = SBO_Company.ExcelDocsPath
oForm.Freeze(True)
SBO_Application.Desktop.State = BoFormStateEnum.fs_Minimized
' ++++++++++++++++++++++++++++++++++++++++++++++++++
' All windows down with command ^M
' ++++++++++++++++++++++++++++++++++++++++++++++++++
Const KEYEVENTF_KEYUP = &H2
Const VK_LWIN = &H5B
Call keybd_event(VK_LWIN, 0, 0, 0)
Call keybd_event(77, 0, 0, 0)
Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
Dim fileName As String = ""
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog.Title = "Select Excel File"
OpenFileDialog.Filter = "Excel files (*.xls)|*.xls"
If Not sPath.Equals("") Then
OpenFileDialog.InitialDirectory = sPath
Else
OpenFileDialog.InitialDirectory = Me.SBO_FormEventHDL.BdgPathLog '"C:\"
End If
If OpenFileDialog.ShowDialog() = DialogResult.OK Then
fileName = OpenFileDialog.FileName
sFileXls = fileName
' ++++++++++++++++++++++++++++++++++++++++++++++++++
' Here I post getted path into my edittext field
' ++++++++++++++++++++++++++++++++++++++++++++++++++
Dim oEdit As SAPbouiCOM.EditText
Dim oItem As SAPbouiCOM.Item
oItem = oForm.Items.Item("eFileName")
oEdit = oItem.Specific
oEdit.Value = sFileXls
oItem = Nothing
oEdit = Nothing
End If
Catch ex As Exception
' log exception
Finally
oForm.Freeze(False)
SBO_Application.Desktop.State = BoFormStateEnum.fs_Restore
System.GC.Collect() 'Release the handle to the table
End Try
End Sub
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
You can use ActiveX control do this stuff.
first use this code while you load your page
'Add One Active-X Button for Browse
oItem = oForm.Items.Add("BrowseA", SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X)
oItem.Top = 20
oItem.Left = 20
oItem.Width = 0
oItem.Height = 0
oActiveX = oItem.Specific
oActiveX.ClassID = "MSComDlg.CommonDialog"
oActiveX.ClassID = "{F9043C85-F6F2-101A-A3C9-08002B2F49FB}"
After this write this while pressing button
oOpenDialog = New OpenFileDialog()
oForm = SBOApp.Forms.Item("frmHazard")
oForm.Items.Item("BrowseA").Specific.Object.FileName = ""
oForm.Items.Item("BrowseA").Specific.Object.Filter = "JPG(*.JPG,*.JPEG)|*.JPG;*.JPEG|GIF(*.GIF)|*.GIF|Bitmap (*.bmp)|*.bmp"
oForm.Items.Item("BrowseA").Specific.Object.ShowOpen()
This will helps you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
10 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.