>>If you only want to prevent printing to file then you can just give the flag cdlPD_HIDEPRINTTOFILE
>>
>>#Define cdlPD_HIDEPRINTTOFILE 0x00100000
>>
>>oCommDialog.Flags = cdlPD_ALLPAGES + cdlPD_HIDEPRINTTOFILE + cdlPD_RETURNDC
>>oCommDialog.ShowPrinter()
>>
>
>Tried that already, but the pdf995 doesn't care about that checkbox at all. It's only called printer driver and gets installed as such, but doesn't respect the flag. I figure Amyuni and Adobe's stuff may behave the same way.
>
>>However, as you probably know, that ShowPrinter() from CommDialog ActiveX is limited. So, if you want to get the selected printer name than you will have to use PrintDlg() API
>
>>About filtering the Printer Name, I can think of the solution, but it's kind of ugly <*bg*>. Just let me know if you are interesting. I'll work on it and post it here or mail it to you
>
>Post it here - even if it doesn't work. Just need the idea, to get pointed into right direction. And I don't care if it's ugly, I won't show it to anyone :).
Sorry for taking so long. I guess I was beaten. My mind was completely blank and I'm starring at my monitor for hours! Well, sorry for the intro <*bg*>
Anyway, this is what I can come up with. I only tested on WinXP. Not sure if it will work on Win2K, but surely it won't work under Win9X/ME because the printer dialog interface is completely different. But once you know the work of it, you can adjust the "searching". Hope it works :)
Declare Long GlobalAlloc in Kernel32 Long , Long
Declare Long GlobalLock in Kernel32 Long
Declare Long GlobalUnlock in Kernel32 Long
Declare Long GlobalFree in Kernel32 Long
Declare Long PrintDlg in ComDlg32 String @
Declare Integer GetClassName in User32 Long , String @ , Integer
Declare Long FindWindowEx in User32 Long , Long , String , String
Declare Long SetTimer in User32 Long , Long , Long , Long
Declare Long KillTimer in User32 Long, Long
Declare Long SendMessage in User32 Long , Long , Long , Long
sPrintDlg = BinToC( 66, '4rs' ) + BinToC( _VFP.hWnd, '4rs' ) + ;
replicate( chr(0), 12 ) + BinToC( 0x00100000, '4rs' ) + ;
replicate( BinToC( 1, '2rs' ) + BinToC( 4096, '2rs' ), 2 ) + ;
BinToC( 1, '2rs' ) + replicate( chr(0), 32 )
oWMHandler = CreateObject( 'WM_Handler', 'fax' )
nResult = PrintDlg( @sPrintDlg )
oWMHandler = Null
If (nResult != 0)
hDevMode = CToBin( substr( sPrintDlg, 9, 4 ), '4rs' )
hDevNames = CToBin( substr( sPrintDlg, 13, 4 ), '4rs' )
pDevMode = GlobalLock( hDevMode )
cPrinterName = sys( 2600, pDevMode, 32 )
GlobalUnlock( pDevMode )
nLen = at( chr(0), cPrinterName ) - 1
If (nLen > 0)
cPrinterName = left( cPrinterName, nLen )
endif
? 'Selected Printer:', cPrinterName
If (hDevMode != 0)
GlobalFree( hDevMode )
endif
If (hDevNames != 0)
GlobalFree( hDevNames )
endif
endif
Clear DLLs
Define class WM_Handler as Custom
hPrintDlg = 0
cFilter = ''
Procedure Init( tc_Filter )
This.cFilter = tc_Filter
BindEvent( _VFP.hWnd, 0x0006, This, 'WndProc' )
BindEvent( _VFP.hWnd, 0x0113, This, 'WndProc' )
EndProc
Procedure WndProc( th_Wnd, tn_Msg, t_wParam, t_lParam )
Local lc_ClassName, lc_Text
Local lh_Wnd, ln_Counts, ln_Len, ln_I
Local lp_Buffer, lp_ItemText, ls_Item
If (tn_Msg == 0x06)
If (t_wParam == 0)
lc_ClassName = space( 64 )
ln_Len = GetClassName( t_lParam, @lc_ClassName, 64 )
If (ln_Len > 0) and ('#32770' $ lc_ClassName)
This.hPrintDlg = t_lParam
UnBindEvents( th_Wnd, 6 )
SetTimer( _VFP.hWnd, 1, 50, 0 )
endif
endif
else
lh_Wnd = FindWindowEx( This.hPrintDlg, 0, '#32770', 'General' )
lh_Wnd = FindWindowEx( lh_Wnd, 0, 'SHELLDLL_DefView', 0 )
lh_Wnd = FindWindowEx( lh_Wnd, 0, 'SysListView32', 'FolderView' )
If (lh_Wnd != 0)
KillTimer( th_Wnd, 1 )
ln_Counts = SendMessage( lh_Wnd, 4100, 0, 0 ) - 1
lp_Buffer = GlobalAlloc( 64, 320 )
If (lp_Buffer != 0)
lp_ItemText = lp_Buffer + 128
For ln_I = 0 to ln_Counts
ls_Item = BinToC( 1, '4rs' ) + BinToC( ln_I, '4rs' ) + ;
replicate( chr(0), 12 ) + BinToC( lp_ItemText, '4rs' ) + ;
BinToC( 128, '4rs' ) + replicate( chr(0), 24 )
sys( 2600, lp_Buffer, len( ls_Item ), ls_Item )
ln_Len = SendMessage( lh_Wnd, 4141, ln_I, lp_Buffer )
lc_Text = sys( 2600, lp_ItemText, ln_Len )
If (upper( This.cFilter ) $ upper( lc_Text ))
SendMessage( lh_Wnd, 4104, ln_I, 0 )
endif
Next
GlobalFree( lp_Buffer )
else
endif
endif
endif
Return 0
EndProc
Procedure Destroy
KillTimer( _VFP.hWnd, 1 )
UnBindEvents( _VFP.hWnd, 0x0006 )
UnBindEvents( _VFP.hWnd, 0x0113 )
EndProc
EndDefine
Herman