SOL9 Sample: ColorDialog

SOL9 2.0 Samples

1 Screenshot


2 Source code

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



// SOL9 
// 2000.02.18
// 2009/10/08
// 2012/08/09 Updated paint method.

#define COMMONCONTROLS_V6

#include <sol\ApplicationView.h>
#include <sol\ColorDialog.h>
#include <sol\FontDialog.h>
#include <sol\Brush.h>
#include <sol\PaintDC.h>
#include "resource.h"

namespace SOL {

class AppView :public ApplicationView {
  COLORREF    color;
  ColorDialog    colordlg;

  long  paint(Event& event) 
  {     
    PaintDC pdc(this);
    for (int i = 0; i<100; i++) {

      Brush brush(color+2*i);
      HGDIOBJ prev = pdc.select(&brush);
      pdc.ellipse(0+2*i, 0+2*i, 100+2*i, 50+2*i);
      pdc.select(prev);
    }
    return 0;
  }

  void  setColor(Action& action)
  {
    colordlg.popup(action);
    color = colordlg .getRGBResult();
    invalidateAll();
    update();
  }

  public:
  AppView(Application& applet, const TCHAR* name, Args& args)
    :ApplicationView(applet, name, args)
  {
    color = RGB(0, 0, 255);
    Args ar;
    colordlg.create(this, NULL, ar);

    addCallback(XmNmenuCallback, IDM_COLOR, this,
      (Callback)&AppView::setColor, NULL);
    addCallback(XmNmenuCallback, IDM_EXIT, this,
      (Callback)&AppView::exit, NULL);

    addEventHandler(WM_PAINT, this,
      (Handler)&AppView::paint, 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.