Newsgroup: it.comp.lang.visual-basic
Titolo: Finestra stampa da modificare...

Salve a tutti, sono nuovo di qui, però è da molto tempo che leggo le
vostre risposte (trovate sempre molto utili e esaustive), ora vorrei
porvi un problema per me molto importante:
Ho sviluppato un programma che alla fine ha lo scopo di visualizzare un
file pdf in un controllo pdf, però devo proteggere tale pdf da
salvataggi ma dare solo la possibilita di stamparlo (direttamente,
senza passare dalla finestra stampa di window, con il metodo print).
Il problema è che nel menu del tasto destro del controllo pdf c'è
anche il pulsante stampa, che però apre la finestra di stampa di
window dove è possibile anche "STAMPA SU FILE", e quindi salvare il
pdf sul computer.
Pensavo di usare il subclassing per modificare la finestra di stampa
eliminando il checkbox "stampa su file"; ho letto abbastanza sul
subclassing ma non ho ancora trovato quello che cerco.
Sapete aiutarmi?



Nessuno sa aiutarmi???

Nessuno sa aiutarmi???

Nessuno sa aiutarmi???

non ricordo dove l'ho preso quindi ti scrivo il codice
Option Explicit
'Strutture
Private Type OPENFILENAME
    lStructSize As Long
    hwnd As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    Flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
End Type
Private Type COLORSTRUC
    lStructSize As Long
    hwnd As Long
    hInstance As Long
    rgbResult As Long
    lpCustColors As String
    Flags As Long
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
End Type
Private Const LF_FACESIZE As Long = 32
Private Type LOGFONT
    lfHeight As Long
    lfWidth As Long
    lfEscapement As Long
    lfOrientation As Long
    lfWeight As Long
    lfItalic As Byte
    lfUnderline As Byte
    lfStrikeOut As Byte
    lfCharSet As Byte
    lfOutPrecision As Byte
    lfClipPrecision As Byte
    lfQuality As Byte
    lfPitchAndFamily As Byte
    lfFaceName(LF_FACESIZE) As Byte
    lfColor As Long
End Type
Private Type FONTSTRUC
    lStructSize As Long
    hwnd As Long
    hDC As Long
    lpLogFont As Long
    iPointSize As Long
    Flags As Long
    rgbColors As Long
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
    hInstance As Long
    lpszStyle As String
    nFontType As Integer
    MISSING_ALIGNMENT As Integer
    nSizeMin As Long
    nSizeMax As Long
End Type
Public Type DEVMODE
    dmDeviceName As String * 32
    dmSpecVersion As Integer
    dmDriverVersion As Integer
    dmSize As Integer
    dmDriverExtra As Integer
    dmFields As Long
    dmOrientation As Integer
    dmPaperSize As Integer
    dmPaperLength As Integer
    dmPaperWidth As Integer
    dmScale As Integer
    dmCopies As Integer
    dmDefaultSource As Integer
    dmPrintQuality As Integer
    dmColor As Integer
    dmDuplex As Integer
    dmYResolution As Integer
    dmTTOption As Integer
    dmCollate As Integer
    dmFormName As String * 32
    dmUnusedPadding As Integer
    dmBitsPerPel As Integer
    dmPelsWidth As Long
    dmPelsHeight As Long
    dmDisplayFlags As Long
    dmDisplayFreq As Long
End Type
Private Type PRINTDLGSTRUC
    lStructSize As Long
    hwnd As Long
    hDevMode As Long
    hDevNames As Long
    hDC As Long
    Flags As Long
    nFromPage As Integer
    nToPage As Integer
    nMinPage As Integer
    nMaxPage As Integer
    nCopies As Integer
    hInstance As Long
    lCustData As Long
    lpfnPrintHook As Long
    lpfnSetupHook As Long
    lpPrintTemplateName As String
    lpSetupTemplateName As String
    hPrintTemplate As Long
    hSetupTemplate As Long
End Type
Public Type PRINTPROPS
    Cancel As Boolean
    Device As String
    Copies As Integer
    Collate As Boolean
    File As Boolean
    All As Boolean
    Pages As Boolean
    Selection As Boolean
    Min As Integer
    Max As Integer
    FromPage As Integer
    ToPage As Integer
    DM As DEVMODE
