WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

COMCONTROL
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Disable the Context Menu on a WebPage in Dialog


Question:

When displaying a webpage with the com control in a WIL Dialog, is there a way to keep the user from being able to copy and paste the content of the window?

Answer:

This is how to disable the context menu when hosting a web page in a dialog.(See the "dialog" function help topic for more info.)
#DefineSubRoutine NoContext(hHandle, nMessage, nID, objEventInfo, reserved)

   MSG_INIT             = 0
   MSG_COMEVENT         = 14 ;COM control event fired.

   ; Options for DialogObject
   DLGOBJECT_ADDEVENT   = 1 ; DialogObject add event.
   DLGOBJECT_REMOVEVENT = 2 ; DialogObject remove event.
   DLGOBJECT_GETOBJECT  = 3 ; DialogObject get reference to object.
   DLGOBJECT_GETPICTURE = 4 ; DialogObject get a picture object.

   Switch nMessage
   Case MSG_INIT

      ; Need to hook the "NavigateComplete2" event because document
      ; object does not exist yet.
      DialogObject(hHandle, 003, DLGOBJECT_ADDEVENT,  "NavigateComplete2", 003001)
      Return -1
  Case  MSG_COMEVENT

        ; Turn off context menus when navigation is complete event fires.
      objWebBrowser = DialogObject(hHandle, 003, DLGOBJECT_GETOBJECT, "", 0)
      objWebBrowser.document.parentWindow.external.contextMenu = @FALSE
      objWebBrowser = 0
      Return -1
   EndSwitch
   Return -1
#EndSubRoutine

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=001
MyDialogY=001
MyDialogWidth=302
MyDialogHeight=219
MyDialogNumControls=003
MyDialogProcedure=`NoContext`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`077,201,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`189,201,036,012,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`003,003,294,188,COMCONTROL,DEFAULT,"http://winbatch.com/",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog")

Article ID:   W16929
File Created: 2007:07:03:14:27:06
Last Updated: 2007:07:03:14:27:06