Page 1 of 1

Structure CHARFORMAT

Posted: Thu May 29, 2003 1:26 pm
by JoRo
the Structure is defined in the Api

Code: Select all

CHARFORMAT\cbSize=SizeOf(CHARFORMAT)
Debug CHARFORMAT\cbSize
End

But why is there the errormessage that this Variable doesent have a structure?

Johannes

Posted: Thu May 29, 2003 2:00 pm
by Froggerprogger
You have to define a name for the structure, and then this name is the container for the structure's elements.

Use it this way:

Code: Select all

structureName.CHARFORMAT
structureName\cbSize=SizeOf(CHARFORMAT) 
Debug structureName\cbSize 
End 
You tried to call structureType\element. So PB 'thinks' CHARFORMAT is a variable, that has not been declared as a pointer to a structure. So the following will work, too, though it's confusing the programmer.

Code: Select all

CHARFORMAT.CHARFORMAT
CHARFORMAT\cbSize=SizeOf(CHARFORMAT) 
Debug CHARFORMAT\cbSize 
End

Re: Structure CHARFORMAT

Posted: Thu May 29, 2003 2:07 pm
by WolfgangS
But why is there the errormessage that this Variable doesent have a structure?

Johannes
You can check the size of a STRUCTURE this way:

Code: Select all

debug SizeOf(CHARFORMAT)
It isn´t possible to read a value from a STRUCTURE !!!!
You can ONLY read a value from an ELEMENT of a structure:
Create an element of the CHARFORMAT STRUCTURE this way:

Code: Select all

myelement.CHARFORMAT
and read a value

Code: Select all

debug myelement\cbSize
or change a value:

Code: Select all

myelement\cbSize=41
I hope it helps ...
:wink: WolfgangS

Posted: Thu May 29, 2003 6:11 pm
by JoRo
@ Froggerprogger

thanks, now its clear. I thought I have to Dim the Structure
like Dim My.CHARFORMAT(1), but that would not work in a apimessage.

@Wolfgang
It is possible and documented in the helpfiles, search for "Sizeof"
The CHARFORMAT works only, if you set the first Element cbSize to the size of the structure
Windows need this, to recognize, what RichEditVersion is used, 2.0 or 3.0

Johannes