-
June 17th, 2011, 03:16 PM
#1
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.
-
June 20th, 2011, 02:09 AM
#2
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
-
June 20th, 2011, 06:05 AM
#3
Re: Scrollview & redraw
Originally Posted by ChayKieu
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...).
Originally Posted by ChayKieu
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|