Skip to Content
0
Dec 06, 2011 at 09:00 PM

OpenFileDialog Focus Problem

215 Views

When making a functionally attachment in my Add-on, sometimes using the property of the OpenFileDialog C #, the dialog box that appears to select files is behind the screen of the sap. That is, it loses focus. How to do this by setting it as the main focus in sap? Here my code:

ThreadStart starter = delegate { Anexar(oEditItem); };

Thread t = new Thread(starter);

t.SetApartmentState(ApartmentState.STA);

t.Start();

t.Join();

public void Anexar(SAPbouiCOM.EditText oEditItem)

{

try

{

OpenFileDialog fDialog = new OpenFileDialog();

fDialog.Title = "Anexar arquivo";

fDialog.Filter = "(.)|.";

fDialog.InitialDirectory = @"C:\";

if (fDialog.ShowDialog() == DialogResult.OK)

{

oEditItem.Value = fDialog.FileName.ToString();

}

}

catch (Exception e)

{

SBO_Application.MessageBox(e.Message);

}

}