SOL9 2.0 Sample: ColorDialog

SOL9 2.0 Samples

1 Screenshot


2 Source code

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



// SOL++2000 
// 2000.02.18
// 2009/10/08

#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);
        Brush brush(color);
        HGDIOBJ prev = pdc.select(&brush);
        pdc.ellipse(0, 0, 100, 50);
        pdc.select(prev);
        return 0;
    }

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

  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);
    }
};

}

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.