Disable image paste on richedit and VSCROLL

Disable image paste on richedit and VSCROLL

Postby AntoninoP » Sat Mar 03, 2018 9:42 am

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
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Disable image paste on richedit and VSCROLL

Postby Antonio Linares » Sun Mar 04, 2018 1:08 pm

Antonino,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Disable image paste on richedit and VSCROLL

Postby AntoninoP » Sun Mar 04, 2018 8:40 pm

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.
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Disable image paste on richedit and VSCROLL

Postby cnavarro » Sun Mar 04, 2018 9:14 pm

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
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Disable image paste on richedit and VSCROLL

Postby AntoninoP » Mon Mar 05, 2018 8:37 am

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:
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Disable image paste on richedit and VSCROLL

Postby cnavarro » Mon Mar 05, 2018 12:53 pm

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
 
Last edited by cnavarro on Mon Mar 05, 2018 4:46 pm, edited 1 time in total.
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Disable image paste on richedit and VSCROLL

Postby cnavarro » Mon Mar 05, 2018 12:55 pm

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
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Disable image paste on richedit and VSCROLL

Postby AntoninoP » Wed Mar 07, 2018 8:12 am

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...
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Disable image paste on richedit and VSCROLL

Postby Antonio Linares » Wed Mar 07, 2018 8:43 am

Antonino,

You are totally right :-)

We are going to modify it, many thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Disable image paste on richedit and VSCROLL

Postby AntoninoP » Wed Mar 07, 2018 9:48 am

wow, this answer is unexpected :shock:
I glad to help
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Disable image paste on richedit and VSCROLL

Postby Antonio Linares » Wed Mar 07, 2018 11:26 am

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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 75 guests