블로그 이미지
frostguy

카테고리

분류 전체보기 (48)
사진 (3)
Study (40)
IT (3)
Total143,121
Today8
Yesterday28

int nWidth, nHeight;
	CClientDC dc(this);  //this->pImgWnd
	CDC MemDC;
	MemDC.CreateCompatibleDC(&dc);
	
	CRect rect;
	GetClientRect(rect);
	nWidth = rect.Width();
	nHeight = rect.Height();

	CBitmap BMP;
	BMP.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
	CBitmap* pOldBitmap = MemDC.SelectObject(&BMP);
	MemDC.BitBlt(0, 0, nWidth, nHeight, &dc, 0, 0, SRCCOPY);

	/*
	SECJpeg* jpg = new SECJpeg();   
	jpg->CreateFromBitmap(&MemDC,&BMP);     
	jpg->SaveImage("Test.jpg");
	*/

	HANDLE hDib;
	LPSTR pDib;
	LPBITMAPINFO lpBitInfo;
	HANDLE hlpBitInfo;
	//CBitmap BMP;

	//BMP.LoadBitmap(IDB_BITMAP1);

	hDib=GlobalAlloc(GHND,nWidth*nHeight*3);
	pDib=(LPSTR)GlobalLock(hDib);
	hlpBitInfo=GlobalAlloc(GHND,sizeof(BITMAPINFOHEADER)+ sizeof(BITMAPINFO));
	lpBitInfo=(LPBITMAPINFO)GlobalLock(hlpBitInfo);

	//BITMAPINFO
	lpBitInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	lpBitInfo->bmiHeader.biWidth = nWidth;
	lpBitInfo->bmiHeader.biHeight = nHeight;
	lpBitInfo->bmiHeader.biPlanes = 1;
	lpBitInfo->bmiHeader.biBitCount = 24;
	lpBitInfo->bmiHeader.biCompression = BI_RGB;
	lpBitInfo->bmiHeader.biSizeImage = nWidth * nHeight * 3;
	lpBitInfo->bmiHeader.biXPelsPerMeter = 0;
	lpBitInfo->bmiHeader.biYPelsPerMeter = 0;
	lpBitInfo->bmiHeader.biClrUsed = 0;
	lpBitInfo->bmiHeader.biClrImportant = 0;         
	////BITMAPINFO  

	HDC hdc=::GetDC(this->m_hWnd);
	GetDIBits(hdc, (HBITMAP)BMP, 0, nHeight, pDib, lpBitInfo, DIB_RGB_COLORS);
	::ReleaseDC(this->m_hWnd, hdc);

	static DOCINFO docinfo= {sizeof(DOCINFO), _T("IMAGE"), NULL};

	CPrintDialog dlg(FALSE);
	if(dlg.DoModal()== IDCANCEL)
		return; 

	HDC hpdc= dlg.GetPrinterDC();
	int cx, cy ;

	cy=GetDeviceCaps(hpdc,VERTRES);
	cx=GetDeviceCaps(hpdc,HORZRES);

	if(StartDoc(hpdc,&docinfo))
	{
		if(StartPage(hpdc))
		{
			StretchDIBits(hpdc,
				0, 0, cx, cy, 0, 0, nWidth, nHeight, pDib, lpBitInfo, DIB_RGB_COLORS,SRCCOPY);
			EndPage(hpdc);
		}
		EndDoc(hpdc);
	}
	::RestoreDC(hpdc, -1);


출처 : http://www1.devpia.com/Maeul/Contents/Detail.aspx?BoardID=50&MAEULNO=20&no=793631&ref=793631&page=1

Posted by frostguy
버튼의 속성에서 Notify 를 True 로 해 주거나

버튼 생성시 BS_NOTIFY 옵션을 주도록 하자!!

간단하지만 잊기 쉬운 것 중의 하나이다.
Posted by frostguy
ShowWindow(SW_SHOWMINIMIZED);
PostMessage (WM_SHOWWINDOW,FALSE, SW_OTHERUNZOOM);
Posted by frostguy

최근에 달린 댓글

글 보관함