//---------------------------------------------------------------------------
UINT
APIENTRY PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam,
LPARAM lParam);
//---------------------------------------------------------------------------
void
__fastcall TForm1::PrintDialogButtonClick(TObject *Sender)
{
PRINTDLG pd;
ZeroMemory(&pd, sizeof(PRINTDLG));
// initialize PRINTDLG
pd.lStructSize = sizeof(PRINTDLG);
pd.hwndOwner = Handle;
pd.nCopies = 1;
pd.nFromPage = 0xFFFF;
pd.nToPage = 0xFFFF;
pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF;
pd.Flags = PD_ENABLEPRINTHOOK;
pd.lpfnPrintHook = PrintHookProc;
if (PrintDlg(&pd))
{
// do some printing...
if (pd.hDevMode) GlobalFree(pd.hDevMode);
if (pd.hDevNames) GlobalFree(pd.hDevNames);
}
}
//---------------------------------------------------------------------------
UINT
APIENTRY PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam,
LPARAM lParam)
{
if (uiMsg == WM_INITDIALOG)
{
// manipulate some controls in the hook procedure
// for example, disable the "Properties" button
HWND HPropButton = GetDlgItem(hdlg, psh2);
EnableWindow(HPropButton, false);
}
return 0L;
}
|