Does anyone know of a simple way to test if a RTE is in insert or overwrite
mode. I can't find any listed messages / properties in the windows docs - in fact the only mention I can find is in the discussion of the Text Object Model in the ITextSelection interface and it seems a little OTT to have to start digging around with this. It *appears* that the RTE always begins life in insert mode so the easiest way would be to assume this is the case and then monitor the keyboard event for the insert key - is this a safe assumption? TIA David |
David
You wrote in message news:94ecd5$7vj$[hidden email]... > Does anyone know of a simple way to test if a RTE is in insert or overwrite > mode. I can't find any listed messages / properties in the windows docs - in > fact the only mention I can find is in the discussion of the Text Object > Model in the ITextSelection interface and it seems a little OTT to have to > start digging around with this. That is the only method I can find too. I wouldn't dismiss it entirely, as I think you will find it is actually pretty easy to use the COM interface. However it looks as if it requires the use of version 2.0 (or later) of the RTE, and Dolphin wraps v1.0 for historical reasons related to Win95. This might mean further work in creating a RichTextEdit2 subclass of RichTextEdit as I seem to recall that the behaviour of v2 differs in some significant ways such as the treatment of line-terminators. > It *appears* that the RTE always begins life in insert mode so the easiest > way would be to assume this is the case and then monitor the keyboard event > for the insert key - is this a safe assumption? Hmmm, perhaps but I would be worried about keeping it in step. Regards Blair |
> That is the only method I can find too. I wouldn't dismiss it entirely, as
I > think you will find it is actually pretty easy to use the COM interface. > However it looks as if it requires the use of version 2.0 (or later) of the > RTE, and Dolphin wraps v1.0 for historical reasons related to Win95. This > might mean further work in creating a RichTextEdit2 subclass of RichTextEdit > as I seem to recall that the behaviour of v2 differs in some significant > ways such as the treatment of line-terminators. > Blair Thanks for the reply Blair - I've had a look at the COM interfaces and as you say it does it look pretty straightforward - the AXComponent wizard does a tremendous job in generating the Smalltalk classes and methods. I think I'll have a go at wrapping the RichEd20.dll - it seems all that is needed in addition is to generate the PARAFORMAT2 and CHARFORMAT2 structures so I'll have a go and see how I get on. One query though - to get to the RTE COM interface I need to send EM_GETOLEINTERFACE with 0 as wParam .The lParam requires " a Pointer to a pointer that receives the IRichEditOle object" - what on earth do I send as the parameter here?. Best Wishes David |
David
You wrote in message news:94pcps$rlr$[hidden email]... > ... > Thanks for the reply Blair - I've had a look at the COM interfaces and as > you say it does it look pretty straightforward - the AXComponent wizard > does a tremendous job in generating the Smalltalk classes and methods. > > I think I'll have a go at wrapping the RichEd20.dll - it seems all that is > needed in addition is to generate the PARAFORMAT2 and CHARFORMAT2 structures > so I'll have a go and see how I get on. If you are using D4 the wizard can generate those too. > One query though - to get to the RTE COM interface I need to send > EM_GETOLEINTERFACE with 0 as wParam .The lParam requires " a Pointer to a > pointer that receives the IRichEditOle object" - what on earth do I send as > the parameter here?. Normally one would simply pass the result of an "IUnknown newPointer", but because this is using a SendMessage() call we need to manually coerce the argument instead of just letting the VM do it, e.g. we might implement RichTextEdit>>getOleInterface as follows (though note this causes a circular dependency between OLE COM and Dolphin packages, and so must be repackaged as a loose method in another package): getOleInterface | answer | answer := IUnknown newPointer. (self sendMessage: "EM_GETOLEINTERFACE" WM_USER + 60 wParam: 0 lParam: answer bytes basicYourAddress) isZero ifTrue: [self error: 'Failed to retrieve IRichEditOle']. ^answer If you've generated IRichEditOle then you could substitute that for IUnknown above, on the other hand if you don't need that interface at all then leave it as it is. You can query off the ITextDocument interface, e.g. rte := RichTextEdit allInstances first ole := rte getOleInterface. "Generate the interfaces and the constants pool - we need only do this once" tlb := (ole queryInterface: IDispatch) typeInfo typeLib. tlb prefix: ''. tlb generateInterfaceWrappers. tlb generateConstantsPool. "Now we can retrieve ITextSelection" sel := (ole queryInterface: ITextDocument) selection. "Finally: Is it in overtype mode?" sel flags allMask: (TomConstants at: 'tomSelOvertype') The above works on Win2k even using Rich Edit 1.0 because Win2k implements all the RTE versions in the same component. I doubt it will work on older systems which have separate RichEd32 (1.0) and RichEd20 (2.0) DLLs, so a generic solution will probably require a subclass for 2.0. Regards Blair |
Superb - many thanks Blair. I was stumbling down the path towards this but
I'm not sure when I would have arrived at the solution! >>it seems all that is needed in addition is to generate the PARAFORMAT2 and >>CHARFORMAT2 structures >>If you are using D4 the wizard can generate those too. This is interesting -I am using D4P. I have added these structures "by hand" - i.e defined the fields and then run compileDefinition to generate accessors - is there an easier way? One more query - when subclassing RichTextEdit to RichTextEdit2 all works as expected apart from registering the class name. According to my Header files ( from C++ Builder4) when using the ANSI form the class name should be 'RichEdit20A' but this results in a incorrect parameter walkback - ( as does 'RichEdit20' and 'RichEdit20W' ) leaving it as 'RichEdit' appears to work but I'm not sure why I'm getting this problem. David |
> One more query - when subclassing RichTextEdit to RichTextEdit2 all works
as > expected apart from registering the class name. According to my Header files > ( from C++ Builder4) when using the ANSI form the class name should be > 'RichEdit20A' but this results in a incorrect parameter walkback - ( as does > 'RichEdit20' and 'RichEdit20W' ) leaving it as 'RichEdit' appears to work > but I'm not sure why I'm getting this problem. > Please ignore this -its my spelling at fault ( dyslexics of the world untie!) David |
Free forum by Nabble | Edit this page |