 |
|
 |
Tank for the of multipage!
|
|
|
|
 |
|
 |
Very useful! thanks a lot!!
When i change the header string to Chinese
it does not print correctly and
i found that "_tcsinc" function moves two bytes
when it find chinese character I just use lpszText++
instead, so it works.
I am i right to change it that way?
Sorry for my bad Engish....
|
|
|
|
 |
|
 |
hello sir,
i try this code and its working fine. i want to increase the left and top margin but i dont know how to do that.
so can u tell me how can i increase magrins in this application.
thanks in advance.
vimal
|
|
|
|
 |
|
 |
A far as I understand, if listview control has only one column, it will neve be printed. The problem is in void CListCtrlPrintJob::OnPrint(). The "for" cycle should start from 0.
|
|
|
|
 |
|
 |
I need to print my reports in landscape and changed some of the code to accomplish this. My problem is sometimes the reports print in portrait. It just happens randomly because I will not change the code and just send the same report printing several times and maybe 1 out of the 5 reports will print portrait. Other times they all print landscape. I am using pDevMode->dmOrientation=DMORIENT_LANDSCAPE to set the printer to landscape and also changing how the CRECT is set up. Any ideas what may be going on?
Jon
|
|
|
|
 |
|
 |
hello sir,
I want to print the list and it is placed on the dialog based application and iwant it and i got it in the doc/view and i wnat it in dialog based application by pressing the button and my list may contains more than 300 rows and 10 items so p[lease kindly give the code for this problem .
Thanks in advance.
Regards,
Malli
Malli
|
|
|
|
 |
|
 |
Same question here. I am just too new to all this stuff as if i could
find an answer to this. Help is really welcome.
Please share.
Best regards
Rootdial
|
|
|
|
 |
|
 |
Hi,
Great job for this print code
Then is there someone that found print preview job ? And is there a way to print icons / images before first column ????
I'm trying to find it but not very easy
---------
| Luke_21 |
---------
|
|
|
|
 |
|
 |
Hi.
I used your example and found it very good and usefull. tThe problem is I couldn't find any way to print few list controls in THE SAME PAGE. Suppose the content of each list control is short enough to put them all in the same page, is there any way to do it? is there any way to add one or more lines of text between the list control which are printed in the same page? is the any way to combine different structs, such as list control, few lines of text and an image, at the same page?
These abilities are very critical for me, and I'll EXTREMELY appreciate an answer for my question.
Dudi.
|
|
|
|
 |
|
 |
Hi, I am new to print kind of work..
This solution will work if i am using doc/view architecture. what is i am not using ListCtrl on a Dialog based project ?
Cheers...
Sam
|
|
|
|
 |
|
 |
I utilized this source and made my own application.
It worked nice on most of computer, but it doesn't work on others.
I don't know the differences between them.
Does this source require any specific DLL ?
FYI, I made my application by using VC++ 6.0 with "Use MFC in static library".
Is anyone who could guess the reason why ?
Thanks
|
|
|
|
 |
|
 |
You just had to use MFC in shared DLL.
In your case, your program works, only
where VC++6.0 is installed ...
|
|
|
|
 |
|
 |
Hi Markus,
I found this article and its resulting codes very useable. However, i need to print a table with horizontal and vertical grid lines and i can't find an easy way to do it on this code infrastructure.
I need help on this grid issue.
Many thanks.
Erkan
|
|
|
|
 |
|
 |
The classes are working fine, with any printer I chose, but if I want to print to a *.pdf File with Acrobat Distiller nothing is going on. Can someone help me?
|
|
|
|
 |
|
 |
The common print dialog has various style flags such as:
PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_HIDEPRINTTOFILE
How do I set them?
I figured it out:
I can set them in the GPrintJob::InitPrintDialog()function, e.g. pDialog->m_pd.Flags |= PD_HIDEPRINTTOFILE ;
or pDialog->m_pd.Flags ^= PD_SELECTION;
|
|
|
|
 |
|
 |
This will allow users to reorder the columns and have them print in the correct order.
void CListCtrlDataPage::DefineColHeadings()
{
int colId = 0,
i;
double widthOfPage;
LV_COLUMN col;
char szText[200];
if( !m_pListCtrl ) return;
// The pointer to my header control.
CHeaderCtrl* pmyHeaderCtrl = m_pListCtrl->GetHeaderCtrl();
int nCount = pmyHeaderCtrl->GetItemCount();
LPINT pnOrder = (LPINT) malloc(nCount*sizeof(int));
pmyHeaderCtrl->GetOrderArray(pnOrder, nCount);
col.mask = LVCF_TEXT;
col.pszText = szText;
col.cchTextMax = sizeof(szText);
// this is the spacing of all columns to print
widthOfPage = m_pListCtrl->GetColumnWidth(0);
for( i= m_firstCol ; i<=m_lastCol ; i++ )
widthOfPage += m_pListCtrl->GetColumnWidth(i);
// define my columns...percentages should all up to 1.00
m_pListCtrl->GetColumn(pnOrder[0], &col);
InsertPrintCol(colId++, szText, ((double)m_pListCtrl->GetColumnWidth(0))/widthOfPage);
for( i= m_firstCol ; i<=m_lastCol ; i++ )
{
m_pListCtrl->GetColumn(pnOrder[i], &col);
InsertPrintCol(colId++, szText, ((double)m_pListCtrl->GetColumnWidth(i))/widthOfPage);
}
free(pnOrder);
// must call base class
GPrintUnit::DefineColHeadings();
}
BOOL CListCtrlDataPage::Print()
{
char szText[200];
int zeile,
spalte,
zeilenMax,
colId,
nRC;
GPrintUnit::Print();
if( !m_pListCtrl )
return FALSE;
// The pointer to my header control.
CHeaderCtrl* pmyHeaderCtrl = m_pListCtrl->GetHeaderCtrl();
int nCount = pmyHeaderCtrl->GetItemCount();
LPINT pnOrder = (LPINT) malloc(nCount*sizeof(int));
pmyHeaderCtrl->GetOrderArray(pnOrder, nCount);
StartPage();
/* {
GSELECT_OBJECT(&JDC, &m_fontHeading);
PrintColHeadings(DT_LEFT);
}
*/ GSELECT_PUFONT(&JDC, &m_fontPairBody);
zeilenMax = m_pListCtrl->GetItemCount();
for( zeile=0 ; zeileGetItemText(zeile, pnOrder[colId], szText, sizeof(szText)) )
PrintCol(colId, szText, DT_LEFT);
colId++;
for( spalte=m_firstCol ; spalte<=m_lastCol ; spalte++ )
{
if( m_pListCtrl->GetItemText(zeile, pnOrder[colId], szText, sizeof(szText)) )
PrintCol(colId, szText, DT_LEFT);
colId++;
}
EndRow();
}
EndPage();
free(pnOrder);
return TRUE;
}
Rudy J. Crespin
|
|
|
|
 |
