Script for changing fontsize

Hi all, I've checked all available documentation and I can't find the correct syntax for changing the FontSize. I've tried Object.FontSize = 14 and Object.FontSize = "14". Alas, both are rejected. I have documentation on DX Scripting, but FontSize isn't contained there. Any ideas anyone?
5,446 views 6 replies
Reply #1 Top
It's in the online docs: https://www.stardock.com/products/desktopx/documentation/index.html

However, it says you can use the FontSize FontName FontBold etc to get or set induvidual properties, but they can in reality only be used to get the value. In order to change the font you have to do it a bit awkwardly:

Object.SetFont
also Object.States("name").SetFont

Let you assign all font settings at once.
Syntax:
Object.SetFont fontName, size, boolBold, boolItalic, boolUnderline, boolStrikeOut, lfCharSet

You can leave the last parameter = 0



So you would have to do something like this:
Object.States("name").SetFont  Object.FontName, 20 Object.FontBold, Object.FontItalic, Object.FontUnderline, Object.FontStrikeout, 0

*phew!*
I really hope this get changed in the future....
Reply #2 Top
Yes you are right this does work and I would continue with my project, but it turns out to be not worth it. And, alas, the reason is the same cannot be applied to ActiveX controls, at least noone has shown me anyway how to set the font size in the much touted ActiveX DesktopX EditBox Control. In fact, the only default setting that is changable with this control is it can be made multiline. Did you ever wonder why all DesktopX themes that have nice little cute notepads in them only use the default 8 pt. text size? The above mentioned culprit is why. The alternative is to write sufficient VB script to code a text editor so... forget it no way. Unless, of course, I'm missing something in syntax and am not finding the correct namespace or something like that when applying the SetFont method. But enough of this complaint of mine, maybe we'll see some changes of this type in the upcoming new release of Object Desktop. Or, a new DesktopX object type that is a functional multiline editor. By the way if anyone knows how to kick some sense into these ActiveX controls and make them customizable let me know please.
Reply #3 Top

DesktopX.ScriptObject("test").Control.FontSize = 14

That allowed me to set the textsize of an edit control in an object named "test" from another  object.

Note that I didn't see any change until I had set a FontName property for the Edit control. In order to do that I had to manually type in a fontname (like "Tahoma") in the Control Properties and hit Return in order to make it stick. After that I could change size, bold, italic etc.

Reply #4 Top
Yep that did it. Thanks a whole bunch. I ran into problems early on in this one and gave up on changing things in the Control Properties box (I had tried setting the font size there to 14 with no luck, but hadn't put in a font name, oh boy!). Next time I'll try being more patient. The SetFont method may or may not work, but no matter the others like, FontSize, FontName, FontBold sure do. Now on to trying to figure out how to write to disc and create a textfile save. Hmmmm.. Later thanks again.


Reply #5 Top
I think you can adapt this script to write to a file: http://www.devguru.com/Technologies/vbscript/QuickRef/filesystemobject.html
Reply #6 Top
Thanks again thomassen. I'll try working on a script for file writing pretty soon now. Your help is appreciated.