Guidance
指路人
g.yi.org
software / rapidq / Examples / QObject / Object / QPageSetup.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'=======================================================
' Type Objet
' Classe QPageSetup version 1.2
'=======================================================
     $IFNDEF TRUE
      $DEFINE True 1
     $ENDIF

     $IFNDEF FALSE
      $DEFINE False 0
     $ENDIF

     $IFNDEF boolean
      $DEFINE boolean INTEGER
     $ENDIF

     CONST PSD_DEFAULTMINMARGINS=0
     CONST PSD_MINMARGINS=&H1
     CONST PSD_MARGINS=&H2
     CONST PSD_INTHOUSANDTHSOFINCHES=&H4
     CONST PSD_INHUNDREDTHSOFMILLIMETERS=&H8
     CONST PSD_DISABLEMARGINS=&H10
     CONST PSD_DISABLEPRINTER=&H20
     CONST PSD_NOWARNING=&H80
     CONST PSD_DISABLEORIENTATION=&H100
     CONST PSD_DISABLEPAPER=&H200
     CONST PSD_RETURNDEFAULT=&H400
     CONST PSD_SHOWHELP=&H800
     CONST PSD_ENABLEPAGESETUPHOOK=&H2000
     CONST PSD_ENABLEPAGESETUPTEMPLATE=&H8000
     CONST PSD_ENABLEPAGESETUPTEMPLATEHANDLE=&H20000
     CONST PSD_ENABLEPAGEPAINTHOOK=&H40000
     CONST PSD_DISABLEPAGEPAINTING=&H80000
     CONST PSD_NONETWORKBUTTON=&H200000

     TYPE TPSD
      lStructSize AS LONG
      hWndOwner AS LONG
      hDevMode AS LONG
      hDevNames AS LONG
      Flags AS LONG
      ptPaperSizeX AS LONG
      ptPaperSizeY AS LONG
      rtMinMarginLeft AS LONG
      rtMinMarginTop AS LONG
      rtMinMarginRight AS LONG
      rtMinMarginBottom AS LONG
      rtMarginLeft AS LONG
      rtMarginTop AS LONG
      rtMarginRight AS LONG
      rtMarginBottom AS LONG
      hInstance AS LONG
      lParam AS LONG
      lpfnPageSetupHook AS LONG
      lpfnPagePaintHook AS LONG
      lpPageSetupTemplate AS LONG
      hPageSetupTemplate AS LONG
     END TYPE

     CONST WM_INITDIALOG_PSD=&H110


     DECLARE FUNCTION PageSetupDlg LIB "COMDLG32" ALIAS "PageSetupDlgA" (PTR AS TPSD) AS LONG

     DECLARE FUNCTION GetPageText LIB "user32" ALIAS "GetWindowRect" (hwnd AS LONG, lpRect AS QRECT) AS LONG
     DECLARE FUNCTION MovePage LIB "user32" ALIAS "MoveWindow" (hwnd AS LONG,x AS LONG,y AS LONG,nWidth AS LONG,nHeight AS LONG,bRepaint AS LONG) AS LONG
     DECLARE FUNCTION SetPageText LIB "user32" ALIAS "SetWindowTextA" (hWnd AS LONG,ByRef lpString AS STRING) AS LONG


     TYPE QPageSetup EXTENDS QOBJECT
Private:
      PSD AS TPSD
Public:
      CAPTION AS STRING
      DisablePrinter AS boolean
      DisablePaper AS boolean
      DisableOrient AS boolean
      DisableMargins AS boolean
      Orientation AS boolean PROPERTY SET SetOrientation
      MarginLeft AS LONG PROPERTY SET SetMarginLeft
      MarginTop AS LONG PROPERTY SET SetMarginTop
      MarginRight AS LONG PROPERTY SET SetMarginRight
      MarginBottom AS LONG PROPERTY SET SetMarginBottom
      PageWidth AS LONG PROPERTY SET SetPageWidth
      PageHeight AS LONG PROPERTY SET SetPageHeight


Private:

  '=============================================
  ' Procédure boite de dialogue
  '=============================================
      FUNCTION HookProc(hWnd AS LONG, uMsg AS LONG, wParam AS LONG, lParam AS LONG) AS LONG
       DIM R AS QRECT

       IF uMsg=WM_INITDIALOG_PSD THEN
        GetPageText(hWnd,R)
        MovePage(hWnd,((Screen.Width-(R.Right-R.Left))/2),((Screen.Height-(R.Bottom-R.Top))/2),(R.Right-R.Left),(R.Bottom-R.Top),0)
        IF LEN(QPageSetup.CAPTION) THEN
         SetPageText(hWnd,QPageSetup.CAPTION)
        END IF
        Result=true
       ELSE
        Result=false
       END IF
      END FUNCTION