|
 |
Yes, this is good. However, you missed a few lines.
The calls to GetColumnWidth should also use pnOrder[] rather than the raw index.
Scot Brennecke
Software Developer
|
|
|
|
 |
|
 |
The text font was correct on the first page, but on subsequent pages the font had changed.
... Fig
|
|
|
|
 |
|
 |
Ya, this is quite easily fixed...
Change the code above to something like this...
void CListCtrlPrintJob::OnPrint()
{
...
widthOfPage = m_pListCtrl->GetColumnWidth(0);
iStart = 1;
for( i=1 ; iGetColumnWidth(i);
bNewPage = FALSE;
if( widthOfPage+widthThisCol > paperWidthInPixel )
{
// not enough place on side, begin new one
bNewPage = TRUE;
}
else
{
// also print the last one
if( i == (m_ColCount-1) )
bNewPage = TRUE;
// this col needs this space:
widthOfPage += widthThisCol;
}
if( bNewPage )
{
// ok, print it on a new page
int nStartCol = 0;
int nEndCol = m_pListCtrl->GetItemCount();
bool bMore = TRUE;
while (bMore)
{
CListCtrlDataPage data(this, m_pListCtrl, iStart, i);
bMore = data.Print(nStartCol);
iStart = i+1;
widthOfPage = m_pListCtrl->GetColumnWidth(0);
}
}
}
CListCtrlDataPage is derived from GPrintUnit and also has this print-function:
BOOL CListCtrlDataPage::Print(int &nStartCol)
{
...
zeilenMax = m_pListCtrl->GetItemCount();
for( zeile=nStartCol ; zeileif (nRC == SR_ADVANCEPAGE)
{
nStartCol = zeile;
return TRUE; /* more to print */
}
// first Col
if( m_pListCtrl->GetItemText(zeile, 0, szText, sizeof(szText)) )
PrintCol(colId, szText, DT_LEFT);
colId++;
for( spalte=m_firstCol ; spalte<=m_lastCol ; spalte++ )
{
if( m_pListCtrl->GetItemText(zeile, spalte, szText, sizeof(szText)) )
PrintCol(colId, szText, DT_LEFT);
colId++;
}
EndRow();
}
EndPage();
...
return FALSE; /* no more to print */
}
Finally in the GPrintUnit::StartRow method remove the call to StartPage() as you dont want to automatically start a new page when a row wont fit.
The problem seems to be the fonts inside the CListCtrlDataPage object are being "lost", so if you create a brand new object for every physical printed page its ok.
Not the tidiest way, but it worked fine for me.
|
|
|
|
 |
|
 |
Actually, the code changes for the font fix is just a hair incorrect. Printing a second page the way the code is above will only print the first column. All we need to do is move the braces in the right spot. See below.
BOOL CListCtrlDataPage::Print(int &nStartCol)
{
...
while (bMore)
{
CListCtrlDataPage data(this, m_pListCtrl, iStart, i);
bMore = data.Print(nStartCol);
} //move closing brace to here....
iStart = i+1;
widthOfPage = m_pListCtrl->GetColumnWidth(0);
//} //...from here
...
}
|
|
|
|
 |