Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to design a paint program, now i need to use scrollbar. I derived CScrollView. The problem is when i scroll, the coordinates is not what i think.For Example:

I set SetScrollViews(MM_TEXT, 1000x1000) -> when my app is fullscreen (scrollbar disappear), so when i move my mouse to bottom right corner, coordinates will be X=1000, Y=1000.
Then i resize window to 1/4 (that mean clientarea will be 500x500), i move my mouse to bottom right corner, coordinates will be X=500, Y=500 (scrollbar appear), then when i scroll down Hor bar and scroll right Ver bar. Result i expect when i move my mouse to bottom right corner must be X=1000, Y=1000, but the result still be X=500, Y=500.

With problem above, i cant draw shape properly with scroll bar. Can you help me? i appreciate any helps!
Posted

1 solution

You retrieve the mouse position relative to client rect of your window. If you need the position relative to your document (drawing), you must adjust the position by the scrolled range. CScrollView::GetScrollPosition() will give you the document coordinates of the upper left corner that can be added to the mouse position.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900