2007-12-03

Mental Block

I must have one about coordinate-system transformations in windows.

Problem I spent literally all day on was to display the Acrobat reader ActiveX control in an application so that only the document itself was visible.

That bit was OK.

Then I had to handle the zooming manually - if the user was allowed to use the Acrobat viewing, they'd screw up the mapping between the application window coordinates and the displayed page.

There's where the fun began. There was an offset (to hide the Acrobat framework), a zoom-factor and the visible top-left point of the page to convert between windowing coordinates and a normalised page coordinate system (0 to 1).

Could I handle zooming in/out? It just did my head in - figuring out which window (application, Acrobat container, page view window) should be used for calculating sccaling factors etc.

Eventually sussed it out. Simple in the end of course with a couple of gotchas in the behaviour of the MFC CScrollView class.

Small disclaimer: I hacked the code together a year ago in a hurry when I was trying to figure out an overlay for the viewer. This made it all pretty confusing. Note to self - review commenting and function-naming style!!!