End Type
Private Type SHITEMID
    cb As Long
    abID As Byte
End Type
Private Type ITEMIDLIST
    mkid As SHITEMID
End Type
Private Type BROWSEINFO
    hOwner As Long
    pidlRoot As Long
    pszDisplayName As String
    lpszTitle As String
    ulFlags As Long
    lpfn As Long
    lParam As Long
    iImage As Long
End Type
'Dichiarazione API.
Private Declare Function GetOpenFileName Lib "Comdlg32.dll" Alias 
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Declare Function GetSaveFileName Lib "Comdlg32.dll" Alias 
"GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Declare Function PrintDlg Lib "Comdlg32.dll" Alias "PrintDlgA" 
(pPrintdlg As PRINTDLGSTRUC) As Long
Private Declare Function ChooseColor Lib "Comdlg32.dll" Alias "ChooseColorA" 
(pChoosecolor As COLORSTRUC) As Long
Private Declare Function ChooseFont Lib "Comdlg32.dll" Alias "ChooseFontA" 
(pChoosefont As FONTSTRUC) As Long
Private Declare Function GlobalAlloc Lib "Kernel32.dll" (ByVal wFlags As 
Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalLock Lib "Kernel32.dll" (ByVal hMem As Long) 
As Long
Private Declare Function GlobalUnlock Lib "Kernel32.dll" (ByVal hMem As 
Long) As Long
Private Declare Sub CopyMemory Lib "Kernel32.dll" Alias "RtlMoveMemory" 
(hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function SHGetPathFromIDList Lib "Shell32.DLL" Alias 
"SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "Shell32.DLL" Alias 
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long    'ITEMIDLIST
Private Declare Function WriteProfileString Lib "Kernel32.dll" Alias 
"WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As 
String, ByVal lpszString As String) As Long
Private Declare Function GetProfileString Lib "Kernel32.dll" Alias 
"GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, 
ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As 
Long) As Long
Private Declare Function SendMessageByString Lib "User32.dll" Alias 
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As 
Long, ByVal lParam As String) As Long
Private Declare Function GetWindowsDirectory Lib "KERNEL32" Alias 
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As 
Long
'Dichiarazione API per la Guida in linea.
Declare Function WinHelp Lib "User32.dll" Alias "WinHelpA" (ByVal hwnd As 
Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As 
Any) As Long
Declare Function HTMLHelp Lib "Hhctrl.ocx" Alias "HtmlHelpA" (ByVal hwnd As 
Long, ByVal szFilename As String, ByVal dwCommand As Long, ByVal dwData As 
Any) As Long
'Costanti per "Stampa Dialog Box".
Public Const PD_NOSELECTION As Long = &H4
Public Const PD_DISABLEPRINTTOFILE As Long = &H80000
Public Const PD_PRINTTOFILE As Long = &H20
Public Const PD_RETURNDC As Long = &H100
Public Const PD_RETURNDEFAULT As Long = &H400
Public Const PD_RETURNIC As Long = &H200
Public Const PD_SELECTION As Long = &H1
Public Const PD_SHOWHELP As Long = &H800
Public Const PD_NOPAGENUMS As Long = &H8
Public Const PD_PAGENUMS As Long = &H2
Public Const PD_ALLPAGES As Long = &H0
Public Const PD_COLLATE As Long = &H10
Public Const PD_HIDEPRINTTOFILE As Long = &H100000
'Costanti per WinHelp.
Public Const HELP_COMMAND As Long = &H102&
Public Const HELP_CONTENTS As Long = &H3&
Public Const HELP_CONTEXT As Long = &H1
Public Const HELP_CONTEXTPOPUP As Long = &H8&
Public Const HELP_FORCEFILE As Long = &H9&
Public Const HELP_HELPONHELP As Long = &H4
Public Const HELP_INDEX As Long = &H3
Public Const HELP_KEY As Long = &H101
Public Const HELP_MULTIKEY As Long = &H201&
Public Const HELP_PARTIALKEY As Long = &H105&
Public Const HELP_QUIT As Long = &H2
Public Const HELP_SETCONTENTS As Long = &H5&
Public Const HELP_SETINDEX As Long = &H5
Public Const HELP_SETWINPOS As Long = &H203&
' Costanti per HTMLHelp
Public Const HH_DISPLAY_TOPIC As Long = &H0&
Public Const HH_HELP_FINDER As Long = &H0&
Public Const HH_DISPLAY_TOC As Long = &H1&    'Non Implementata
Public Const HH_DISPLAY_INDEX As Long = &H2&    'Non Implementata
Public Const HH_DISPLAY_SEARCH As Long = &H3&    'Non Implementata
Public Const HH_SET_WIN_TYPE As Long = &H4&
Public Const HH_GET_WIN_TYPE As Long = &H5&
Public Const HH_GET_WIN_HANDLE As Long = &H6&
Public Const HH_ENUM_INFO_TYPE As Long = &H7&
Public Const HH_SET_INFO_TYPE As Long = &H8&
Public Const HH_SYNC As Long = &H9&
Public Const HH_ADD_NAV_UI As Long = &H10&    'Attualmente non implementata
Public Const HH_ADD_BUTTON As Long = &H11&    'Attualmente non implementata
Public Const HH_GETBROWSER_APP As Long = &H12&    'Attualmente non 
implementata
Public Const HH_KEYWORD_LOOKUP As Long = &H13&
Public Const HH_DISPLAY_TEXT_POPUP As Long = &H14&
Public Const HH_HELP_CONTEXT As Long = &H15&
Public Const HH_TP_HELP_CONTEXTMENU As Long = &H16&
Public Const HH_TP_HELP_WM_HELP As Long = &H17&
Public Const HH_CLOSE_ALL As Long = &H18&
Public Const HH_ALINK_LOOKUP As Long = &H19&
Public Const HH_GET_LAST_ERROR As Long = &H20&    'Attualmente non 
implementata
Public Const HH_ENUM_CATEGORY As Long = &H21&
Public Const HH_ENUM_CATEGORY_IT As Long = &H22&
Public Const HH_RESET_IT_FILTER As Long = &H23&
Public Const HH_SET_INCLUSIVE_FILTER As Long = &H24&
Public Const HH_SET_EXCLUSIVE_FILTER As Long = &H25&
Public Const HH_SET_GUID As Long = &H26&
Public Const HH_INTERNAL As Long = &H255&
'Costanti Private
Private Const FW_BOLD As Long = 700
Private Const GMEM_MOVEABLE As Long = &H2
Private Const GMEM_ZEROINIT As Long = &H40
Private Const GHND As Long = (GMEM_MOVEABLE Or GMEM_ZEROINIT)
Private Const OFN_FILEMUSTEXIST As Long = &H1000
Private Const OFN_HIDEREADONLY As Long = &H4
Private Const OFN_OVERWRITEPROMPT As Long = &H2
Private Const OFN_PATHMUSTEXIST As Long = &H800
Private Const PD_PRINTSETUP As Long = &H40
Private Const CF_SCREENFONTS As Long = &H1
Private Const CF_EFFECTS As Long = &H100&
Private Const CC_SOLIDCOLOR As Long = &H80
Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const HWND_BROADCAST As Long = &HFFFF&
Private Const WM_WININICHANGE As Long = &H1A
'// SetDefaultPrinter
'//
'// Descrizione:
'// Imposta la stampante predefinita.
'//
'// Sintassi:
'// BOOL = SetDefaultPrinter(object)
'//
'// Esempio:
'// Dim objNewPrinter As Printer
'// Set objNewPrinter = Printers(2)
'// SetDefaultPrinter objNewPrinter
'//
Public Function SetDefaultPrinter(objPrn As Printer) As Boolean
    Dim X As Long, szTmp As String
    szTmp = objPrn.DeviceName & "," & objPrn.DriverName & "," & objPrn.Port
    X = WriteProfileString("windows", "device", szTmp)
    X = SendMessageByString(HWND_BROADCAST, WM_WININICHANGE, 0&, "windows")
