Click here to Skip to main content
15,914,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionIs it possible to attach another apps' window DC? (About Gdi handle table and objects) Pin
sawerr21-Jul-08 9:05
sawerr21-Jul-08 9:05 
AnswerRe: Is it possible to attach another apps' window DC? (About Gdi handle table and objects) Pin
CPallini21-Jul-08 9:25
mveCPallini21-Jul-08 9:25 
GeneralRe: Is it possible to attach another apps' window DC? (About Gdi handle table and objects) Pin
Rajesh R Subramanian22-Jul-08 23:34
professionalRajesh R Subramanian22-Jul-08 23:34 
GeneralRe: Is it possible to attach another apps' window DC? (About Gdi handle table and objects) Pin
CPallini22-Jul-08 23:41
mveCPallini22-Jul-08 23:41 
GeneralRe: Is it possible to attach another apps' window DC? (About Gdi handle table and objects) Pin
Rajesh R Subramanian22-Jul-08 23:43
professionalRajesh R Subramanian22-Jul-08 23:43 
GeneralRe: Is it possible to attach another apps' window DC? (About Gdi handle table and objects) Pin
CPallini22-Jul-08 23:48
mveCPallini22-Jul-08 23:48 
GeneralTHHB hits again Pin
Rajesh R Subramanian22-Jul-08 23:52
professionalRajesh R Subramanian22-Jul-08 23:52 
AnswerRe: Is it possible to attach another apps' window DC? (About Gdi handle table and objects) Pin
Mark Salsbery21-Jul-08 11:17
Mark Salsbery21-Jul-08 11:17 
I tested this real quick, and it works fine for me.

This example finds a NotePad instance and Blts the Notepad window
to my window (note that "*pThis" in the callback == the HWND for the dialog window)...
BOOL CALLBACK CMFCTesterDlg::EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
	if(hwnd == ::FindWindow(NULL, L"Untitled - Notepad"))
	{
		CMFCTesterDlg *pThis = (CMFCTesterDlg *)lParam;
		HWND hwnddest = *pThis;

		RECT rect;
		::GetWindowRect(hwnd, &rect);
		HDC dc = ::GetDCEx(hwnd, NULL, DCX_WINDOW);
		HDC destdc = ::GetDC(hwnddest);
		::BitBlt(destdc, 0, 0, rect.right-rect.left, rect.bottom-rect.top, dc, 0, 0, SRCCOPY);
		::ReleaseDC(hwnddest, destdc);
		::ReleaseDC(hwnd, dc);
	};
	return TRUE;
}


void CMFCTesterDlg::OnOK()
{
	::EnumWindows(&CMFCTesterDlg::EnumWindowsProc, (LPARAM)this);	
}

Also, why the search within a search (FindWindow() within an EnumWindows() callback)?? Smile | :)

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: Is it possible to attach another apps' window DC? (About Gdi handle table and objects) Pin
sawerr21-Jul-08 14:11
sawerr21-Jul-08 14:11 
GeneralPercent Progress Bar Pin
robertaallan21-Jul-08 9:03
robertaallan21-Jul-08 9:03 
GeneralRe: Percent Progress Bar Pin
Randor 21-Jul-08 9:50
professional Randor 21-Jul-08 9:50 
QuestionRe: Percent Progress Bar Pin
David Crow22-Jul-08 2:52
David Crow22-Jul-08 2:52 
QuestionTab Control/Dialog Box Position problem Pin
Leslie Sanford21-Jul-08 7:47
Leslie Sanford21-Jul-08 7:47 
AnswerRe: Tab Control/Dialog Box Position problem Pin
Randor 21-Jul-08 8:20
professional Randor 21-Jul-08 8:20 
AnswerRe: Tab Control/Dialog Box Position problem Pin
Mark Salsbery21-Jul-08 8:54
Mark Salsbery21-Jul-08 8:54 
GeneralRe: Tab Control/Dialog Box Position problem Pin
Leslie Sanford21-Jul-08 8:56
Leslie Sanford21-Jul-08 8:56 
QuestionHow to print on a non-default printer without print dialog Pin
victoria195021-Jul-08 6:29
victoria195021-Jul-08 6:29 
QuestionExtending a class that uses a template Pin
Patrick G21-Jul-08 5:55
Patrick G21-Jul-08 5:55 
AnswerRe: Extending a class that uses a template Pin
led mike21-Jul-08 6:18
led mike21-Jul-08 6:18 
GeneralRe: Extending a class that uses a template Pin
Patrick G21-Jul-08 7:28
Patrick G21-Jul-08 7:28 
GeneralRe: Extending a class that uses a template Pin
led mike21-Jul-08 7:46
led mike21-Jul-08 7:46 
GeneralRe: Extending a class that uses a template Pin
Patrick G21-Jul-08 8:09
Patrick G21-Jul-08 8:09 
GeneralRe: Extending a class that uses a template Pin
led mike23-Jul-08 5:31
led mike23-Jul-08 5:31 
QuestionRe: Extending a class that uses a template Pin
David Crow21-Jul-08 8:20
David Crow21-Jul-08 8:20 
GeneralRe: Extending a class that uses a template Pin
Patrick G21-Jul-08 8:38
Patrick G21-Jul-08 8:38 

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.