Richedit ole object

Richedit ole object

Postby AntoninoP » Mon Mar 12, 2018 10:52 am

Hello,
I want implement suspend/resume on undo saving from this post http://forums.codeguru.com/showthread.php?325068-Realizing-Undo-Redo-functionality-for-RichEdit-Syntax-Highlighter&p=1080967#post1080967
And I see there is defined a REGetOleInterface in TRichEdit how can I access to it?
this method is not present on provided code.
Thanks,
Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Richedit ole object

Postby Antonio Linares » Tue Mar 13, 2018 8:41 am

Antonino,

FWH REGetOleInterface() basically does this (what you already posted in the provided example):

SendMessage( hEdit, EM_GETOLEINTERFACE, 0, ( LPARAM ) &tr_code );

IMO, in the example that you have posted you have everything you need to implement it :-)
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: Richedit ole object

Postby AntoninoP » Tue Mar 13, 2018 9:37 am

Hello,
I tryied to call oEdit:GetOleInterface and returned .T., how can i get the IRichEditOle ?
Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Richedit ole object

Postby Antonio Linares » Tue Mar 13, 2018 12:54 pm

Antonino,

Here you have the code of the example adapted to Harbour/FWH:

Code: Select all  Expand view
#include "FiveWin.ch"
#include "RichEdit.ch"

function Main()

   local oWnd, hRichEdit := LoadLibrary( "riched20.dll" ), oRichEd
   local cText := ""

   DEFINE WINDOW oWnd

   @ 0, 0 RICHEDIT oRichEd VAR cText OF oWnd

   REUndoRedo( oRichEd:hWnd )

   ACTIVATE WINDOW oWnd

   FreeLibrary( hRichEdit )

return nil

#pragma BEGINDUMP

#include <windows.h>
#include <richedit.h>
#include <richole.h>
#include <tom.h>
#include <unknwn.h>
#include <hbapi.h>

#define DEFINE_GUIDXXX(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
        EXTERN_C const GUID CDECL name \
                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }

DEFINE_GUIDXXX(IID_ITextDocument,0x8CC497C0,0xA1DF,0x11CE,0x80,0x98,
                0x00,0xAA,0x00,0x47,0xBE,0x5D);

HB_FUNC( REUNDOREDO )
{
   HWND hEdit = ( HWND ) hb_parnll( 1 );
   IUnknown * tr_code = NULL;
   ITextDocument * td_code;
   
   SendMessage( hEdit, EM_SETEVENTMASK, 0, ENM_CHANGE | ENM_KEYEVENTS | ENM_SELCHANGE );
   SendMessage( hEdit, EM_GETOLEINTERFACE, 0, ( LPARAM ) &tr_code );
   
   if( tr_code != NULL )
   {
      tr_code->lpVtbl->QueryInterface( tr_code, &IID_ITextDocument, ( void ** ) &td_code );
      td_code->lpVtbl->Undo( td_code, tomSuspend, NULL );
      td_code->lpVtbl->Undo( td_code, tomResume, NULL );
   }
   else
      MessageBox( 0, "Error when trying to get RichEdit OLE Object", "Info", 0 );
}

#pragma ENDDUMP
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: Richedit ole object

Postby AntoninoP » Tue Mar 13, 2018 2:12 pm

ah ok,

I will implement EM_GETOLEINTERFACE myself,
I was thinking to use TOleAuto.. I will post the code when i do it...

thanks anyway.
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 94 guests

cron