SOL9 2.0 Sample: RubberBand

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


// SOL++2000
// 2000.02.18


#include <sol\ApplicationView.h>
#include <sol\ClientDC.h>
#include <sol\StockObject.h>

namespace SOL {

class AppView :public ApplicationView {
private:
    POINT    beg;
    POINT    end;
    int        capturing;

public:
    AppView(Application& applet, const TCHAR* name, Args& args)
    :ApplicationView(applet, name, args)
    {
        capturing = FALSE;
        addEventHandler(WM_LBUTTONDOWN, this, 
            (Handler)&AppView::leftButtonDown, NULL);
        addEventHandler(WM_MOUSEMOVE, this, 
            (Handler)&AppView::mouseMove, NULL);
        addEventHandler(WM_LBUTTONUP, this, 
            (Handler)&AppView::leftButtonUp, NULL);
    }

private:
    long leftButtonDown(Event& event)
    {
        event.getMousePosition(&beg);
        end.x     = beg.x;
        end.y     = beg.y;
        capturing = TRUE;
        return 0;
    }

private:
    long mouseMove(Event& event)
    {
        ClientDC cdc(this);

        StockObject brush(NULL_BRUSH);
        cdc.select(&brush);
        cdc.setROP2(R2_NOTXORPEN);
        if(capturing == TRUE) {
            cdc.rectangle(beg.x, beg.y, end.x, end.y);
            event.getMousePosition(&end);
            cdc.rectangle(beg.x, beg.y, end.x, end.y);
        }
        return 0;
    }

private:
    long leftButtonUp(Event& event)
    {
        capturing = FALSE;
        return 0;
    }
};

}

//
void Main(int argc, TCHAR** argv) 
{
    const String name = "RubberBand";
    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.