From: Danijel on
Hi,

I use ShellExecute to open and printing documents (HTML type of
files). This
works fine for opening files. I would like printing witout opening,
but nothing seems to happen
Does anyone has a any idea to printing HTML files witout opening
I would be obliged for some ideas

kind regards
From: dlzc on
Dear Danijel:

On May 13, 3:01 am, Danijel <danijel.koprivn...(a)gmail.com> wrote:
> I  use ShellExecute to open and printing
> documents (HTML type of files). This
> works fine for opening files. I would
> like printing witout opening, but nothing
> seems to happen. Does anyone has a any
> idea to printing HTML files witout opening
> I would be obliged for some ideas

IE does not support printing based on command-line commands.

May not help:
http://social.msdn.microsoft.com/Forums/en/ieextensiondevelopment/thread/3c7034e1-e52d-419c-9525-14cd8037932e

David A. Smith
From: richard.townsendrose on
Danijel

its a nightmare .... because shelecex reliese on the called programme
to do whats its told... and some software like adobe 5 REFUSES to
close once used for a print ... ms stuff [office] is totally
unpreductable ! openoffice usually behaves as does workperfect.
interestingly wordpad and notepad do whats expected

I have collected over the years lots ofd code snipperts and spent
hours on this problem ...

below is what i finally settled for ! works mostly for adobe !

richard
*********************
METHOD PrintAttachment(cDocName) CLASS MailPrint
LOCAL ExecInfo IS _winSHELLEXECUTEINFO
LOCAL hProc, hwnd AS PTR

/*
// print
DdeClientTransaction(FilePrintTo(MyDoc.pdf,PrinterName)
// close reader when print job is done
DdeClientTransaction(AppExit())
*/

// works but leaves app open
// ShellExecute(NULL, String2Psz("print"), String2Psz(cDocName), NULL,
NULL, SW_HIDE )

// does NOT print for windows picture and fax viewer
ExecInfo.cbSize := _SIZEOF( _WINShellExecuteInfo )
ExecInfo.hwnd := SysObject():Handle()
ExecInfo.lpVerb := String2Psz("print")
ExecInfo.lpFile := String2Psz( cDocName )
ExecInfo.lpParameters := NULL
ExecInfo.nShow := SW_HIDE
ExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS + SEE_MASK_FLAG_DDEWAIT

IF ShellExecuteEx( @ExecInfo ) // works
// Wait while its printing
hProc := ExecInfo.hProcess

