Hi
I am trying to print the window's content using PrintWindow() function. The code I use is below. In this code I could not call PrintWindow directly but had to load it dynamically from the dll because I use very old Borland C which does not have this function. Everything looks all right, the call (ProcAdd) (hwnd,pd.hDC,PW_CLIENTONLY); returns TRUE, i.e. the function does not report an error. However, when I run the program and try to print, nothing happens. I tried both printing and creating a pdf file, in either case nothing happens.
Maybe I missed something in the initialization of the printing job? For example one thing that comes to my mind, the printer device context that is passed to the function, pd.hDC, is nowhere determined explicitly. I was thinking that it gets defined in the printing dialog. Is that correct or should I define it somehow? Or maybe there is something else missing?
Does anybody have an idea?

Code:
typedef int (__cdecl *MYPROC)(HWND,HDC,UINT);
....
// This part is not directly related to the example, it just initializes and displays the print dialog 
ZeroMemory(&pd, sizeof(pd));
pd.lStructSize = sizeof(pd);
pd.hwndOwner   = hwnd;
pd.hDevMode    = NULL;     // Don't forget to free or store hDevMode.
pd.hDevNames   = NULL;     // Don't forget to free or store hDevNames.
pd.Flags       = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
pd.nCopies     = 1;
pd.nFromPage   = 0xFFFF;
pd.nToPage     = 0xFFFF;
pd.nMinPage    = 1;
pd.nMaxPage    = 0xFFFF;

PrintDlg(&pd);

//This is the actual example I found for LoadLibrary/GetProcAddress
// Get a handle to the DLL module.
hinstLib = LoadLibrary(TEXT("user32.dll"));
// If the handle is valid, try to get the function address.
 if (hinstLib != NULL) {
	ProcAdd = (MYPROC) GetProcAddress(hinstLib, "PrintWindow");
	// If the function address is valid, call the function.
        	if (NULL != ProcAdd) {
        	fRunTimeLinkSuccess = TRUE;
        	(ProcAdd) (hwnd,pd.hDC,PW_CLIENTONLY);  // this is where the compiler gives and error message
        }
        // Free the DLL module.
        fFreeResult = FreeLibrary(hinstLib);
}