mathieu_cupryk
asked on
Disable ctrl + P
I want to disable control + P
in my web application so nobody can print from the web app.
This should be done through ieViewer object.
Problem with SHDocVW Internetexplorer PlugIn
with the ctrl + P print disable.
in my web application so nobody can print from the web app.
This should be done through ieViewer object.
Problem with SHDocVW Internetexplorer PlugIn
with the ctrl + P print disable.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I will try both guys.
but what does WebBrowser1.WebBrowserShor tcutsEnabl ed = False?
but what does WebBrowser1.WebBrowserShor
Hi,
If we make WebBrowser1.WebBrowserShor tcutsEnabl ed = False, then it will disable all the keyboard shortcuts. So I am wondering whether we should use only to disable printing ability.
Regards,
kulkarnivishwajit
If we make WebBrowser1.WebBrowserShor
Regards,
kulkarnivishwajit
ASKER
Hi Kulk,
I don;t think it would be wise to diasable all the keyboard shortcuts.
http://www.devx.com/codemag/Article/20145/1954?pf=true
Is there another way?
I don;t think it would be wise to diasable all the keyboard shortcuts.
http://www.devx.com/codemag/Article/20145/1954?pf=true
Is there another way?
ASKER
Here is another example?
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=160976&SiteID=1
But I just need to disable the Ctrl+P
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=160976&SiteID=1
But I just need to disable the Ctrl+P
ASKER
I am also talking to you gang, you must excuse me I am tired after 14 hour days.
'Just change the keys u want and Add the Handler of the Event Defined
' -------------------------- ---------- ---------- ----
' Class LowLevelKeyBoardhook
' -------------------------- ---------- ---------- ----
Imports System.Runtime.InteropServ ices
'Note : This class wont work in IDE
'If u want to see the effects Execute the Application from bin
Public Class LowLevelKeyBoardhook
Private Const HC_ACTION As Integer = 0
Private Const WH_KEYBOARD_LL As Integer = 13
Private Const WM_KEYDOWN As Integer = &H100
Private Const WM_SYSKEYDOWN As Integer = &H104
Public Structure KBDLLHOOKSTRUCT
Public vkCode As Integer
Public scancode As Integer
Public flags As Integer
Public time As Integer
Public dwExtraInfo As Integer
End Structure
Private Declare Function SetWindowsHookEx Lib "user32" _
Alias "SetWindowsHookExA" ( _
ByVal idHook As Integer, _
ByVal lpfn As LowLevelKeyboardProcDelega te, _
ByVal hmod As Integer, _
ByVal dwThreadId As Integer) As Integer
Private Declare Function CallNextHookEx Lib "user32" ( _
ByVal hHook As Integer, _
ByVal nCode As Integer, _
ByVal wParam As Integer, _
ByVal lParam As KBDLLHOOKSTRUCT) As Integer
Private Declare Function UnhookWindowsHookEx Lib "user32" ( _
ByVal hHook As Integer) As Integer
Private Delegate Function LowLevelKeyboardProcDelega te( _
ByVal nCode As Integer, _
ByVal wParam As Integer, _
ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Integer) As Integer
Public Event CtrlShiftF12()
Private hhkLowLevelKeyboard As Integer
Private keyboardDelegate As LowLevelKeyboardProcDelega te
Public Sub New()
keyboardDelegate = New LowLevelKeyboardProcDelega te(Address Of Me.LowLevelKeyboardProc)
hhkLowLevelKeyboard = SetWindowsHookEx(WH_KEYBOA RD_LL, keyboardDelegate, _
Marshal.GetHINSTANCE(Syste m.Reflecti on.Assembl y.GetExecu tingAssemb ly.GetModu les()(0)). ToInt32, 0)
End Sub
Private Function LowLevelKeyboardProc( _
ByVal nCode As Integer, _
ByVal wParam As Integer, _
ByRef lParam As KBDLLHOOKSTRUCT) As Integer
If (nCode = HC_ACTION) Then
Select Case wParam
Case WM_KEYDOWN, WM_SYSKEYDOWN
If GetAsyncKeyState(Keys.Cont rolKey) AndAlso _
GetAsyncKeyState(Keys.Shif tKey) AndAlso _
(lParam.vkCode = Keys.F12) Then
RaiseEvent CtrlShiftF12()
End If
End Select
End If
Return CallNextHookEx(hhkLowLevel Keyboard, nCode, wParam, lParam)
End Function
Protected Overrides Sub Finalize()
UnhookWindowsHookEx(hhkLow LevelKeybo ard)
MyBase.Finalize()
End Sub
End Class
'Note : This class wont work in IDE
'If u want to see the effects Execute the Application from bin
' -------------------------- ---------- ---------- ----
' Class Form1
' -------------------------- ---------- ---------- ----
Public Class Form1
Inherits System.Windows.Forms.Form
Private WithEvents llkb As New LowLevelKeyBoardhook
Private Sub llkb_CtrlShiftF12() Handles llkb.CtrlShiftF12
MsgBox("Ctrl-Shift-F12 Pressed ")
End Sub
End Class
'For example execution the code witha Form is provided
Try It (It is written for Key Combination Ctrl+Shit+F12 u can change it for Ctrl+p)
' --------------------------
' Class LowLevelKeyBoardhook
' --------------------------
Imports System.Runtime.InteropServ
'Note : This class wont work in IDE
'If u want to see the effects Execute the Application from bin
Public Class LowLevelKeyBoardhook
Private Const HC_ACTION As Integer = 0
Private Const WH_KEYBOARD_LL As Integer = 13
Private Const WM_KEYDOWN As Integer = &H100
Private Const WM_SYSKEYDOWN As Integer = &H104
Public Structure KBDLLHOOKSTRUCT
Public vkCode As Integer
Public scancode As Integer
Public flags As Integer
Public time As Integer
Public dwExtraInfo As Integer
End Structure
Private Declare Function SetWindowsHookEx Lib "user32" _
Alias "SetWindowsHookExA" ( _
ByVal idHook As Integer, _
ByVal lpfn As LowLevelKeyboardProcDelega
ByVal hmod As Integer, _
ByVal dwThreadId As Integer) As Integer
Private Declare Function CallNextHookEx Lib "user32" ( _
ByVal hHook As Integer, _
ByVal nCode As Integer, _
ByVal wParam As Integer, _
ByVal lParam As KBDLLHOOKSTRUCT) As Integer
Private Declare Function UnhookWindowsHookEx Lib "user32" ( _
ByVal hHook As Integer) As Integer
Private Delegate Function LowLevelKeyboardProcDelega
ByVal nCode As Integer, _
ByVal wParam As Integer, _
ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Integer) As Integer
Public Event CtrlShiftF12()
Private hhkLowLevelKeyboard As Integer
Private keyboardDelegate As LowLevelKeyboardProcDelega
Public Sub New()
keyboardDelegate = New LowLevelKeyboardProcDelega
hhkLowLevelKeyboard = SetWindowsHookEx(WH_KEYBOA
Marshal.GetHINSTANCE(Syste
End Sub
Private Function LowLevelKeyboardProc( _
ByVal nCode As Integer, _
ByVal wParam As Integer, _
ByRef lParam As KBDLLHOOKSTRUCT) As Integer
If (nCode = HC_ACTION) Then
Select Case wParam
Case WM_KEYDOWN, WM_SYSKEYDOWN
If GetAsyncKeyState(Keys.Cont
GetAsyncKeyState(Keys.Shif
(lParam.vkCode = Keys.F12) Then
RaiseEvent CtrlShiftF12()
End If
End Select
End If
Return CallNextHookEx(hhkLowLevel
End Function
Protected Overrides Sub Finalize()
UnhookWindowsHookEx(hhkLow
MyBase.Finalize()
End Sub
End Class
'Note : This class wont work in IDE
'If u want to see the effects Execute the Application from bin
' --------------------------
' Class Form1
' --------------------------
Public Class Form1
Inherits System.Windows.Forms.Form
Private WithEvents llkb As New LowLevelKeyBoardhook
Private Sub llkb_CtrlShiftF12() Handles llkb.CtrlShiftF12
MsgBox("Ctrl-Shift-F12 Pressed ")
End Sub
End Class
'For example execution the code witha Form is provided
Try It (It is written for Key Combination Ctrl+Shit+F12 u can change it for Ctrl+p)
WebBrowser1.WebBrowserShor