End Function
'//
'// GetDefaultPrinter
'//
'// Descrizione:
'// Ritorna il nome della stampante predefinita
'//
'// Syntassi:
'// StrVar = GetDefaultPrinter()
'//
'// Esempio:
'// szDefPrinter = GetDefaultPrinter
'//
Public Function GetDefaultPrinter() As String
    Dim X As Long, szTmp As String, dwBuf As Long
    dwBuf = 1024
    szTmp = Space(dwBuf + 1)
    X = GetProfileString("windows", "device", "", szTmp, dwBuf)
    GetDefaultPrinter = Trim(Left(szTmp, X))
End Function
'//
'// ResetDefaultPrinter
'//
'// Descrizione:
'// Resetta la stampante predefinita
'//
'// Syntassi:
'// BOOL = ResetDefaultPrinter(StrVar)
'//
'// Esempio:
'// szDefPrinter = GetDefaultPrinter()
'// If Not ResetDefaultPrinter(szDefPrinter) Then
'//     MsgBox "Non posso resettare la stampante predefinita.", 
vbExclamation
'// End If
'//
Public Function ResetDefaultPrinter(szBuf As String) As Boolean
    Dim X As Long
    X = WriteProfileString("windows", "device", szBuf)
    X = SendMessageByString(HWND_BROADCAST, WM_WININICHANGE, 0&, "windows")
