| 
  SOL9 Sample: ColorChooser
 | 
1 Screenshot
2 Source code
/*
 * ColorChooser.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */
// SOL++2000
// 2000.06.15
#include <sol\ApplicationView.h>
#include <sol\ColorChooser.h>
#include <sol\ColorBox.h>
#include "resource.h"
namespace SOL {
class MainView :public ApplicationView {
private:
  ColorChooser colorChooser;
  COLORREF   rgb;
  ColorBox   colorBox;
public:
  /**
   * Constructor
   */
  MainView(Application& applet, const TCHAR* label, Args& args)
    :ApplicationView(applet, label, args.set(XmNstyle, WS_CLIPCHILDREN))
  {
    Args ar;
    ar.set(XmNx, 10);
    ar.set(XmNy, 10);
    ar.set(XmNstyle, WS_VISIBLE);
    //ar.set(XmNstyle, (ulong)SS_OWNERDRAW);
    colorChooser.create(this, NULL, ar);
    
    rgb = colorChooser.getCurrentColor();
    ar.reset();
    colorBox.create(this, NULL, ar);
    colorBox.setColor(rgb);
    addEventHandler(WM_COLORCHOOSER_PICKED, this,
      (Handler)&MainView::picked, NULL);
    addCallback(XmNmenuCallback, IDM_EXIT, this, 
      (Callback)&MainView::exit, NULL);
  }
private:
  long picked(Event& event)
  {
    rgb = (COLORREF)event.getLParam();
    colorBox.setColor(rgb);
    
    return 0L;
  }
private:
  long size(Event& event)
  {
    int width, height;
    event.getSize(width, height);
    
    WINDOWPLACEMENT p;
    colorChooser.getPlacement(&p);
    RECT rc =p.rcNormalPosition;
    
    //colorChooser.getSize(w, h);
    colorBox.reshape(rc.right, 10, width-(rc.right-rc.left)-20, height-20); 
    return 0L;
  }
};
}
//
void  Main(int argc, TCHAR** argv)
{
  ModuleFileName module(argv[0]);
  const TCHAR* name = module.getFileName();
  try {
    Application applet(name, argc, argv);
    Args args;
    args.set(XmNwidth, 540);
    args.set(XmNheight, 580);
  
    //2009/10/11 To avoid a window flicker
    args.set(XmNclassStyle, 0);
    args.set(XmNexStyle, (ulong)WS_EX_CLIENTEDGE);
    MainView colorModel(applet, name, args);
    colorModel.realize();
    applet.run();
    
  } catch (Exception& ex) {
    caught(ex);
  } catch (...) {
    caught(UnknownException());
  } 
}
Last modified: 1 Feb 2017
Copyright (c) 2017  Antillia.com ALL RIGHTS RESERVED.