-------------------- TPrintFormData PrintOptions; // Are we printing something right now? if (Printer()->Printing) { ShowMessage("Already printing... Please try again later!"); return; } // Let the user select a printer if (! PrintDialog1->Execute()) { return; } // Prepare to set printing options memset(&PrintOptions, 0, sizeof(PrintOptions)); PrintOptions.StrucSize = sizeof(PrintOptions); // Lets show a status dialog during the print job! PrintOptions.UseAbortDialog = TRUE; // Lets show messages if there are problems printing the form PrnFormSetDebugMsg(TRUE); // Allow the user to force the use 24 bit printing for problem printers PrintOptions.Use24BitOutputOnly = CheckBox24BitFormOutput->Checked; // Allow user to force the use of DDBs for problem printers or speed up the print job PrnFormSetDebugUseDDB(CheckBoxUseDDB->Checked); // Set print job size reduction factor if (CheckBoxCompress->Checked) { PrnFormSetOutputScaleFactor(2, 2); } else { PrnFormSetOutputScaleFactor(1, 1); } // Set WinScale if (CheckBoxWinStretch->Checked) { PrnFormSetOutputScaleFactor(1, 1); PrnFormSetDoWinScale(TRUE); } else { PrnFormSetDoWinScale(FALSE); } // Start the print job! Printer()->BeginDoc(); // Print the form! if (! PrintFormEx(this, Printer()->Canvas->Handle, TRUE, // Center the form on the page TRUE, // Adjust for perfect margins &PrintOptions)) { // Abort the print job! Printer()->Abort(); ShowMessage("User abort or other error!"); } else { // End the print job! Printer()->EndDoc(); } // We are done! ShowMessage("Printing Completed!");} ---------------- 能打印窗体的可见部分
打印出来保准没问题!
TPrintFormData PrintOptions; // Are we printing something right now?
if (Printer()->Printing) {
ShowMessage("Already printing... Please try again later!");
return;
} // Let the user select a printer
if (! PrintDialog1->Execute()) {
return;
} // Prepare to set printing options
memset(&PrintOptions, 0, sizeof(PrintOptions));
PrintOptions.StrucSize = sizeof(PrintOptions); // Lets show a status dialog during the print job!
PrintOptions.UseAbortDialog = TRUE; // Lets show messages if there are problems printing the form
PrnFormSetDebugMsg(TRUE); // Allow the user to force the use 24 bit printing for problem printers
PrintOptions.Use24BitOutputOnly = CheckBox24BitFormOutput->Checked; // Allow user to force the use of DDBs for problem printers or speed up the print job
PrnFormSetDebugUseDDB(CheckBoxUseDDB->Checked); // Set print job size reduction factor
if (CheckBoxCompress->Checked) {
PrnFormSetOutputScaleFactor(2, 2);
} else {
PrnFormSetOutputScaleFactor(1, 1);
} // Set WinScale
if (CheckBoxWinStretch->Checked) {
PrnFormSetOutputScaleFactor(1, 1);
PrnFormSetDoWinScale(TRUE);
} else {
PrnFormSetDoWinScale(FALSE);
} // Start the print job!
Printer()->BeginDoc(); // Print the form!
if (! PrintFormEx(this,
Printer()->Canvas->Handle,
TRUE, // Center the form on the page
TRUE, // Adjust for perfect margins
&PrintOptions)) {
// Abort the print job!
Printer()->Abort();
ShowMessage("User abort or other error!");
} else {
// End the print job!
Printer()->EndDoc();
} // We are done!
ShowMessage("Printing Completed!");}
----------------
能打印窗体的可见部分