End Function
'//
'// BrowseFolder
'//
'// Descrizione:
'// Apre la finestra Sfoglia cartelle
'//
'// Syntassi:
'// StrVar = BrowseFolder(hWnd, StrVar)
'//
'// Esempio:
'// szFilename = BrowseFolder(Me.hWnd, "Seleziona la cartella desiderata:")
'//
Public Function BrowseFolder(hwnd As Long, szDialogTitle As String, Optional 
creacartella As Boolean) As String
    Dim X As Long, BI As BROWSEINFO, dwIList As Long, szPath As String, wPos 
As Integer
    BI.hOwner = hwnd
    BI.lpszTitle = szDialogTitle
    If creacartella = True Then
        BI.ulFlags = BIF_RETURNONLYFSDIRS + &H40    'INSERIRE SE SI VUOLE 
CREA CARTELLA
    Else
        BI.ulFlags = BIF_RETURNONLYFSDIRS    'INSERIRE SE SI VUOLE CREA 
CARTELLA
    End If
    dwIList = SHBrowseForFolder(BI)
    szPath = Space$(512)
    X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
    If X Then
        wPos = InStr(szPath, Chr(0))
        BrowseFolder = Left$(szPath, wPos - 1)
    Else
        BrowseFolder = ""
    End If
End Function
'//
'// DialogConnectToPrinter
'//
'// Descrizione:
'// Per selezionare la stampante che interessa.
'//
'// Syntassi:
'// DialogConnectToPrinter
'//
'// Esempio:
'// DialogConnectToPrinter
'//
Public Function DialogConnectToPrinter() As Boolean
    Shell "rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter", 
vbNormalFocus
End Function
'//
'// ByteToString
'//
'// Descrizione:
'// Converte un array di bytes in una stringa
'//
'// Syntassi:
'// StrVar = ByteToString(ARRAY)
'//
'// Esempio:
'// szBuf = BytesToString(aChars(10))
'//
Private Function ByteToString(aBytes() As Byte) As String
    Dim dwBytePoint As Long, dwByteVal As Long, szOut As String
    dwBytePoint = LBound(aBytes)
    While dwBytePoint <= UBound(aBytes)
        dwByteVal = aBytes(dwBytePoint)
        If dwByteVal = 0 Then
            ByteToString = szOut
            Exit Function
        Else
            szOut = szOut & Chr$(dwByteVal)
        End If
        dwBytePoint = dwBytePoint + 1
    Wend
    ByteToString = szOut
End Function
'//
'// DialogColor
'//
'// Descrizione:
'// Apre la finestra di dialogo per la scelta del colore.
'//
'// Syntassi:
'// BOOL = DialogColor(hWnd, CONTROL)
'//
'// Esempio:
'// Dim yn as Boolean
'// yn = DialogColor(Me.hWnd, txtEditor)
'//
Public Function DialogColor(hwnd As Long, C As Control, FoB As Integer) As 
Boolean
    Dim X As Long, CS As COLORSTRUC
    CS.lStructSize = Len(CS)
    CS.hwnd = hwnd
    CS.hInstance = App.hInstance
    CS.Flags = CC_SOLIDCOLOR
    CS.lpCustColors = String$(16 * 4, 0)
    X = ChooseColor(CS)
    If X = 0 Then
        DialogColor = False
    Else
        DialogColor = True
        If FoB = 0 Then
            C.BackColor = CS.rgbResult
        Else
            C.ForeColor = CS.rgbResult
        End If
    End If
