Let the common dialog display the front of the window (C #)

zhaozj2021-02-16  56

Note: The API function getForegroundWindow is used to get the handle of the front desk window, the "front desk" is the active window of the front desk application.

The class ForegroundWind is inherits the IWIN32Window interface provided by the frame and defines a static IWIN32WINDOW property instance instance to get the handle of the front desk.

Public class foregroundwindow: IWIN32WINDOW {private static foregroundwindow _window = new foregroundwindow (); private foregroundwindow () {}

Public static w32window instance {get {return_window;}}

[DLLIMPORT ("User32.dll")] private static extern INTPTR getForeGroup ";

INTPTR IWIN32WINDOW.HANDE {Get {Return getForeGroup Dindow ();}} public class example1

{

Public void savefile (String Str_FilePath)

{

SavefileDialog OpenFile = New SaveFileDialog (); OpenFile.title = "Please enter the RTF file name"; openfile.filter = "Word document (* .rtf) | * .rtf"; openfile.filterIndex = 0; openfile.validatenames = true; OpenFile.initialDirectory = str_filepath; OpenFile.ShowDialog (ForegroundWindow.instance);

}

}

转载请注明原文地址:https://www.9cbs.com/read-16938.html

New Post(0)