SOL9 Sample: Printdlg

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


// SOL++2000
// 2000.02.18

#define COMMONCONTROLS_V6

#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)
{
  ModuleFileName module(argv[0]);
  const TCHAR* name = module.getFileName();
  try {
    Application applet(name, argc, argv);
  
    Args args;
    AppView appView(applet, name, args);
    appView.realize();
    applet.run();

  } catch (Exception& ex) {
    caught(ex);
  } catch (...) {
    caught(UnknownException());
  }
}


Last modified: 1 Feb 2017

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