Click here to Skip to main content
15,917,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAbout SAPI Pin
Member 12180445-Jul-04 9:36
Member 12180445-Jul-04 9:36 
GeneralAdding a toolbar button to Internet Explorer Pin
Member 12180445-Jul-04 9:24
Member 12180445-Jul-04 9:24 
GeneralCTabCtrl frame background color Pin
alma5-Jul-04 8:46
alma5-Jul-04 8:46 
Generalhelp, style convert: Dialog -> MDI Pin
junhonguk5-Jul-04 6:51
junhonguk5-Jul-04 6:51 
GeneralRe: help, style convert: Dialog -> MDI Pin
Jaime Stuardo5-Jul-04 7:06
Jaime Stuardo5-Jul-04 7:06 
QuestionHow to take a snapshot from a (partially o fully) hidden window Pin
Member 1338885-Jul-04 6:48
Member 1338885-Jul-04 6:48 
AnswerRe: How to take a snapshot from a (partially o fully) hidden window Pin
Ravi Bhavnani5-Jul-04 7:56
professionalRavi Bhavnani5-Jul-04 7:56 
GeneralRe: How to take a snapshot from a (partially o fully) hidden window Pin
Scozturk5-Jul-04 9:22
professionalScozturk5-Jul-04 9:22 
Here is a win32 code:
<br />
int	Screenshot(HDC hdc, char *pszflname)<br />
{<br />
	HDC					memdc;<br />
	HANDLE				hfl;<br />
	DWORD				dwBytes, dwWidth, dwHeight, dwNumColors, dwBPP, ColorSize;<br />
	void				*pBits;<br />
	HBITMAP				hbmp;<br />
	BITMAPFILEHEADER	fileheader;<br />
	BITMAPINFOHEADER	infoheader;<br />
	RGBQUAD				colors[256];<br />
	BITMAPINFO			bmpinfo;<br />
	HGDIOBJ				hret;<br />
<br />
	dwWidth = GetDeviceCaps(hdc, HORZRES);<br />
	dwHeight = GetDeviceCaps(hdc, VERTRES);<br />
	dwBPP = GetDeviceCaps(hdc, BITSPIXEL);<br />
	if (dwBPP <= 8)<br />
		dwNumColors = 256;<br />
	else<br />
		dwNumColors = 0;<br />
	if (!(memdc = CreateCompatibleDC(hdc)))<br />
		return (0);<br />
	bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);<br />
	bmpinfo.bmiHeader.biWidth = dwWidth;<br />
	bmpinfo.bmiHeader.biHeight = dwHeight;<br />
	bmpinfo.bmiHeader.biPlanes = 1;<br />
	bmpinfo.bmiHeader.biBitCount = (WORD)dwBPP;<br />
	bmpinfo.bmiHeader.biCompression = BI_RGB;<br />
	bmpinfo.bmiHeader.biSizeImage = 0;<br />
	bmpinfo.bmiHeader.biXPelsPerMeter = 0;<br />
	bmpinfo.bmiHeader.biYPelsPerMeter = 0;<br />
	bmpinfo.bmiHeader.biClrUsed = dwNumColors;<br />
	bmpinfo.bmiHeader.biClrImportant = dwNumColors;<br />
	hbmp = CreateDIBSection(hdc, &bmpinfo, DIB_PAL_COLORS, &pBits, NULL, 0);<br />
	if (!hbmp)<br />
	{<br />
		DeleteDC(memdc);<br />
		return (0);<br />
	}<br />
	hret = SelectObject(memdc, hbmp);<br />
	if (!hret || (hret == HGDI_ERROR))<br />
	{<br />
		DeleteDC(memdc);<br />
		return (0);<br />
	}<br />
	if (!BitBlt(memdc, 0, 0, dwWidth, dwHeight, hdc, 0, 0, SRCCOPY))<br />
	{<br />
		DeleteDC(memdc);<br />
		return (0);<br />
	}<br />
	if (dwNumColors)<br />
		dwNumColors = GetDIBColorTable(memdc, 0, dwNumColors, colors);<br />
	fileheader.bfType = 0x4D42;<br />
	ColorSize = dwNumColors * sizeof(RGBQUAD);<br />
	fileheader.bfSize = ((dwWidth*dwHeight*dwBPP) >> 3) + ColorSize + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);<br />
	fileheader.bfReserved1 = fileheader.bfReserved2 = 0;<br />
	fileheader.bfOffBits = ColorSize + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);<br />
	infoheader.biSize = sizeof(BITMAPINFOHEADER);<br />
	infoheader.biWidth = dwWidth;<br />
	infoheader.biHeight = dwHeight;<br />
	infoheader.biPlanes = 1;<br />
	infoheader.biBitCount = (WORD)dwBPP;<br />
	infoheader.biCompression = BI_RGB;<br />
	infoheader.biSizeImage = infoheader.biClrImportant = 0;<br />
	infoheader.biXPelsPerMeter = infoheader.biYPelsPerMeter = 0;<br />
	infoheader.biClrUsed = dwNumColors;<br />
	hfl = CreateFile(pszflname, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);<br />
	if (hfl == INVALID_HANDLE_VALUE)<br />
	{<br />
		DeleteObject(hbmp);<br />
		{<br />
			DeleteDC(memdc);<br />
			return (0);<br />
		}<br />
	}<br />
	WriteFile(hfl, &fileheader, sizeof(BITMAPFILEHEADER), &dwBytes, 0);<br />
	WriteFile(hfl, &infoheader, sizeof(BITMAPINFOHEADER), &dwBytes, 0);<br />
	if (!dwNumColors)<br />
		WriteFile(hfl, colors, ColorSize, &dwBytes, 0);<br />
	ColorSize = (dwWidth * dwHeight * dwBPP) >> 3;<br />
	WriteFile(hfl, pBits, ColorSize, &dwBytes, 0);<br />
	CloseHandle(hfl);<br />
	DeleteObject(hbmp);<br />
	DeleteDC(memdc);<br />
	return (1);<br />
}<br />



