The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: ToutEnMasm on April 27, 2009, 08:26:32 AM

Title: reusing the wordpad
Post by: ToutEnMasm on April 27, 2009, 08:26:32 AM

This example run the wordpad
           - extract the handle of the richedit
           - use the handle to write some text in it
Then he try to select the text and get the charformat.
This failed,it seems there is some memory problems.
Who can help ?




[attachment deleted by admin]
Title: Re: reusing the wordpad
Post by: dedndave on May 06, 2009, 01:34:42 AM
look at it with olly and see what the "sizeof" operator is yielding

   mov commun.defautcharformat.cbSize,sizeof CHARFORMAT2
   mov commun.charformat.cbSize,sizeof CHARFORMAT2
Title: Re: reusing the wordpad
Post by: ToutEnMasm on May 06, 2009, 08:53:07 AM

the more simple case to solve is the text selection.
Quote
   mov commun.charrange.cpMin,0
   mov commun.charrange.cpMax,-1
   invoke SendMessage,Hredit,EM_SETSEL,0,-1
   ;invoke SendMessage,Hredit,EM_EXSETSEL,NULL,addr commun.charrange
As a alternate soluce,i used the EM_SETSEL message (Edit message) that work.
The EM_EXSETSEL failed with no visible reason and there isn't problem with unicode and the size of the structure.
Size of  charformat2 is 9C






Title: Re: reusing the wordpad
Post by: dedndave on May 06, 2009, 09:07:58 AM
glad you got it running  :U
i mentioned the sizeof operator because i had seen a number of other posts regarding sizeof problems