Public:

  '=============================================
  ' Proprieté orientation page en lecture seule
  '=============================================
      PROPERTY SET SetOrientation(value AS boolean)
      END PROPERTY

  '===============================================
  ' Proprieté valeur marge gauche
  '===============================================
      PROPERTY SET SetMarginLeft(value AS LONG)
       QPageSetup.PSD.rtMarginLeft=value*100
      END PROPERTY

  '===============================================
  ' Proprieté valeur marge haute
  '===============================================
      PROPERTY SET SetMarginTop(value AS LONG)
       QPageSetup.PSD.rtMarginTop=value*100
      END PROPERTY

  '===============================================
  ' Proprieté valeur marge droite
  '===============================================
      PROPERTY SET SetMarginRight(value AS LONG)
       QPageSetup.PSD.rtMarginRight=value*100
      END PROPERTY

  '===============================================
  ' Proprieté valeur marge basse
  '===============================================
      PROPERTY SET SetMarginBottom(value AS LONG)
       QPageSetup.PSD.rtMarginBottom=value*100
      END PROPERTY

  '===============================================
  ' Proprieté largeur page en lecture seule
  '===============================================
      PROPERTY SET SetPageWidth(value AS boolean)
      END PROPERTY

  '===============================================
  ' Proprieté hauteur page en lecture seule
  '===============================================
      PROPERTY SET SetPageHeight(value AS boolean)
      END PROPERTY

  '===========================================
  ' Méthode affichage mise en page imprimante
  '===========================================
      FUNCTION EXECUTE AS boolean
       QPageSetup.PSD.lStructSize = SIZEOF(QPageSetup.PSD)
       QPageSetup.PSD.hWndOwner=Application.handle
       QPageSetup.PSD.Flags=PSD_MARGINS+PSD_MINMARGINS
       IF QPageSetup.CAPTION<>"" THEN
        QPageSetup.PSD.Flags=QPageSetup.PSD.Flags+PSD_ENABLEPAGESETUPHOOK
        QPageSetup.PSD.lpfnPageSetupHook=CODEPTR(QPageSetup.HookProc)
       END IF
       IF QPageSetup.DisablePrinter THEN
        QPageSetup.PSD.Flags=QPageSetup.PSD.Flags+PSD_DISABLEPRINTER
       END IF
       IF QPageSetup.DisablePaper THEN
        QPageSetup.PSD.Flags=QPageSetup.PSD.Flags+PSD_DISABLEPAPER
       END IF
       IF QPageSetup.DisableOrient THEN
        QPageSetup.PSD.Flags=QPageSetup.PSD.Flags+PSD_DISABLEORIENTATION
       END IF
       IF QPageSetup.DisableMargins THEN
        QPageSetup.PSD.Flags=QPageSetup.PSD.Flags+PSD_DISABLEMARGINS
       END IF
       IF PageSetupDlg(QPageSetup.PSD) THEN
        QPageSetup.EXECUTE=true
        QPageSetup.PageWidth=ROUND(QPageSetup.PSD.ptPaperSizeX/100)
        QPageSetup.PageHeight=ROUND(QPageSetup.PSD.ptPaperSizeY/100)
        IF QPageSetup.PageWidth>QPageSetup.PageHeight THEN
         QPageSetup.Orientation=true
        ELSE
         QPageSetup.Orientation=false
        END IF
        QPageSetup.MarginLeft=QPageSetup.PSD.rtMarginLeft/100
        QPageSetup.MarginTop=QPageSetup.PSD.rtMarginTop/100
        QPageSetup.MarginRight=QPageSetup.PSD.rtMarginRight/100
        QPageSetup.MarginBottom=QPageSetup.PSD.rtMarginBottom/100
       ELSE
        QPageSetup.EXECUTE=false
       END IF
      END FUNCTION

      CONSTRUCTOR
       CAPTION=""
       DisablePrinter=false
       DisablePaper=false
       DisableOrient=false
       DisableMargins=false
      END CONSTRUCTOR
     END TYPE
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2023-2-4  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-02-25 23:29:28