Some times uses will be copy/pasting on datawindow due to which issues may happen (specially in the trademark symbols etc.,)
So we may need to restrict copy pasting on datawindow/ only some columns on datawindow.
The below code will be usefull to acheive this.
In this case I have used demo database to create a freeform datawindow and I am not allowing copy/paste on 2 columns. Also I am showing a message box to users that copy pasting is not allowed on those 2 columns.
No need to think Item changed/ Clicked, In this case we will be using a windows event ID to acheive this
Before we proceed make sure that Ctrl + V is not used in the menu. In this case the menu Ctrl+V will supress our event.
In the datawindow on which you need to restrict copy/Paste, create a event and map to pbm_dwnkey and external check box unchecked. Write the below code in that-
boolean ib_CaptureTab = true string ls_columnname ls_columnname =this.getcolumnname() IF trim(ls_Columnname) <> "" THEN // 86 Is the ANSCII value for V IF ib_CaptureTab AND KeyDown(Keycontrol!) and KeyDown(86) and (ls_columnname ='first_name' or ls_columnname='city') THEN string ls_1 = '' ls_1 = clipboard() ls_1 ="" ::clipboard(ls_1) MessageBOx("Info","You can't use copy/paste on this field.Please type manually") END IF END IF
In above code I have restricted cntrl+v on firstname and city. You need to modify your code accordingly.
Also some cases if users know that Shift +Insert also works to copy then we need to modify code for that also.
Just add onemore if condition for KeyDown(KeyShift!) and KeyDown(KeyInsert!). Thats it.