CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Posts
    3

    Write Text On Desktop Background (in Windows OS)

    Hi,

    I want to write text on the desktop background that updates itself every X seconds.

    Can someone show me simple sample C/C++ code how to write for example text "Hello" on desktop background.


    Best regards

  2. #2
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Write Text On Desktop Background (in Windows OS)

    I don't see this being any harder than writing text on a window. But instead of using a clientDC, you would use the screenDC. Look up device contexts on windows.

  3. #3
    Join Date
    Jul 2009
    Posts
    3

    Re: Write Text On Desktop Background (in Windows OS)

    Any piece of code i.e. example using screenDC for this purpose?

    What I need is possibility to change text font and that text written on desktop stays even if we move other windows, mouse etc over screen.

    This is what I try but this way I can not play with text font and text disappear after moving other windows, mouse... over screen:

    --------------------------------------------------------------------------------------------------------------------------------------------------------
    int DrawOnSC(char szBuffer[], int bottom, int left, int right, int top, RECT& rect, HDC& hdc, HWND& hwnd, int& iLength) {

    SetRect(&rect, bottom, left, right + 34, top + 34);
    DrawText(hdc, szBuffer, iLength, &rect, 32);

    return 0;
    }


    int main()
    {
    RECT rect;
    TCHAR szBuffer[50] = {0}; // Text to be outputted
    HWND hWnd = GetActiveWindow();
    HDC hdc = ::GetWindowDC(NULL);
    int iLength = 0;

    iLength = wsprintf(szBuffer, "Hello World!");
    DrawOnSC(szBuffer, 50, 50, 150, 50, rect, hdc, hWnd, iLength); //function call

    return 0;
    }
    --------------------------------------------------------------------------------------------------------------------------------------------------------

    Anny suggestions how to be abble to change text font and that text stays over other windows i.e. always in front of screen?


    Thanks in advance
    Last edited by melinda123; February 18th, 2010 at 04:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured