티스토리 뷰

Code/C C++

Display Number on Tray Icon

Hide Code 2010. 6. 20. 01:14
LRESULT CMainFrame::OnUserTray(WPARAM wParam, LPARAM lParam)
{
    CMenu menu, *pSubMenu;

    if (LOWORD(lParam) == WM_LBUTTONDOWN)
    {
        CString str("369048");
        CString str1 = str.Left(3);
        CString str2 = str.Right(3);

        LPTSTR pstr1 = str1.GetBuffer(str1.GetLength());
        LPTSTR pstr2 = str2.GetBuffer(str2.GetLength());

        LPWSTR wstr1 = new WCHAR[4];
        LPWSTR wstr2 = new WCHAR[4];

        int len1 = MultiByteToWideChar(CP_ACP, 0, pstr1, -1, NULL, NULL);
        MultiByteToWideChar(CP_ACP, 0, pstr1, -1, wstr1, len1);

        int len2 = MultiByteToWideChar(CP_ACP, 0, pstr2, -1, NULL, NULL);
        MultiByteToWideChar(CP_ACP, 0, pstr2, -1, wstr2, len2);

        Bitmap bitmap(16, 16);
        Graphics graphics(&bitmap);

        FontFamily fontFamily(L"Tahoma");
        Font font(&fontFamily, 7, FontStyleRegular, UnitPoint);
        SolidBrush solidBrush(Color(255, 0, 0, 255));

        PointF pointF1(-2, -2);
        graphics.DrawString(wstr1, 3, &font, pointF1, &solidBrush);

        PointF pointF2(-2, 7);
        graphics.DrawString(wstr2, 3, &font, pointF2, &solidBrush);

        HICON hicon;
        bitmap.GetHICON(&hicon);
        m_TrayIcon.SetIcon(hicon);

        DestroyIcon(hicon);

        delete[] wstr1;
        delete[] wstr2;
    }
    else if (LOWORD(lParam) == WM_RBUTTONDOWN)
    {
        CString str("000888");
        CString str1 = str.Left(3);
        CString str2 = str.Right(3);

        CHAR pstr1[4];
        CHAR pstr2[4];

        strcpy(pstr1, str1.GetBuffer(str1.GetLength()));
        strcpy(pstr2, str2.GetBuffer(str2.GetLength()));

        USES_CONVERSION;

        WCHAR* wstr1 = A2W(pstr1);
        WCHAR* wstr2 = A2W(pstr2);

        Bitmap bitmap(16, 16);
        Graphics graphics(&bitmap);

        FontFamily fontFamily(L"Tahoma");
        Font font(&fontFamily, 7, FontStyleRegular, UnitPoint);
        SolidBrush solidBrush(Color(255, 255, 0, 0));

        PointF pointF1(-2, -2);
        graphics.DrawString(wstr1, 3, &font, pointF1, &solidBrush);

        PointF pointF2(-2, 7);
        graphics.DrawString(wstr2, 3, &font, pointF2, &solidBrush);

        HICON hicon;
        bitmap.GetHICON(&hicon);
        m_TrayIcon.SetIcon(hicon);

        DestroyIcon(hicon);
    }

    return 1;
}

공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함