• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 利用VC++開發所見即所得的打印程序

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    成都 田星 所見即所得的打印方式探受大家的歡迎,讀者 開發 自己的所見即 所得的打印程序也不是很困難,只要掌握了 WINDOWS 字體大小以及了 解OnDraw函數與OnPrint函數中應做的工作就能作出比較滿意的程序, 以下是程序生成的步驟: (一)使用Appwizard來創
    成都 田星

    所見即所得的打印方式探受大家的歡迎,讀者開發自己的所見即
    所得的打印程序也不是很困難,只要掌握了WINDOWS字體大小以及了
    解OnDraw函數與OnPrint函數中應做的工作就能作出比較滿意的程序,
    以下是程序生成的步驟:
    (一)使用Appwizard來創建Prt-View.注意:
    1.在classes選擇中將文檔Docu?ment的Class Name中的CPrt-
    viewDoc類改為CsongDoc類,PrtvDoc.h和Prtv?Doc.cpp分別改為s
    ongDoc.h和song?Doc.cpp;視View的prtvvw.h和Prtvvw.cpp分別
    改為songvw.h和songvw.cpp(這樣做的目的是使程序的可讀物性更
    好,因為我們要打印的內容是一首歌詞);另外,將songvw.cpp的基
    類改成帶有滾動條的CScrollView類。 2.在Option選擇中選取prin
    ting And pre?view選項。
    (二)利用ClassWizard為Csongvw類加入WM-CREATE消息控制函
    數。
    (三)打開songdoc.h文件,加入
    public:
    CStringArray m-songArray;
    (四)打開songdoc.cpp文件,在On?NewDocument函數中加入以
    下程序段:
    1 BOOL CSongDoc::onNewDocument()
    2 {
    3 if(!CDocument::OnNewDocument())
    4 return FALSE;
    5 m-songArray.SetSize(13);
    6 m-songArray[0]=”tell me how long,can we go in th
    is way”;
    7 m-songArray[1]=”Just to be strong”;
    8 m-songArray[2]=”We talk through the night”;
    9 m-songArray[3]=”But never reach the other side”;
    10 m-songArray[4]=”We fill our lives”;
    11 m-songArray[5]=”When all that we need,we hold w
    ithin our hearts”;
    12 m-songArray[6]=”When will we find,our way out o
    f the dark”;
    13 m-songArray[7]=”chorus:”
    14 m-songArray[8]=”We know that”;
    15 m-songArray[9]=”Love is the power,love is the k
    ey”;
    16 m-songArray[10]=”Love is the reason,reason to b
    elieve”;
    17 m-songArray[11]=”Love is the answer,when were w
    e see”;
    18 m-songArray[12]=”Love is the power,love is the
    power,”;
    19 return TRUE;}
    20 void CSongDoc::Serialize(CArchive& ar)
    21 } m-songArray.Serialize(ar):}
    (五)打開songvw.cpp,因為我們使用的是滾動視窗,就必須設
    置可見窗口的尺寸,頁的大小等。刪除OnlnitialUp?date函數的內容
    。在OnCreate函數中加入
    1 int CSongView::OnCreate(LPCREATESTRUCT lpCreate Str
    uct)
    2 { if(CScrollView::OnCreate(lpCreateStruct)==-
    1)
    3 return -1;
    4 CSize totalSize=CSize(11520,15120);
    5 CSize pageSize=CSize(totalSize.cx/2,totalSize.cy
    /2);
    6 CSize lineSize=CSize(totalSize.cx/100,totalSize.
    cy/100);
    7 SetScrollSizes(MM-TWIPS,totalSize,pageSize,linSiz
    e);
    8 return 0;}
    在OnDraw函數中加入以下程序段:
    1 void CSongView::OnDraw(CDC*pDC)
    2 { int i,j,nHeight;
    3 char temp[33];
    4 CFont font;
    5 TEXTMETRIC tm;
    6 CSongDoc*pDoc=GetDocument();
    7 pDC->MoveTo(CPoint(0,0));
    8 pDC->LineTo(CPoint(11505,0));
    9 pDC->LineTo(CPoint(11505,-15105));
    10 pDC->LineTo(CPoint(0,-15105));
    11 pDC->LineTo(CPoint(0,0));
    12 //draw external frame of article
    13 for(i=0;i<=8;i=i+1){
    14 wsprintf(temp,”%02d”,i);
    15 pDC->TextOut(i*1440,0,temp);}
    16 for(i=0;i<=10;i++)
    17 { wsprintf(temp,”%02d”,i);
    18 pDC->TextOut(0,-i*1440,temp):}
    19 font.CreateFont(-200,0,0,0,400,FALSE,FALSE,
    0,ANSI-CHARSET,OUT-DEFAULT-PRECIS,CLIP-DEFAULT-PRECI
    S,DEFAULT-QUALITY,DEFAULT-PITCH|FF-ROMAN,”Times New
    Roman”);
    20 CFont* pOldFont=(CFont*)pDC->SelectObject(&f
    ont);
    21 pDC->GetTextMetrics(&tm);
    22 nHeight=tm.tmHeight+tm.tmExternalLeading;
    23 j=pDoc->m-songArray.GetSize();
    24 for(i=0;i<j;i++){
    25 pDC->TextOut(720,-i*nHeight-720,pDoc->m-so
    ngArray[1]);
    26 }
    27 pDC->SelectObject(pOldFont);}
    在OnPreparePrinting函數中加入以下程序段:
    BOOL CSongView::OnPre?parePrinting(CPrintlnfo* plnf
    o)
    // default preperation
    plnfo->SetMaxPage(1);
    return DoPreparePrinting(plnfo);

    (六)Build該程序,運行它就可以看到這個只占一頁的歌詞了。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>