/*   ディスプレイのデバイスコンテキスト      1998/10/ 4 宍戸 輝光 */ #include int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){ HDC hdc,hdcMem; HBITMAP hBMP; LPBITMAPINFO lpDIB; LPBYTE lpBMP; int i,iWidth,iHeight; BYTE bRed,bGreen,bBlue,bGray; hdc=CreateDC("DISPLAY",NULL,NULL,NULL); iWidth=GetDeviceCaps(hdc,HORZRES); /* 画面の大きさ取得 */ iHeight=GetDeviceCaps(hdc,VERTRES); lpDIB=(LPBITMAPINFO)GlobalAlloc(GPTR, sizeof(BITMAPINFO)); /* DIB用メモリ確保 */ /* DIBSection 用BITMAPINFO構造体設定 */ lpDIB->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); lpDIB->bmiHeader.biWidth=iWidth; lpDIB->bmiHeader.biHeight=iHeight; lpDIB->bmiHeader.biPlanes=1; lpDIB->bmiHeader.biBitCount=24; lpDIB->bmiHeader.biCompression=BI_RGB; lpDIB->bmiHeader.biSizeImage=0; lpDIB->bmiHeader.biXPelsPerMeter=0; lpDIB->bmiHeader.biYPelsPerMeter=0; lpDIB->bmiHeader.biClrUsed=0; lpDIB->bmiHeader.biClrImportant=0; /* DIB と画面のDC からDIBSection を作成 */ hBMP=CreateDIBSection(hdc,lpDIB,DIB_RGB_COLORS,&lpBMP,NULL,0); hdcMem=CreateCompatibleDC(hdc); /* メモリDC を作成 */ SelectObject(hdcMem,hBMP); /* メモリDC にDIBSectionを選択 */ /* 画面全体をDIBSection のビットマップにコピー */ BitBlt(hdcMem,0,0,iWidth,iHeight,hdc,0,0,SRCCOPY); for (i=0;i