I am developing this little app in which there's a table and the user may scroll sideways to view the full table and choose to make an entry in any of the cells by clicking on the respective cell.
When the screen is not scrolled (m_nHScrollPos is zero) and when I click on a cell, the app creates a CEdit control in that particular cell and it's all good. However, when I scroll sideways (m_nHScrollPos > 0) to further reveal the table and then click on the cell which appears, the app creates a CEdit control which is offset greatly to the right (from it's actual required position).
It appears to be a problem with the origin to my inexperienced programmer mind. Please note that to bring about the scroll effect, in the OnPaint handler, I have used pDC->SetwindowOrg(m_nHscrollPos, m_nVScrollPos).
I'd be grateful if you could shed light on this problem. I've been working on this problem for quite a while already...
SelectGhostTexts() displays the old (destroyed) CEdit's data. cNewEntry.SetValues(..) sets the exact CRects for all the required CEdit cells which are crEntries[4]. Finally, cNewEntry.DestroyTextIn() destroys the window after retrieving the CEdit's information.
Then I guess that's where you have to adjust the position of the rectangle for the scrolling.
I have been trying precisely that. Any suggestions as to how I can do that? What sort of adjustment would I have to do? I have tried many combinations but none of them work.
I have been trying precisely that. Any suggestions as to how I can do that? What sort of adjustment would I have to do? I have tried many combinations but none of them work.
I had hoped that perhaps this was a standard problem.
I have been trying precisely that. Any suggestions as to how I can do that? What sort of adjustment would I have to do? I have tried many combinations but none of them work.
It's just plain logic. Think what the values should be and adjust the way the actual values are calculated such that they match.
You can also do this using trial-and-error by scrolling just a little bit and observing how the edit is misplaced. If it's too far to the right, you'll have to decrease the left and right values in the rectangle. If it's too low, you'll have to increase the top and bottom values.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
I could do that. But wouldn't it be a problem when I run the app on a computer with different monitor specifications having different resolutions? Dabbling with pixels can cause such errors, right?
I could do that. But wouldn't it be a problem when I run the app on a computer with different monitor specifications having different resolutions? Dabbling with pixels can cause such errors, right?
Different resolution, different settings, different theme, even a different window placement could reveal a bug in your code. So you should test for all of these things to make sure your code works correctly in all situations. If your code uses magic numbers, it's likely to fail in a different situation. So make sure you call the proper Windows functions to get the size of scrollbars, etc.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Bookmarks