Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another internal SelectReplaceHighlightFormat question
#1
In the SelectReplaceHighlightFormat code there is the following statement:
Function SelectReplaceHighlightFormat
Code:
Copy      Help
__ProcessMemory m.Alloc(hwndre 1000)

I know from the documentation that this is for allocating memory in the context of the process that the window handle belongs to. What's unclear to me is - what is the relation of the size of the buffer and the size of the text that is being updated?

In a subsequent line there is this command:
Function SelectReplaceHighlightFormat
Code:
Copy      Help
SendMessage hwndre EM_REPLACESEL 0 replacetext

My question: if replaceText.len > 1000 - should the buffer be larger? Or is this irrelevant - SendMessage manages its own memory and the Alloc is just for the target application having enough memory to do housekeeping (which may mean that it needs to be larger).

Thanks
#2
In this cases the memory is used only for the CHARFORMAT2W variable.
Code:
Copy      Help
out sizeof(CHARFORMAT2W)
Windows knows EM_REPLACESEL and copies the string, don't need shared memory for it. Same with WM_SETTEXT, maybe with several other known messages. For other messages where text used need __ProcessMemory, allocate enough memory for the string.


Forum Jump:


Users browsing this thread: 1 Guest(s)