Author |
Topic: Rich Edit controls (Read 952 times) |
|
Nick
New Member
member is offline


Gender: 
Posts: 33
|
 |
Rich Edit controls
« Thread started on: Aug 31st, 2011, 4:58pm » |
|
Greetings.
My first post!
First of all CONGRATULATIONS with BBC4W - it is absolutely fabulous, unbelievably powerful and it enables me to make windows apps quickly and which compile to such small sizes!
Having said that I am on a steep learning curve! I have spent several hours hunting around for various questions, but the following has me stumped.
I am developing a text box with a rich edit control. I open the control thus:
SYS "LoadLibrary", "RICHED20.DLL" TO hRichEditDLL% IF hRichEditDLL%=0 THEN ERROR 100,"Failed to load RICHED20.DLL"
After that, there is the usual code setting up values for various aspects, for example CHARFORMAT.
It all works superbly.
But now I want to play with values in PARAFORMAT.
The problem is that I can not see anywhere in the BBC libraries that open windows etc where it defines the PARAFORMAT structure. I presume that the richeditdll uses default values.
There is a EM_GETPARAFORMAT message, but before you use it you have to know the size of the PARAFORMAT structure. There does NOT seem to be an equivalent to "GETPARAFORMAT length" message. If I knew the relevant structure length, then I could use this to get the data:
SYS "GlobalAlloc", 0, X% TO F% SYS "SendMessage", hRichEdit%, EM_GETPARAFORMAT, 0, F%
(where X% is the length of the structure)
The MSDN article says of the lparam for the GETPARAFORMAT message:
"Pointer to a PARAFORMAT structure that receives the paragraph formatting attributes of the current selection.
...Microsoft Rich Edit 2.0 and later: This parameter can be a pointer to a PARAFORMAT2 structure, which is an extension of the PARAFORMAT structure. Before sending the EM_GETPARAFORMAT message, set the structure's cbSize member to indicate the version of the structure. "
BUT in my initialisation code for the rich edit control, I cannot see ANYWHERE where the cbSize is set... Do you only get the functionality if you predeclare it at initialisation??
Any ideas?
Thanks
Nick
P.S. MSDN on PARAFORMAT STRUCTURE: http://msdn.microsoft.com/en-us/library/bb787942(v=vs.85).aspx
|
« Last Edit: Aug 31st, 2011, 5:36pm by Nick » |
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Rich Edit controls
« Reply #1 on: Aug 31st, 2011, 9:32pm » |
|
on Aug 31st, 2011, 4:58pm, Nick wrote:There does NOT seem to be an equivalent to "GETPARAFORMAT length" message. If I knew the relevant structure length, then I could use this to get the data |
|
Unless the PARAFORMAT2 structure has unusual packing requirements, you can find the length by adding together the sizes of the various members. A quick back-of-envelope calculation suggests that it's 64 bytes (9 * 4 + 13 * 2 + 2).
If you declare the structure in BBC BASIC code you can find the length using the DIM function, thus:
Code: DIM paraformat2{cbSize%, dwMask%, wNumbering{l&,h&}, wEffects{l&,h&}, \
\ dxStartIndent%, dxRightIndent%, dxOffset%, wAlignment{l&,h&}, \
\ cTabCount{l&,h&}, rgxTabs%, dySpaceBefore%, dySpaceAfter%, dyLineSpacing%, \
\ sStyle{l&,h&}, bLineSpacingRule&, bOutlineLevel&, wShadingWeight{l&,h&}, \
\ wShadingStyle{l&,h&}, wNumberingStart{l&,h&}, wNumberingStyle{l&,h&}, \
\ wNumberingTab{l&,h&}, wBorderSpace{l&,h&}, wBorderWidth{l&,h&}, wBorders{l&,h&}}
PRINT DIM(paraformat2{}) Richard.
|
|
Logged
|
|
|
|
Nick
New Member
member is offline


Gender: 
Posts: 33
|
 |
Re: Rich Edit controls
« Reply #2 on: Aug 31st, 2011, 9:56pm » |
|
on Aug 31st, 2011, 9:32pm, Richard Russell wrote:If you declare the structure in BBC BASIC code you can find the length using the DIM function, thus: |
|
Thanks Richard - that is helpful (and thinking about it, now obvious! Sorry!)
With a statement in BBC4W that makes a call and puts the result in memory, is there an easy way to tell precisely how many bytes were returned to the memory space?
I presume that if you have allocated, say, 64 bytes, but the system returns void or false, then most of your allocated memory will NOT contain the data you expect!
Is there a way to tell this with a call such as:
SYS "SendMessage", hRichEdit%, EM_GETPARAFORMAT, 0, F%
Or is there an easier way to get the SYS call to put the data directly into a variable? The WinAPI says that the lparam should be a "Pointer to a PARAFORMAT structure that receives the paragraph formatting attributes of the current selection. "
I suppose I am asking "Is there a way to present the SYS call lparam so that it seems like an accessible structure to the Rich control, but is also a variable within your BBC prog?"
Thanks again
Nick
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Rich Edit controls
« Reply #3 on: Sep 1st, 2011, 08:12am » |
|
on Aug 31st, 2011, 9:56pm, Nick wrote:With a statement in BBC4W that makes a call and puts the result in memory, is there an easy way to tell precisely how many bytes were returned to the memory space? |
|
No, there's no way of knowing unless the API call itself returns that information (several do).
Quote:I suppose I am asking "Is there a way to present the SYS call lparam so that it seems like an accessible structure to the Rich control, but is also a variable within your BBC prog?" |
|
I'm not sure I fully understand the question, but you should be using the API as follows:
Code: DIM paraformat2{cbSize%, dwMask%, wNumbering{l&,h&}, wEffects{l&,h&}, \
\ dxStartIndent%, dxRightIndent%, dxOffset%, wAlignment{l&,h&}, \
\ cTabCount{l&,h&}, rgxTabs%, dySpaceBefore%, dySpaceAfter%, dyLineSpacing%, \
\ sStyle{l&,h&}, bLineSpacingRule&, bOutlineLevel&, wShadingWeight{l&,h&}, \
\ wShadingStyle{l&,h&}, wNumberingStart{l&,h&}, wNumberingStyle{l&,h&}, \
\ wNumberingTab{l&,h&}, wBorderSpace{l&,h&}, wBorderWidth{l&,h&}, wBorders{l&,h&}}
EM_GETPARAFORMAT = &43D
paraformat2.cbSize% = DIM(paraformat2{})
SYS "SendMessage", hRichEdit%, EM_GETPARAFORMAT, 0, paraformat2{} Richard.
|
|
Logged
|
|
|
|
Nick
New Member
member is offline


Gender: 
Posts: 33
|
 |
Re: Rich Edit controls
« Reply #4 on: Sep 1st, 2011, 1:33pm » |
|
OK - Thanks. That is helpful.
|
|
Logged
|
|
|
|
|