Главная страница | назад





Article #15254: Setting the size of font in a VBX control

 Question and Answer Database
FAQ254C.txt Setting the size of font in a VBX control
Category :Windows API
Platform :All
Product :BC++ 5.x
Question:
In my Windows API (not OWL) program, why does my call to
VBXSetPropByName(hVBXCtl, "FontSize", MyLong); not work?
Answer:
The prototype for VBXSetPropByName() (and VBXSetProp()) specifies
LONG as the type of that third parameter. The FontSize property
expects a float. Even if you pass a float, the compiler will
convert that float to a long and this long will be interpreted as
a float which will yield unexpected results in the size of the
font. Try this:
float fontSize = 20 * 20;
VBXSetPropByName(hTheVBXControl, "FontSize", *((long*)&fontSize));
This will fool the compiler into thinking the contents of fontSize
is a long, not a float. This way the compiler will not convert
fontSize, it will be passed as is.
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99