FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Disable image paste on richedit and VSCROLL
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Disable image paste on richedit and VSCROLL
Posted: Sat Mar 03, 2018 09: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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Disable image paste on richedit and VSCROLL
Posted: Sun Mar 04, 2018 01: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
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: Disable image paste on richedit and VSCROLL
Posted: Sun Mar 04, 2018 08: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.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Disable image paste on richedit and VSCROLL
Posted: Sun Mar 04, 2018 09:14 PM
Antonino, now I understand your first question

Please try

Code (fw): Select all Collapse
//----------------------------------------------------------------------------//

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
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: Disable image paste on richedit and VSCROLL
Posted: Mon Mar 05, 2018 08: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 :-)
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Disable image paste on richedit and VSCROLL
Posted: Mon Mar 05, 2018 12:53 PM
Antonino, for next version

New DATA
Code (fw): Select all Collapse
   DATA   aFmtsClpPaste INIT {}


and Paste METHOD modified

Code (fw): Select all Collapse
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
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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Disable image paste on richedit and VSCROLL
Posted: 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 :-)


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
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: Disable image paste on richedit and VSCROLL
Posted: Wed Mar 07, 2018 08:12 AM
In My Humble Opinion the WM_COMMAND management should be different, put on TWindow and/or TDialog something like:
Code (fw): Select all Collapse
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...
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Disable image paste on richedit and VSCROLL
Posted: Wed Mar 07, 2018 08:43 AM

Antonino,

You are totally right :-)

We are going to modify it, many thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: Disable image paste on richedit and VSCROLL
Posted: Wed Mar 07, 2018 09:48 AM

wow, this answer is unexpected :shock:
I glad to help

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Disable image paste on richedit and VSCROLL
Posted: 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

Continue the discussion