End Function
'//
'// DialogFile
'//
'// Descrizione:
'// Apre la finestra di dialogo Apri/Salva.
'//
'// Sintassi:
'// StrVar = DialogFile(hWnd, IntVar, StrVar, StrVar, StrVar, StrVar, 
StrVar)
'//
'// Esempio:
'// szFilename = DialogFile(Me.hWnd, 1, "Open", "MyFileName.doc", 
"Documents" & Chr(0) & "*.doc" & Chr(0) & "Tutti i files" & Chr(0) & "*.*", 
App.Path, "doc")
'//
'// Nota che la variabile szFilter lavora differentemente
'// a seconda del filtro associato.
'// Occorre separare i filtri col carattere |
Public Function DialogFile(hwnd As Long, wMode As Integer, szDialogTitle As 
String, szFilename As String, szFilter As String, szDefDir As String, 
szDefExt As String) As String
    Dim X As Long, OFN As OPENFILENAME, szFile As String
    OFN.lStructSize = Len(OFN)
    OFN.hwnd = hwnd
    OFN.lpstrTitle = szDialogTitle
    OFN.lpstrFile = szFilename & String$(250 - Len(szFilename), 0)
    OFN.nMaxFile = 255
    OFN.lpstrFileTitle = String$(255, 0)
    OFN.nMaxFileTitle = 255
    OFN.lpstrFilter = szFilter
    OFN.nFilterIndex = 1
    OFN.lpstrInitialDir = szDefDir
    OFN.lpstrDefExt = szDefExt
    If wMode = 1 Then
        OFN.Flags = OFN_HIDEREADONLY Or OFN_PATHMUSTEXIST Or 
OFN_FILEMUSTEXIST
        X = GetOpenFileName(OFN)
    Else
        OFN.Flags = OFN_HIDEREADONLY Or OFN_OVERWRITEPROMPT Or 
OFN_PATHMUSTEXIST
        X = GetSaveFileName(OFN)
    End If
    If X <> 0 Then
        '// If InStr(OFN.lpstrFileTitle, Chr$(0)) > 0 Then
        '//     szFileTitle = Left$(OFN.lpstrFileTitle, 
InStr(OFN.lpstrFileTitle, Chr$(0)) - 1)
        '// End If
        If InStr(OFN.lpstrFile, Chr$(0)) > 0 Then
            szFile = Left$(OFN.lpstrFile, InStr(OFN.lpstrFile, Chr$(0)) - 1)
        End If
        '// OFN.nFileOffset è il numero di caratteri accettato
        '// inizialmente dal nome del file compreso il percorso
        '// OFN.nFileExtension è il numero di caratteri dell'estensione
        '// incluso (.)
        '// MsgBox "Il nome del file è " & szFileTitle & Chr$(13) & Chr$(10) 
& "Percorso e file é " & szFile, , "Open"
        '// DialogFile = szFile & "|" & szFileTitle
        DialogFile = szFile
    Else
        DialogFile = ""
    End If
