Structure CHARFORMAT

Just starting out? Need help? Post your questions and find answers here.
JoRo
User
User
Posts: 70
Joined: Sat May 10, 2003 2:03 pm
Location: Essen, Germany
Contact:

Structure CHARFORMAT

Post 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
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post 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
%1>>1+1*1/1-1!1|1&1<<$1=1
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

Re: Structure CHARFORMAT

Post 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
JoRo
User
User
Posts: 70
Joined: Sat May 10, 2003 2:03 pm
Location: Essen, Germany
Contact:

Post 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
Post Reply