>>#Define cdlPD_HIDEPRINTTOFILE 0x00100000 >> >>oCommDialog.Flags = cdlPD_ALLPAGES + cdlPD_HIDEPRINTTOFILE + cdlPD_RETURNDC >>oCommDialog.ShowPrinter() >>>
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 ) ** Remove any printer name that has a string 'FAX' in it 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 ** GetLastError() endif endif endif Return 0 EndProc Procedure Destroy KillTimer( _VFP.hWnd, 1 ) UnBindEvents( _VFP.hWnd, 0x0006 ) UnBindEvents( _VFP.hWnd, 0x0113 ) EndProc EndDefine