websmiley
Messages postés27Date d'inscriptionjeudi 4 mars 2004StatutMembreDernière intervention13 août 2009
-
29 mai 2006 à 19:31
websmiley
Messages postés27Date d'inscriptionjeudi 4 mars 2004StatutMembreDernière intervention13 août 2009
-
30 mai 2006 à 08:50
Hello à tous, j'ai un petit souci...
J'ai un webbrowser qui s'affiche et je souhaiterais imprimer son contenu. J'ai donc ce code:
<hr />Option Explicit
Private Const SW_SHOWNORMAL = 1
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub SetFocusToBrowser(hBrowserHwnd As Long)
Dim lStyle As Long
Dim lResult As Long
Dim hwnd As Long
hwnd = hBrowserHwnd
While (lResult = 0) And (hwnd <> 0)
hwnd = GetWindow(hwnd, GW_CHILD)
lStyle = GetWindowLong(hwnd, GWL_STYLE)
lResult = lStyle And WS_VSCROLL
Wend
SetFocusAPI (hwnd)
End Sub
Private Sub print_browser()
Dim hwnd As Long
WebBrowser1.SetFocus
hwnd = GetFocus
SetFocusToBrowser (hwnd)
SendKeys "^p"
End Sub
<hr />
Depuis VB, ca fonctionne à merveille, mais dès que je cré mon .exe et que je fais le test sur un autre poste, rien ne se passe...
Avez-vous une idée??? Ou une alternative (avec une commondialog ou autre...).
Merci d'avance
<hr />La théorie c'est quand rien ne marche et que tout le monde sait pourquoi.
La pratique c'est quand tout marche et que personne ne sait pourquoi