none
Writing text to an LCD screen / WinCE6.0+VS2005

    Question

  • Anyone have any idea why won't this code won't work for WinCE6.0/PlatformBuilder/VS2005+MFC for an LCD on a smart device ARM development kit?  It works in the OnPaint() function only, but nowhere else in the code like from a button control handler:

    CPaintDC dc2 (this);

    dc2.SetTextColor (RGB (0,0,255));

    dc2.SetBkColor(RGB(255,0,0)); 

    int num2 = 123;

    WCHAR string2[11];

    size_t strlen2 = 11;           //max string length of integer

    LPCTSTR format2 = L"%s %d";

    WCHAR* insert2 = L"screen";

    StringCchPrintfW(string2,strlen2,format2,insert2,num2);  //convert int to LPCTSTR `

     ExtTextOut(dc2,50,50,0,NULL,string2,strlen2,NULL);      //wcslen for wide characters

    (Tried using a Rectangle, but that made no difference.)

    Thanks for your help.  CM007


    • Edited by CodeMan007 Thursday, February 16, 2012 3:40 PM
    Thursday, February 16, 2012 5:11 AM

Answers

  • Hello,

    If your codes in MFC project, I suggest you to use  CClientDC to drawtext.

    And call this function  CClientDC.ExtTextOut()
    http://msdn.microsoft.com/zh-cn/library/e28c8dxx.aspx

    The ExtTextOut function need HDC
    http://msdn.microsoft.com/en-us/library/dd162713(v=vs.85).aspx
    You need to use
    hdc=::GetDC(m_hWnd); to get the hdc.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by CodeMan007 Friday, February 17, 2012 6:33 PM
    Friday, February 17, 2012 9:41 AM
    Moderator
  • Hi Jesse,

    I think you replied to one of my earlier posts.  Don't know who you are, but you are excellent!  What you suggested worked.  Now I have the writing capaility that I need as well as the location of the rest of the MFC member functions that I'll need going forward.  Thank you for being such a valuable resource, and for taking the time to help the rest of us.

    CM007

    • Marked as answer by CodeMan007 Friday, February 17, 2012 6:37 PM
    Friday, February 17, 2012 6:37 PM

All replies

  • Hello,

    If your codes in MFC project, I suggest you to use  CClientDC to drawtext.

    And call this function  CClientDC.ExtTextOut()
    http://msdn.microsoft.com/zh-cn/library/e28c8dxx.aspx

    The ExtTextOut function need HDC
    http://msdn.microsoft.com/en-us/library/dd162713(v=vs.85).aspx
    You need to use
    hdc=::GetDC(m_hWnd); to get the hdc.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by CodeMan007 Friday, February 17, 2012 6:33 PM
    Friday, February 17, 2012 9:41 AM
    Moderator
  • Hi Jesse,

    I think you replied to one of my earlier posts.  Don't know who you are, but you are excellent!  What you suggested worked.  Now I have the writing capaility that I need as well as the location of the rest of the MFC member functions that I'll need going forward.  Thank you for being such a valuable resource, and for taking the time to help the rest of us.

    CM007

    • Marked as answer by CodeMan007 Friday, February 17, 2012 6:37 PM
    Friday, February 17, 2012 6:37 PM