SOL9 2.0 Class: Cursor

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * Cursor.h 
 * Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL++2000
#pragma once

#include <sol\Resource.h>

#include <sol\DC.h>

namespace SOL {

class Cursor :public Resource {
private:
    int width;
    int height;

public:
    Cursor(const TCHAR* name, HCURSOR hcursor)
    :Resource(name, hcursor)
    {
        width  = ::GetSystemMetrics(SM_CXCURSOR);
        height = ::GetSystemMetrics(SM_CYCURSOR);
    }

public:
    ~Cursor()
    {
        ::DestroyCursor((HCURSOR)get());
    }

public:
    void draw(DC* dc, int x, int y)
    {
        HCURSOR hcursor = (HCURSOR)get();
        if(hcursor) {
            // This works well, because ...
            ::DrawIcon(dc->get(), x, y, hcursor); 
        }
    }

public:
    void draw(DC* dc)
    {
        draw(dc, 0, 0);
    }


/*
    Cursor(const TCHAR* name, HCURSOR hcursor);
    ~Cursor();
    void    draw(DC* dc);
    void    draw(DC* dc, int x, int y);
*/
    void    getSize(int* w, int* h) { *w = width; *h = height; }
};

}



Last modified: 1 Feb 2012

Copyright (c) 2009-2012 Antillia.com ALL RIGHTS RESERVED.