End Function
'//
'// DialogFont
'//
'// Descrizione:
'// Apre la finestra di dialogo per i caratteri
'//
'// Syntassi:
'// BOOL = DialogFont(hWnd, CONTROL)
'//
'// Esempio:
'// Dim yn as Boolean
'// yn = DialogFont(Me.hWnd, txtEditor)
'//
Public Function DialogFont(hwnd As Long, C As Control) As Boolean
    Dim LF As LOGFONT, FS As FONTSTRUC
    Dim lLogFontAddress As Long, lMemHandle As Long
    If C.Font.Bold Then LF.lfWeight = FW_BOLD
    If C.Font.Italic = True Then LF.lfItalic = 1
    If C.Font.Underline = True Then LF.lfUnderline = 1
    FS.lStructSize = Len(FS)
    lMemHandle = GlobalAlloc(GHND, Len(LF))
    If lMemHandle = 0 Then
        DialogFont = False
        Exit Function
    End If
    lLogFontAddress = GlobalLock(lMemHandle)
    If lLogFontAddress = 0 Then
        DialogFont = False
        Exit Function
    End If
    CopyMemory ByVal lLogFontAddress, LF, Len(LF)
    FS.hwnd = hwnd
    FS.lpLogFont = lLogFontAddress
    FS.iPointSize = C.Font.Size * 10
    FS.Flags = CF_SCREENFONTS Or CF_EFFECTS
    If ChooseFont(FS) = 1 Then
        CopyMemory LF, ByVal lLogFontAddress, Len(LF)
        If LF.lfWeight >= FW_BOLD Then
            C.Font.Bold = True
        Else
            C.Font.Bold = False
        End If
        If LF.lfItalic = 1 Then
            C.Font.Italic = True
        Else
            C.Font.Italic = False
        End If
        If LF.lfUnderline = 1 Then
            C.Font.Underline = True
        Else
            C.Font.Underline = False
        End If
        If LF.lfStrikeOut = 1 Then
            C.Font.Strikethrough = True
        Else
            C.Font.Strikethrough = False
        End If
 
C.Font.Name
 = ByteToString(LF.lfFaceName())
        C.Font.Size = CLng(FS.iPointSize / 10)
        C.ForeColor = FS.rgbColors
        DialogFont = True
    Else
        DialogFont = False
    End If
End Function
'//
'// DialogPrint
'//
'// Descrizione:
'// Apre la finestra di dialogo Stampa
'//
'// Syntassi:
'// PRINTPROPS = DialogPrint(hWnd, BOOL, DWORD)
'//
'// Esempio:
'// Dim PP As PRINTPROPS
'// PP = DialogPrint(Me.hWnd, True, PD_PAGENUMS or PD_SELECTION or 
PD_SHOWHELP)
'//
Public Function DialogPrint(hwnd As Long, bPages As Boolean, Flags As Long, 
Optional dapag As Integer, Optional apag As Integer) As PRINTPROPS
    Dim DM As DEVMODE, PD As PRINTDLGSTRUC
    Dim lpDM As Long
    PD.lStructSize = Len(PD)
    PD.hwnd = hwnd
    PD.hDevMode = 0
    PD.hDevNames = 0
    PD.hDC = 0
    PD.Flags = Flags
    PD.nFromPage = dapag
    PD.nToPage = apag
    PD.nMinPage = dapag
    PD.nMaxPage = apag
    PD.nCopies = 0
    DialogPrint.Cancel = True
    If PrintDlg(PD) Then
        lpDM = GlobalLock(PD.hDevMode)
        CopyMemory DM, ByVal lpDM, Len(DM)
        lpDM = GlobalUnlock(PD.hDevMode)
        DialogPrint.Cancel = False
        DialogPrint.Device = Left$(DM.dmDeviceName, InStr(DM.dmDeviceName, 
Chr(0)) - 1)
        If PD.Flags And PD_PRINTTOFILE Then DialogPrint.File = True Else 
DialogPrint.File = False
        If PD.Flags And PD_COLLATE Then DialogPrint.Collate = True Else 
DialogPrint.Collate = False
        If PD.Flags And PD_PAGENUMS Then
            DialogPrint.Pages = True
            DialogPrint.All = False
            DialogPrint.FromPage = PD.nFromPage
            DialogPrint.ToPage = PD.nToPage
        Else
            DialogPrint.Pages = False
            'DialogPrint.All = True Then
            DialogPrint.FromPage = PD.nMinPage
            DialogPrint.ToPage = PD.nMaxPage
            'End If
        End If
        If PD.Flags And PD_SELECTION Then
            DialogPrint.Selection = True
            DialogPrint.All = False
        Else
            DialogPrint.Pages = False
        End If
        If PD.nCopies = 1 Then
            DialogPrint.Copies = DM.dmCopies
        End If
        DialogPrint.DM = DM
    End If
