Prev: Clear CWnd Child with png
Next: MDI GUI
From: Martin B. on 1 Mar 2010 12:09 Hi all, We have a module that uses custom printing code (no CView involved, just drawing to a custom allocated device context) to print out tabular data (numbers, text, borders) one or more pages. If there are too many lines the table will just be continued on the next page. Problem: We need to split the table to multiple pages horizontally, that is if the columns don't fit on one page width, we would like for the printed out report to use a "width" of two pages (or more). Since my experience with either printing in Windows C++ and device contexts in general is very limited, I would like to ask for any tips / pointers on how to achieve this. Help! :-) cheers, Martin
From: Joseph M. Newcomer on 1 Mar 2010 13:52 Consider your pages are AB CD where each letter represents one page. You will write out the pages by writing A, B, C, D To do this, I'd most likely draw in terms of the logical coordinate system, where I did SetWindowOrg for page B to be the rightmost pixel of A (modulo boundary conditions; for example in GM_ADVANCED, Org(B) = Org(A) + width(A) + 1, but in GM_COMPATIBLE mode Org(B) = Org(A) + width(A), because width-1 pixels printed in A. You generalize this for more horizontal output. Note that you have to worry about the actual printable area, because some printers have fixed margins (e.g., most printers have a 0.3" border, except those that have 0.25", and those that can do "full bleed" edge-to-edge). For columnar data, you probably don't want to split columns, so you would "truncate down" the right edge to the previous column value and start the next page by matching the origin. So if you have columns | A | B | C | where the page width is | | | (The appearance is going to depend on the fonts you are using to read this, but the intent is that the middle line is just below the B in the middle column) you would print out pages | A | | B | | C | note that in this case, you print out the rightmost border of the A column, and repeat as the leftmost border of the B column, by adjusting your SetWindowOrg. Now, if you have performance problems, you can be "smart" about the formatting, and not format anything that is to the left of the X-org or beyond the right of X-org + width(columns)+border. Generally, GDI will do the clipping more efficiently than you can, but not always, so you have to use your judgment here. But don't assume you need to do the clipping unless there is a distinct performance problem you are detecting. joe On Mon, 01 Mar 2010 18:09:22 +0100, "Martin B." <0xCDCDCDCD(a)gmx.at> wrote: >Hi all, > >We have a module that uses custom printing code (no CView involved, just >drawing to a custom allocated device context) to print out tabular data >(numbers, text, borders) one or more pages. If there are too many lines >the table will just be continued on the next page. > >Problem: We need to split the table to multiple pages horizontally, that >is if the columns don't fit on one page width, we would like for the >printed out report to use a "width" of two pages (or more). > >Since my experience with either printing in Windows C++ and device >contexts in general is very limited, I would like to ask for any tips / >pointers on how to achieve this. > >Help! :-) > >cheers, >Martin Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Martin B. on 2 Mar 2010 03:27 Joseph M. Newcomer wrote: > Consider your pages are > > AB > CD > > where each letter represents one page. > > You will write out the pages by writing > > A, B, C, D > > To do this, I'd most likely draw in terms of the logical coordinate system, where I did > SetWindowOrg for page B to be the rightmost pixel of A (modulo boundary conditions; for > example in GM_ADVANCED, Org(B) = Org(A) + width(A) + 1, but in GM_COMPATIBLE mode Org(B) = > Org(A) + width(A), because width-1 pixels printed in A. > > You generalize this for more horizontal output. > > (....) Thanks for the pointers so far. SetWindowOrg was a useful hint to find some articles on the device context coordinates stuff. cheers, Martin
|
Pages: 1 Prev: Clear CWnd Child with png Next: MDI GUI |