dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Scrollview & redraw

  1. #1
    Join Date
    May 2008
    Posts
    36

    Arrow Scrollview & redraw

    What my view displays is not redrawn once I move the thumb bar up or down past the hidden text ?
    What should I add in to make it viewable when dragging the thumb downward or rightward ?

    rc is declared as a global variable;

    In OnDraw function

    GetWindowRect(&rc);
    pDC->LPToDP(&rc);
    pDC->DrawText(L"Draw text",&rc,TA_LEFT);


    In OninitialUpdate

    CClientDC dc(this);
    OnPrepareDC();
    CSize sz(rc.With(),rc.Height());
    dc.LPToDP(&sz);
    SetScrollSizes(MM_TEXT,sz);

    It's all about the cscrollview I use in my single document.

    Thank you.

  2. #2
    Join Date
    Nov 2009
    Posts
    45

    Re: Scrollview & redraw

    For drawing text, please use logic point not the device point, so please try:
    pDC->DPtoLP(...)
    Jack
    --------------------------------------------------------------------------------
    HMI/SCADA/CAD/GIS VC++ Source Codes: http://www.code-home.com

  3. #3
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: Scrollview & redraw

    Quote Originally Posted by ChayKieu View Post

    rc is declared as a global variable;
    Why? This is not a good idea to use a global variable.

    Where are you initialzing rc ?

    Instead of the global rc use rather a view's or doc's member depending on what you want to achieve (drawing "Draw Text" is for sure not your end goal...).

    Quote Originally Posted by ChayKieu View Post
    In OnDraw function

    GetWindowRect(&rc);
    pDC->LPToDP(&rc);
    pDC->DrawText(L"Draw text",&rc,TA_LEFT);
    Why are you using GetWindowRect? Why are you using the LPtoDP function at all?

    Think of what you really want to do in your OnDraw handler.
    If you want to draw the text exactly in the view:
    Code:
    CRect rClient;
    GetClientRect(&rClient);
    pDC->DrawText(L"Text\r\nText line 2\r\n...", &rClient, TA_LEFT);
    But for this there is absolutely no need to have a scroll view.

    If you want to draw the text in a certain area (that can be scrolled via the scrollbars) then use this certain area (maybe calculated via DrawText with the DT_CALCRECT flag set; Details see MSDN).

    Then you do not need to call GetWIndowRect or GetCLientRect at all. All you have to do is
    Code:
    pDC->DrawText(L"Text\r\nText line 2\r\n...", &m_myFixedArea, TA_LEFT);
    And of course you have to set SetScrollSizes to this certain area.

    With regards
    PA

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)