0
printPreviewDialog 컨트롤을 사용하고 싶습니다. richTextBox, button, printPreviewDialog 및 printDocument의 네 가지 컨트롤을 추가합니다. printDocument1를 들어 내가 추가printPreviewDialog 너무 많은 창을 표시합니다.
private: System::Void printDocument1_PrintPage(System::Object^ sender, System::Drawing::Printing::PrintPageEventArgs^ e) {
printDocument1->Print();
e->Graphics->DrawString(richTextBox1->Text,richTextBox1->Font, Brushes::Black,(float)80,(float)80);
}
버튼의 :
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
printPreviewDialog1->Document = printDocument1;
printPreviewDialog1 -> ShowDialog();
}
코드 괜찮습니다, 나는 구축하고 aplication를 실행할 수 있습니다.
이 사람이 나를 도와 드릴까요 : 내가 버튼을 클릭 할 때하지만 난 이런 일을받은? 고마워요!
이 줄이 있는지 궁금합니다. 'printDocument1-> Print();'는 재귀 적으로'printDocument1_PrintPage' 이벤트를 호출합니다. –
@CarlWinder - 빠른 응답을 주셔서 감사합니다. 당신은 맞습니다.'printDocument1-> Print();를 삭제하면 미리보기 대화 상자가 제대로 작동하지만 ...'printDocument1-> Print();'를 사용하지 않고 문서를 인쇄하는 방법은 무엇입니까? –
'ShowDialog'는'Ok' 나'Cancel'과 같은 값을 반환 할 것이고, 실제 코드가 무엇인지 머리 위를 기억할 수는 없습니다. 그러나'ShowDialog'의 반환 코드를'Ok'라고 체크하면'Print' 함수를 호출 할 것입니다. –