티스토리 뷰

Code/Project

OSD.BeeTextOut

Hide Code 2009. 4. 4. 20:03

OSD.BeeTextOut.1000.zip



PowerPro Plug-in bee.dll 과 함께 사용하는 프로그램입니다.




#include "stdafx.h"

#include "CmdLineParser.h"


void WINAPI initializeDefault();

void WINAPI parseCommandLine();

COLORREF WINAPI parseColor(CString);


HINSTANCE hInstanceMain;


int cxScreen; // The width of the screen, in pixels.

int cyScreen; // The height of the screen, in pixels.


CString m; // Notice Message

int x; // x-coordinate of starting position

int y; // y-coordinate of starting position

int xb; // x-coordinate base point indicator (0:Left, 1:Center, 2:Right)

int yb; // y-coordinate base point indicator (0:Top, 1:Baseline, 2:Bottom)

UINT textAlign; // Text Align Mode


CString f; // font name

int fh; // height of font

int fw; // average character width

DWORD fi; // italic attribute option (0 or 1)

DWORD fu; // underline attribute option (0 or 1)

DWORD fs; // strikeout attribute option (0 or 1)

COLORREF ftc; // font text color (RGB)

COLORREF fbc; // font background color (RGB)


int o; // opacity (1 TRANSPARENT, 2 OPAQUE)


int a; // text angle (-3600 <= a <= 3600)


void WINAPI initializeDefault()

{

    cxScreen = GetSystemMetrics(SM_CXSCREEN);

    cyScreen = GetSystemMetrics(SM_CYSCREEN);


    m = _T("bee");

    x = cxScreen / 2;

    y = cyScreen / 2;

    xb = 0;

    yb = 0;

    textAlign = 0;


    f = _T("Tahoma");

    fh = 0;

    fw = 0;

    fi = 0;

    fu = 0;

    fs = 0;

    ftc = RGB(255, 0, 0); // Red

    fbc = RGB(255, 255, 255); // White


    o = 2; // OPAQUE


    a = 0;

}


void WINAPI parseCommandLine()

{

    CCmdLineParser parser(GetCommandLine());


    if (parser.HasKey(_T("m"))) {

        m = parser.GetVal(_T("m"));

    }


    if (parser.HasKey(_T("x"))) {

        x = _ttoi(parser.GetVal(_T("x")));

        x = max(x, 0);

        x = min(x, cxScreen);

    }


    if (parser.HasKey(_T("y"))) {

        y = _ttoi(parser.GetVal(_T("y")));

        y = max(y, 0);

        y = min(y, cxScreen);

    }


    if (parser.HasKey(_T("xb"))) {

        xb = _ttoi(parser.GetVal(_T("xb")));

        xb = max(xb, 0);

        xb = min(xb, 2);


        switch (xb)

        {

        case 0:

            textAlign |= TA_LEFT;

        break;

        case 1:

            textAlign |= TA_CENTER;

            break;

        case 2:

            textAlign |= TA_RIGHT;

            break;

        default:

            textAlign |= TA_LEFT;

            break;

        }

    }


    if (parser.HasKey(_T("yb"))) {

        yb = _ttoi(parser.GetVal(_T("yb")));

        yb = max(yb, 0);

        yb = min(yb, 2);


        switch (yb)

        {

        case 0:

            textAlign |= TA_TOP;

            break;

        case 1:

            textAlign |= TA_BASELINE;

            break;

        case 2:

            textAlign |= TA_BOTTOM;

            break;

        default:

            textAlign |= TA_TOP;

            break;

        }

    }


    if (parser.HasKey(_T("f"))) {

        f = parser.GetVal(_T("f"));

    }


    if (parser.HasKey(_T("fh"))) {

        fh = _ttoi(parser.GetVal(_T("fh")));

    }


    if (parser.HasKey(_T("fw"))) {

        fw = _ttoi(parser.GetVal(_T("fw")));

    }


    if (parser.HasKey(_T("fi"))) {

        fi = _ttoi(parser.GetVal(_T("fi")));

        fi = (fi == 0) ? 0 : 1;

    }


    if (parser.HasKey(_T("fu"))) {

        fu = _ttoi(parser.GetVal(_T("fu")));

        fu = (fu == 0) ? 0 : 1;

    }


    if (parser.HasKey(_T("fs"))) {

        fs = _ttoi(parser.GetVal(_T("fs")));

        fs = (fs == 0) ? 0 : 1;

    }


    if (parser.HasKey(_T("ftc"))) {

        ftc = parseColor(parser.GetVal(_T("ftc")));

    }


    if (parser.HasKey(_T("fbc"))) {

        fbc = parseColor(parser.GetVal(_T("fbc")));

    }


    if (parser.HasKey(_T("o"))) {

        o = _ttoi(parser.GetVal(_T("o")));

        o = max(o, 1);

        o = min(o, 2);

    }


    if (parser.HasKey(_T("a"))) {

        a = _ttoi(parser.GetVal(_T("a")));

        a = max(a, -3600);

        a = min(a, 3600);

    }

}


COLORREF WINAPI parseColor(CString rgbString)

{

    int curPos = 0;

    int r = _ttoi(rgbString.Tokenize(_T(" "), curPos));

    int g = _ttoi(rgbString.Tokenize(_T(" "), curPos));

    int b = _ttoi(rgbString.Tokenize(_T(" "), curPos));


    r = max(r, 0);

    r = min(r, 255);

    g = max(g, 0);

    g = min(g, 255);

    b = max(b, 0);

    b = min(b, 255);


    return RGB(r, g, b);

}


int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)

{

    hInstanceMain = hInstance;


    initializeDefault();

    parseCommandLine();


    HDC hdc = GetDC(NULL);

    HFONT newFont = CreateFont(fh, fw, a, 0, 0, fi, fu, fs, 0, 0, 0, 0, 0, (LPCTSTR)f);

    HFONT oldFont = (HFONT)SelectObject(hdc, newFont);

    SetTextColor(hdc, ftc);

    SetBkColor(hdc, fbc);

    SetBkMode(hdc, o);

    SetTextAlign(hdc, textAlign);

    TextOut(hdc, x, y, (LPCTSTR)m, m.GetLength());

    SelectObject(hdc, oldFont);

    DeleteObject(newFont);

    ReleaseDC(NULL, hdc);


    return 0;

}



'Code > Project' 카테고리의 다른 글

Detours : DetouredRegistry  (0) 2009.04.14
Detours : DetouredSample  (0) 2009.04.13
PowerPro Plugin bee.dll  (0) 2009.04.04
OSD.BeeNotice  (0) 2009.04.04
[Project] fileHook, BeeHook  (0) 2009.02.27
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함