and you can use it like this

<br />
Screenshot(GetDC(GetDesktopWindow()), "myscreenshot.bmp");<br />


I hope this helps....

Well... I am a beginner ...
GeneralRe: How to take a snapshot from a (partially o fully) hidden window Pin
Jijo.Raj5-Jul-04 21:34
Jijo.Raj5-Jul-04 21:34 
GeneralCalling C++ DLL ( not MFC) from another C++ DLL ( not MFC) Pin
chepuri_uk5-Jul-04 6:06
chepuri_uk5-Jul-04 6:06 
GeneralRe: Calling C++ DLL ( not MFC) from another C++ DLL ( not MFC) Pin
Jaime Stuardo5-Jul-04 8:13
Jaime Stuardo5-Jul-04 8:13 
GeneralRe: Calling C++ DLL ( not MFC) from another C++ DLL ( not MFC) Pin
Jeremy Falcon5-Jul-04 8:57
professionalJeremy Falcon5-Jul-04 8:57 
GeneralRe: Calling C++ DLL ( not MFC) from another C++ DLL ( not MFC) Pin
Jörgen Sigvardsson5-Jul-04 10:28
Jörgen Sigvardsson5-Jul-04 10:28 
GeneralRe: Calling C++ DLL ( not MFC) from another C++ DLL ( not MFC) Pin
Jeremy Falcon5-Jul-04 10:51
professionalJeremy Falcon5-Jul-04 10:51 
General&quot;%1&quot; %* Pin
Larsson5-Jul-04 5:45
Larsson5-Jul-04 5:45 
GeneralRe: &quot;%1&quot; %* Pin
Maximilien5-Jul-04 6:31
Maximilien5-Jul-04 6:31 
GeneralRe: &quot;%1&quot; %* Pin
Larsson5-Jul-04 6:34
Larsson5-Jul-04 6:34 
GeneralRe: &quot;%1&quot; %* Pin
Larsson5-Jul-04 6:47
Larsson5-Jul-04 6:47 
GeneralRe: &quot;%1&quot; %* Pin
Maximilien5-Jul-04 7:09
Maximilien5-Jul-04 7:09 
GeneralRe: &quot;%1&quot; %* Pin
Larsson5-Jul-04 7:12
Larsson5-Jul-04 7:12 
GeneralRe: &quot;%1&quot; %* Pin
Cobra4Ever5-Jul-04 13:43
Cobra4Ever5-Jul-04 13:43 
GeneralRe: &quot;%1&quot; %* Pin
Larsson6-Jul-04 2:53
Larsson6-Jul-04 2:53 
GeneralRe: &quot;%1&quot; %* Pin
Roger Allen6-Jul-04 4:32
Roger Allen6-Jul-04 4:32 
GeneralLR_DEFAULTSIZE|LR_LOADFROMFILE in WinCE Pin
Anonymous5-Jul-04 5:20
Anonymous5-Jul-04 5:20 
GeneralProgram Settings Pin
sweep1235-Jul-04 5:13
sweep1235-Jul-04 5:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.