End Function
'//
'// DialogPrintSetup
'//
'// Descrizione:
'// Apre la finestra di dialogo Imposta stampante
'//
'// Syntassi:
'// BOOL = DialogPrintSetup(hWnd)
'//
'// Esempio:
'// If DialogPrintSetup(Me.hWnd) Then
'// End If
'//
Public Function DialogPrintSetup(hwnd As Long) As Boolean
    Dim X As Long, PD As PRINTDLGSTRUC
    PD.lStructSize = Len(PD)
    PD.hwnd = hwnd
    PD.Flags = PD_PRINTSETUP
    X = PrintDlg(PD)
End Function
Public Function GetWinDir() As String
    Dim Temp As String * 256
    Dim X As Integer
    X = GetWindowsDirectory(Temp, Len(Temp))
    GetWinDir = Left$(Temp, X)
    GetWinDir = IIf(Right(GetWinDir, 1) = "\", GetWinDir, GetWinDir & "\")
End Function
con questo in un modulo  puoi aprire le finestre di commondialog  e se setti 
giusto i flag dovresti riuscirci, purtroppo non ho tempo di provarci
ciao
Ilario

Intanto scusatemi se ho postato 3 volte lo stesso post ("Nessuno sa
aiutarmi?????")
Grazie per la disponibilità ilario, mi puoi fare il piacere di
spiegarmi cosa devo fare? di subclassing non sono molto esperto
Il codice che mi hai postato lo copio in un modulo? ma come lo richiamo
da programma?
Scusami l'ignoranza
Grazie in anticipo

ma non capisco, le risposte vengano visualizzate piu tardi??

pdf sul computer.
questo me lo sono perso  guarda se riesci a fargli aprire dal menu la 
finestra di dialogo del codice che ti ho inviato, so no' non so' come 
aiutarti
ciao
Ilario



apri un nuovo modulo e lo chiami come vuoi , inserisci il codice e lo salvi,
per aprire una finestra di dialogo semplicemente (dal form che vuoi)
Esempio:
'// Dim PP As PRINTPROPS
'// PP = DialogPrint(Me.hWnd, True, PD_PAGENUMS or PD_SELECTION or 
PD_SHOWHELP)
'//
poi il flag che ti interessa dovrebbe essere questo
Public Const PD_HIDEPRINTTOFILE As Long = &H100000   (guarda all'inizio del 
codice trovi questo e altri)
leggiti bene il codice ti riporta degli esempi
ciao
Ilario

mi sembra di avere capito (non ne ho la certezza) che questo codice
serve per gestire la chiamata della finestra stampa dal form di vb, ma
la chiamata alla finestra stampa avviene dal controllo pdf che essendo
un controllo esterno non fornisce output per vb, cioè vb non gestisce
gli eventi scatenati dal controllo pdf.
Però (spero) vb può intercettare una chiamata alla finestra stampa da
qualsiasi altra applicazione, penso che li sia la soluzione,
intercettare la chiamata alla finestra stampa e modificare le
proprietà.
spero di essere stato abbastanza chiaro, purtroppo anche dopo molte
letture non ho ancora capito bene il metodo del subclassing e non
riesco a trovare esempi utili a questo problema, ossia intercettare
chiamate a finestra di window da altre applicazioni, tutti i
subclassing trovati intercettano messaggi che vengono inviati dal form
vb.
Ora provo a fare come dici tu, grazie infinite per l'aiuto, se ti viene
in mente qualcosa fammi sapere.

ma non capisco, le risposte vengano visualizzate piu tardi??
  Notoriamente Google e' lentissimo nel visualizzare i messaggi dei
newsgroup... usare un vero newsserver con un vero newsreader pare
brutto?
-- 
  Ciao :-)
  Massimo
  Nell'indirizzo, sostituire "micio" con "mc"

Ho fatto mille prove ma non sono riuscito a risolvere il problema, mi
sono bloccato all'intercettazione della chiamata della finestra di
stampa, non riesco a capire che messaggio devo intercettare nel
subclassing, per esempio: per intercettare un click nel system menu
nella nuova window procedure si verifica che il iMsg sia uguale a
WM_SYSCOMMAND, se lo è si decide cosa fare.
In questo caso devo trovare il messaggio che viene inviato alla window
procedure nel caso che si chiami la finestra stampa, a quel punto non
rimarrebbe altro che modificare le proprietà (anche questo sembra
semplice ma mi immagino che non lo sia).
Nessuno conosce il messaggio corrispondente alla chiamata della
finestra di stampa??

