0

如果“TotalFileCount”== 0,此代码将打开一个文件夹。我想打开该文件夹并将其置于屏幕中央,并且我希望它具有特定的大小。有没有办法在 C# 中做到这一点?

if (TotalFileCount == 0)
{
    MessageBox.Show("There are no files in this directory. Please add pictures to this folder: " + AppVars.PolicyImagesDirectory + " and try again.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
    btnBrowse.Focus();

    System.Diagnostics.Process process = new System.Diagnostics.Process();
    process.StartInfo.FileName = AppVars.PolicyImagesDirectory;
    process.Start(); 
 }

当新的 Windows 资源管理器窗口打开时,我可以将其设置为特定大小并在屏幕上居中吗?

4

1 回答 1

0

从进程中获取句柄,然后从 win32 api 调用本机 SetWindowPos

process.handle //to get the handle of the window.

[DllImport("user32.dll", SetLastError=true)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int W, int H, uint uFlags);
于 2012-08-07T18:39:52.203 回答