Formula One 5.0µÄ PrintDevModeÊô ÐÔ Êµ ¼Ê ÉÏ ÊÇ Ò» ¸ö ´¢ ´æ DEVMODEµÄ Ò» ¸ö È« ¾Ö ¾ä ±ú ¡£ ÏÂ Ãæ ÊÇ Formula One 5.0µÄ ¿ª ·¢ Õß Tidestone Technologies, Inc.Ìá ¹© ¸ø ÎÒ µÄ Ò» ¶Î Àý ×Ó (Éè ÖÃ Ö½ ÕÅ ´ó Ð¡ Îª A4)£¬ Ê¹ ÓÃ C++Ð´ µÄ £¬ ¹© Äã ²Î ¿¼ ¡£ 
    ///////////////////////// Solution /////////////////////////////////// 
    ///// Note: only call once (for instance when the F1Book is initialized) 
    ///// Access devmode dierctly from F1 book after that 
    void SetA4Paper(CWinApp& myApp,CF1Book& book) 
    { 
    PRINTDLG pd; pd.lStructSize = (DWORD) sizeof(PRINTDLG); 
    myApp.GetPrinterDeviceDefaults(&pd); 
    HGLOBAL hAppDevMode, hGridDevMode; 
    LPDEVMODE pAppDevMode, pGridDevMode; 
    hAppDevMode = pd.hDevMode; 
    pAppDevMode = (LPDEVMODE)::GlobalLock(hAppDevMode); 
    if (pAppDevMode) 
     { 
    hGridDevMode = ::GlobalAlloc(GHND, pAppDevMode->dmSize + 
    pAppDevMode->dmDriverExtra); 
    pGridDevMode = (LPDEVMODE)::GlobalLock(hGridDevMode); 
    //pAppDevMode = (LPDEVMODE)::GlobalLock(hAppDevMode); 
    CopyMemory(pGridDevMode, pAppDevMode, pAppDevMode->dmSize + 
    pAppDevMode->dmDriverExtra); 
    pGridDevMode->dmPaperSize=DMPAPER_A4; 
    // Unlock memory handles. 
    GlobalUnlock(hAppDevMode); 
    GlobalUnlock(hGridDevMode); 
     
    book.SetPrintDevMode((long) hGridDevMode); 
     } 
    } 
<END>