SOL9 2.0 Sample: Printdlg

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * Printdlg.cpp 
 * Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL++2000
// 2000.02.18


#include <sol\ApplicationView.h>
#include <sol\PrintDialog.h>

#include "resource.h"


namespace SOL {

class AppView :public ApplicationView {

private:
    PrintDialog    printdlg;

    void    print(Action& action)
    {
        printdlg.popup(action);
        if (action.getResult()) {
            HDC hdc = printdlg.getDC();
            TCHAR* doc = _T("TEXT");
            DOCINFO docInfo;
            memset(&docInfo, 0, sizeof(DOCINFO));
            docInfo.cbSize = sizeof(DOCINFO);
            docInfo.lpszDocName = _T("Text");

            StartDoc(hdc, &docInfo); 
            StartPage(hdc);
    
            TCHAR* text = _T("Hello world");
            TextOut(hdc, 200, 200, text, strlen(text));
            EndPage(hdc);
            EndDoc(hdc);
        }
    }

public:
    /**
     * Constructor
     */
    AppView(Application& applet, const TCHAR* name, Args& args)
        :ApplicationView(applet, name, args)
    {
        Args ar;
        printdlg.create(this, NULL, ar);

        addCallback(XmNmenuCallback, IDM_PRINT, this,
            (Callback)&AppView::print, null);

        addCallback(XmNmenuCallback, IDM_EXIT, this,
            (Callback)&AppView::exit, null);

        restorePlacement();
    }
};

}

//
void    Main(int argc, TCHAR** argv)
{
    const TCHAR* name = _T("AppView");
    try {
        Application applet(name, argc, argv);
    
        Args args;
        AppView appView(applet, name, args);
        appView.realize();
        applet.run();
    } catch (...) {

    }
}


Last modified: 11 Nov 2009

Copyright (c) 2009 Antillia.com ALL RIGHTS RESERVED.