を介して画面領域をキャプチャするプログラムがありますBitBlt
。今日テストしていたところ、画面領域に Windows Media Player の一部が含まれている場合、それらの部分がグレーで表示されることがわかりました。領域の残りの部分は、ビットマップに正常にコピーされます。
画面の一部をキャプチャするために使用するコード フラグメントを次に示します。
HDC hdc = ::GetDC(NULL); // get the desktop device context
HDC hDest = CreateCompatibleDC(hdc); // create a device context to use
// set the height and width of the region
int height = 800;
int width = 600;
// create a bitmap
HBITMAP hbDesktop = CreateCompatibleBitmap(hdc, width, height);
// use the previously created device context with the bitmap
SelectObject(hDest, hbDesktop);
// copy from the desktop device context (x=100,y=100) to the bitmap device context
BitBlt(hDest, 0, 0, width, height, hdc, 100, 100, SRCCOPY);
このコード フラグメントは、スクリーン ポイント (100, 100) から始まるサイズ 800x600 のスクリーン領域をキャプチャします。
この領域のどこかにムービーを再生するメディア プレーヤーを配置すると、出力ビットマップに入ると、ムービー プレーヤーのコンテンツではなく灰色の領域になります。
BitBlt
映画プレーヤーが含まれている場合、画面領域にまったく可能かどうか疑問に思いますか? Media Player の画面へのコンテンツの表示が他の Windows アプリケーションとは異なるためでしょうか?