2

アプリケーションのスクリーンショットを含む PDF ファイルを作成する必要があるアプリケーションを作成しています。

スクリーンショットを作成する方法と、それをファイルに入れる方法を見つけました。ほとんどの状況ですべてがうまく機能しています。

私の問題は、複数の画面や Teamviewer のようなプログラムを使用しているときに発生します。問題は、私のプログラムが正しい領域をキャプチャすることです(どの画面でも画面上の適切な座標)が、ウィンドウの背後にあるものはすべてキャプチャしますが、ウィンドウはキャプチャしません。

誰かが私が何を間違っているのか、または詳細を見逃したのか知っていますか?

現在使用しているコードは次のとおりです。

// creates an rectangle of the size of the window
        Rectangle bounds = new Rectangle(
            (int)System.Windows.Application.Current.MainWindow.Left+10, 
            (int)System.Windows.Application.Current.MainWindow.Top+10, 
            (int)System.Windows.Application.Current.MainWindow.Width-20, 
            (int)System.Windows.Application.Current.MainWindow.Height-20);

        // creates a bitmap with a screenshot of the size of the window
        Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);
        Graphics g = Graphics.FromImage(bitmap);
        g.CopyFromScreen(new System.Drawing.Point(bounds.Left, bounds.Top), new System.Drawing.Point(0,0), bounds.Size);

助けや例を前もって感謝します。

4

1 に答える 1