본문 바로가기

Windows/MFC

프린터/프린트 설정 CPrintDialog

프린터/프린트 설정    CPrintDialog
[code]
CPrintDialog(BOOL bPrintSeupOnly,DWORD dwFlags = PD_ALLPAGES | PDUSEDEVMODECOPIES |
            PD_NOPAGENUMS | PD_HIDEPRINTTOFILE | PD_NOSELECTION, CWnd* pParentWnd = NULL);

BOOL bPrintSetupOnly
TRUE : 프린트 설정 다이알로그
FALSE : 프린트 다이알로그

DWORD dwFlags - 속성지정
    PD_ALLPAGES : 인쇄범위 박스안에 전부라고 설정도어 있는 라디오 버튼을 선택한채로 나오게 한다.
    PD_DISABLEPRINTTOFILE : 파일로 인쇄하기 박스를 비 활성화 상태로 만듬
    PD_HIDEPRINTTOFILE : 파일로 인쇄하기 박스를 보이지 않게 만든다.
    PD_PAGENUMS : 인쇄할쪽이라고 설정되어 잇는 라디오 버튼을 선택한 상태로 나오게 한다.
    PD_SELECTION : 선택영역이라고 설정되어 잇는 라디오 버튼을 선택한 상태로 나오게 한다.
    PD_USERDEVMODECOPIES : 인쇄매수박스의 매수라고 설정된 박스를 활성화 시킨다

CWnd* pParentWnd - 본 멤버함수 이용 필요한 작업
    멤버 함수
    int GetCopies() const; : 사용자가 선택한 인쇄 매수를 돌려줌
    BOOL PrintCollate() const; : 프린터가 문서에 있는 모든 페이지를 인쇄되었는지를 알아냄.
    int GetFrompage() const; : 인쇄할쪽 박스를 선택했을 경우 시작 페이지값을 얻는다.
    int GetToPage() const; :
[/code]

[code]
//프린터 설정 다이얼로그 박스
void CDlgTotalView::OnCmdPrinterSet()
{
    CPrintDialog PrintersetDlg(TRUE); //프린터 설정 다이얼로그 박스로 옵션선택-파라미터 1개사용 경우

    if(printersetDlg.DoModal() == IDOK)
    {
        CString str;
        str.Format("Device Name : %s\r\nDriver Name : %s\r\nPortName : %s",
                    printersetDlg.GetDeviceName(),
                    printersetDlg.GetDriverName(),
                    printersetDlg.GetPortName();

        MessageBox(str, "프린터 설정 정보");
    }
}

//인쇄 다이알로그 박스
void CDlgTotalView::OnComdPrint()
{
    //인쇄다이알로그 옵션 선택    
    CPrintDialog printDlg(FALSE,PD_ALLPAGES | PD_USEDEVMODECOPIES |
                            PD_NOPAGENUMS | PD_HIDEPRINTTOFILE | PD_NOSELECTION);

    if(printDlg.DoModal() == IDOK)
    {
        CString str;
        str.Format("Device Name : %s\r\nDriver Name : %s\r\nPortName :
                    %s\r\nCopiesNum : %d",printDlg.GetDeviceName(),
                    printDlg.GetDriverName(),printDlg.GetPortName,
                    printDlg.GetCopies());

        MessageBox(str,"프린터 출력정보");
    }
}[/code]