Page 1 of 1

Disable image paste on richedit and VSCROLL

PostPosted: Sat Mar 03, 2018 9:42 am
by AntoninoP
Hello,
I created a program using TRichEdit and I have 2 question about it:
I see that if I have an image on the clipboard it will be pasted on the control... because my program allow to edit ini files, how I can disable it?
I would like to intercept EN_VSCROLL, is it possible?
Thanks,
Antonino

Re: Disable image paste on richedit and VSCROLL

PostPosted: Sun Mar 04, 2018 1:08 pm
by Antonio Linares
Antonino,

Could you please provide a small and self contained example PRG to test here ? thanks

Re: Disable image paste on richedit and VSCROLL

PostPosted: Sun Mar 04, 2018 8:40 pm
by AntoninoP
Hello,
now I can not test, but the first is a common problem:
https://social.msdn.microsoft.com/Forums/en-US/0f762cb8-7383-4937-8ee8-f8df5d3a9852/disable-image-paste-in-richtextbox

I am follow this sample https://www.codeproject.com/Articles/13581/Fast-HTML-syntax-highlighting-with-the-Rich-Edit-c and it highlight only the visible part intercepting the VScroll command.

Re: Disable image paste on richedit and VSCROLL

PostPosted: Sun Mar 04, 2018 9:14 pm
by cnavarro
Antonino, now I understand your first question

Please try

Code: Select all  Expand view


//----------------------------------------------------------------------------//

METHOD Paste() CLASS TRichEdit5

   if GetClipContentFormat( 13, 1, 7, 15 ) > 0
   ::SendMsg( WM_PASTE )
   ::PostMsg( FM_CHANGE )
   endif

return nil

//----------------------------------------------------------------------------//

 


For second question, ( EN_VSCROLL ), please wait
I have tried to capture the message without success yet
https://msdn.microsoft.com/en-us/librar ... 89(v=vs.85).aspx

Re: Disable image paste on richedit and VSCROLL

PostPosted: Mon Mar 05, 2018 8:37 am
by AntoninoP
The first problem looks ok, I already derived the TRichEdit so I added the Paste method.
The second problem looks like http://forums.fivetechsupport.com/viewtopic.php?f=3&t=34982&p=208642 because TDIalog:Command filter the commands... In this case microsoft should use WM_VSCROLL but we can not change the operation system :lol:

Re: Disable image paste on richedit and VSCROLL

PostPosted: Mon Mar 05, 2018 12:53 pm
by cnavarro
Antonino, for next version

New DATA
Code: Select all  Expand view

   DATA   aFmtsClpPaste INIT {}
 


and Paste METHOD modified

Code: Select all  Expand view

METHOD Paste() CLASS TRichEdit5

   local lSw   := .F.

   if !Empty( ::aFmtsClpPaste )
      if GetClipContentFormat( ::aFmtsClpPaste ) > 0
         lSw   := .T.
      endif
   else
      lSw   := .T.
   endif
   if lSw
      if ::CanPaste()
         ::SendMsg( WM_PASTE )
         ::PostMsg( FM_CHANGE )
      else
         MsgInfo( "Format Data in clipboard or ReadOnly Document", "Not Allowed Paste" )
      endif
   else
      MsgInfo( "Format Data in clipboard or ReadOnly Document", "Not Allowed Paste" )
   endif

return lSw
 

Re: Disable image paste on richedit and VSCROLL

PostPosted: Mon Mar 05, 2018 12:55 pm
by cnavarro
AntoninoP wrote:The second problem looks like http://forums.fivetechsupport.com/viewtopic.php?f=3&t=34982&p=208642 because TDIalog:Command filter the commands... In this case microsoft should use WM_VSCROLL but we can not change the operation system :lol:


I Know this, but I think that is not just the problem
Please wait

Re: Disable image paste on richedit and VSCROLL

PostPosted: Wed Mar 07, 2018 8:12 am
by AntoninoP
In My Humble Opinion the WM_COMMAND management should be different, put on TWindow and/or TDialog something like:
Code: Select all  Expand view
METHOD Command( nWParam, nLParam )
   local nNotifyCode, nID, hWndCtl, oCtrl
   nNotifyCode = nHiWord( nWParam )
   nID         = nLoWord( nWParam )
   hWndCtl     = nLParam
   do case
      case ::oPopup != nil
           ::oPopup:Command( nID )

      case hWndCtl == 0 .and. ::oMenu != nil .and. ;
            nNotifyCode == BN_CLICKED .and. nID != IDCANCEL
           ::oMenu:Command( nID )

      case (oCtrl := oWndFromHwnd( hWndCtl )) != nil .and. oCtrl:isKindOf("TCONTROL")
            oCtrl:Command( nWParam, nLParam )

   endcase
return nil

add an empty implementation on TControl, and move other case on respective classes, for example BN_CLICKED is only on button, CBN_SELCHANGE is only on ComboBox...

Re: Disable image paste on richedit and VSCROLL

PostPosted: Wed Mar 07, 2018 8:43 am
by Antonio Linares
Antonino,

You are totally right :-)

We are going to modify it, many thanks

Re: Disable image paste on richedit and VSCROLL

PostPosted: Wed Mar 07, 2018 9:48 am
by AntoninoP
wow, this answer is unexpected :shock:
I glad to help

Re: Disable image paste on richedit and VSCROLL

PostPosted: Wed Mar 07, 2018 11:26 am
by Antonio Linares
Antonino,

Maybe I answered you too fast :-)

I am testing it and I am not sure that it may work properly...

Sometimes notifications are sent to the container of the control. In example, a BN_... notification is not sent to a button but to its container.

So it is the container the responsable for properly routing the message.