IF Upper(Right(cDocName,3)) == 'PDF'
DO WHILE (hwnd := FindWindow(NULL_PSZ, PSZ("Adobe
Reader"))) = NULL_PTR
Sleep(500)
ENDDO
Sleep(5000)
// Close
PostMessage(hwnd, WM_CLOSE, 0, 0)
ELSE // not adobe
DO WHILE WaitForSingleObject( hProc, 0 ) = WAIT_OBJECT_0 //
WAIT_TIMEOUT
Sleep(500)
ENDDO
// Close it.
SendMessage(hProc, WM_CLOSE, 0, 0) // whats the difference
between send and post ?
SendMessage(hProc, WM_QUIT, 0, 0) // whats the difference
between send and post ?
PostMessage(hProc, WM_CLOSE, 0, 0) // whats the difference
between send and post ?
PostMessage(hProc, WM_QUIT, 0, 0) // whats the difference
between send and post ?
ENDIF

ELSE
TextBox{SELF, 'Error','Error:' + AsString(ExecInfo.hInstApp) +
CRLF + ;
'Handle:' + AsString(ExecInfo.hWnd) + CRLF + ;
'Class:' + AsString(ExecInfo.lpClass) + CRLF + ;
'Params:' + AsString(ExecInfo.lpParameters) + CRLF + ;
'Verb:' + AsString(ExecInfo.lpVerb) + CRLF + ;
'File:' + AsString(ExecInfo.lpFile) + CRLF + ;
'Mask:' + AsString(ExecInfo.fMask) + CRLF + ;
'Size:' + AsString(ExecInfo.cbSize) + CRLF + ;
'Show:' + AsString(ExecInfo.nShow)}:Show()
ENDIF

RETURN NIL

// following are code snippets off web.

// this code keeps running while the app is running. not when process
is finished.
/* lRunning := ( lpExitCode == STILL_ACTIVE )
DO WHILE lRunning
GetExitCodeProcess( hProc, @lpExitCode )
lRunning := ( lpExitCode == STILL_ACTIVE )
ApplicationExec(EXECWHILEEVENT)
ENDDO
*/

/*
FUNCTION PrintPDFwithAdobeReader(oOwner AS OBJECT, cPDFFile AS STRING)
AS VOID PASCAL
LOCAL ExecInfo AS _winSHELLEXECUTEINFO
LOCAL hWnd AS PTR

// Allocate structure memory
ExecInfo:=MemAlloc(_SizeOf(_winSHELLEXECUTEINFO))

// Structure params
ExecInfo.cbSize:=_SizeOf(_winSHELLEXECUTEINFO)
ExecInfo.fMask:=_Or(SEE_MASK_FLAG_DDEWAIT,
SEE_MASK_NOCLOSEPROCESS) // not needed ?
ExecInfo.lpVerb:=PSZ("print")
ExecInfo.lpFile:=PSZ(cPDFFile)
ExecInfo.nShow:=SW_SHOWMINIMIZED // no effect ??? // SW_HIDE

// Do it
IF ShellExecuteEx(ExecInfo)
oOwner:Pointer:=Pointer{POINTERHOURGLASS}

// Looking for the "Adobe Reader" caption...
// If it's a NULL_PTR, it is still printing...
DO WHILE (hWnd:=FindWindow(NULL_PSZ, PSZ("Adobe
Reader")))=NULL_PTR
DoEvents()
Sleep(100)
ENDDO

// Close it.
PostMessage(hWnd, WM_CLOSE, 0, 0)

oOwner:Pointer:=Pointer{POINTERARROW}
ENDIF
// Clean up
MemFree(ExecInfo)
*/

/*
METHOD OpenAndWait( cFile ) CLASS IMSDirectory
LOCAL lpShellInfo IS _winShellExecuteInfo
LOCAL lRet AS LOGIC
LOCAL hProc AS PTR

Default( @cFile, SELF:cFilePath+SELF:FileName )

IF Empty( cFile )
SELF:lErrorFlag := TRUE
SELF:cErrorMessage := "Keinen Dateinamen erhalten!"
ENDIF

lpShellInfo.cbSize := _SizeOf( _winShellExecuteInfo )
lpShellInfo.hwnd := SELF:Owner:Handle()
lpShellInfo.lpVerb := String2Psz("open")
lpShellInfo.lpFile := String2Psz( cFile )
lpShellInfo.nShow := SW_ShowNormal
lpShellInfo.fMask := SEE_MASK_NOCLOSEPROCESS + SEE_MASK_FLAG_DDEWAIT

lRet := ShellExecuteEx( @lpShellInfo )

IF lRet
hProc := lpShellInfo.hProcess
WHILE WaitForSingleObject( hProc, 0 ) = WAIT_TIMEOUT
Sleep(500)
ENDDO
ENDIF

RETURN
*/
From: Geoff Schaller on
Danijel,

This is not really appropriate - don't try. Nor is it a reasonable thing
to do because heaps depends on the page design, underlying code and
functionality. At very least you should be using an OLE web browser
control where you can at least execute such functionality, assuming the
page itself supports it.

ShellExecute really shouldn't be used for something like this. An
equivalent would be driving a car blind folded.

Geoff



"Danijel" <danijel.koprivnjak(a)gmail.com> wrote in message
news:ae3a8a2b-d54b-4585-818f-7270bd7cf0ac(a)p2g2000yqh.googlegroups.com:

> Hi,
>
> I use ShellExecute to open and printing documents (HTML type of
> files). This
> works fine for opening files. I would like printing witout opening,
> but nothing seems to happen
> Does anyone has a any idea to printing HTML files witout opening
> I would be obliged for some ideas
>
> kind regards

 | 
Pages: 1
Prev: Byte Array over COM
Next: Lotus Notes SIX