2025 Mar 13 3:20 AM - edited 2025 Mar 13 7:37 AM
SaveFileDialog shows and can be used but it shows behind the SAP window.
I've tested run with C# in Visual Studio and it works very well being in front of the SAP window. But after added it with Lightweight Deployment, it became behind.
Here is the code I use,
System.Threading.Thread thread = new System.Threading.Thread(() => {
using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
{
System.Windows.Forms.Form form = new System.Windows.Forms.Form();
form.TopMost = true;
saveFileDialog.ShowDialog(form);
}
}
thread.SetApartmentState(System.Threading.ApartmentState.STA);
thread.Start();
Request clarification before answering.
Hi,
You can test adding form.TopLevel:
System.Threading.Thread thread = new System.Threading.Thread(() => {
using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
{
System.Windows.Forms.Form form = new System.Windows.Forms.Form();
form.TopLevel = true;
form.TopMost = true;
saveFileDialog.ShowDialog(form)
}
}
thread.SetApartmentState(System.Threading.ApartmentState.STA);
thread.Start();Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the answer. I've tried it and it still doesn't work. But I searched for solutions in other topics and found this one that weirdly works by setting visible as true and the rest work like a magic.
System.Threading.Thread thread = new System.Threading.Thread(() => {
using (System.Windows.Forms.SaveFileDialog saveFileDialog = new
System.Windows.Forms.SaveFileDialog())
{
System.Windows.Forms.Form saveForm = new System.Windows.Forms.Form();
saveForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
saveForm.ControlBox = false;
saveForm.Activate();
saveForm.BringToFront();
saveForm.Visible = true;
saveForm.Width = 0;
saveForm.Height = 0;
saveForm.TopMost = true;
saveForm.Focus();
System.Windows.Forms.DialogResult dialogResult = saveFileDialog.ShowDialog(saveForm);
System.Threading.Thread.Sleep(100);
}
});
thread.IsBackground = false;
thread.Priority = System.Threading.ThreadPriority.Highest;
thread.SetApartmentState(System.Threading.ApartmentState.STA);
thread.Start();
| User | Count |
|---|---|
| 33 | |
| 17 | |
| 14 | |
| 13 | |
| 9 | |
| 4 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.