views:

30

answers:

0

I tryed to write my first Windows Mobile application, and I have used the following sample to create my custom Today plugin.

To write dynamic text into today the following code is used:

  case WM_PAINT: 
    PAINTSTRUCT   ps;
    RECT      rcWindBounds; 
    RECT      rcMyBounds;
    HDC       hDC;
    HFONT     hFontOld;
    TCHAR     szTextBuffer[128];
    COLORREF    crText;

    RefreshStatuses();

    GetWindowRect( hwnd, &rcWindBounds); 

    hDC = BeginPaint(hwnd, &ps);

    rcMyBounds.left = 0;
    rcMyBounds.top = 0;
    rcMyBounds.right = rcWindBounds.right - rcWindBounds.left;
    rcMyBounds.bottom = rcWindBounds.bottom - rcWindBounds.top;      

    SetBkMode(hDC, TRANSPARENT);

    LOGFONT lf;
    HFONT hSysFont;
    HFONT hFont;   
    hSysFont = (HFONT) GetStockObject(SYSTEM_FONT);
    GetObject(hSysFont, sizeof(LOGFONT), &lf);
    lf.lfWeight = FW_NORMAL;
    lf.lfHeight = (long) -((6.0 * (double)GetDeviceCaps(hDC, LOGPIXELSY) / 72.0)+.5);

    hFont = CreateFontIndirect(&lf);  
    hFontOld = (HFONT) SelectObject(hDC, hFont);
    crText = SendMessage(GetParent(hwnd), TODAYM_GETCOLOR, (WPARAM) TODAYCOLOR_TEXT, NULL);
    SetTextColor(hDC, crText);

    wsprintf(szTextBuffer, TEXT("text1: %i, text2: %i"), 5, 10);

    SetWindowText(g_hTasks,szTextBuffer);
    SetWindowPos(g_hTasks, g_hWnd, rcMyBounds.left + 2, rcMyBounds.top + 2, 200, 16, SWP_SHOWWINDOW);
    ::SendMessage(g_hTasks,WM_SETFONT,(WPARAM)hFont,MAKELPARAM(TRUE,0));

    SelectObject(hDC, hFontOld);
    DeleteObject(hFont);
    EndPaint(hwnd, &ps);
    break;

As result I can see on Today-Screen black symbols "text1: 5, text2: 10" on white background. Now I know how to change the color of the symbols, but how to set the backround to Today background?

Thanks!